// JavaScript Document
var pathNameArray =window.location.pathname.split("/");
var rootPath = window.location.protocol + "//" + window.location.host;
if(pathNameArray[1]== "stackmeup") {
	//rootPath += "/" + pathNameArray[1] + "/" + pathNameArray[2] + "/";
	rootPath += "/" + pathNameArray[1] + "/" ;
} else {
	rootPath += "/";
}
var realEstateAjaxPath 	= rootPath + "ajax_queries/real-estate/";
var yourBodyAjaxPath 	= rootPath + "ajax_queries/your-body/";
var incomeAjaxPath 		= rootPath + "ajax_queries/income/";
var ajaxPath 			= rootPath + "ajax_queries/";
var BusinessAjaxPath 	= rootPath + "ajax_queries/business/";

function getCheckedValue(radioObj) 
{
	if(!radioObj) 
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined) 
		if(radioObj.checked) 
			return radioObj.value;
		else 
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;
	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');
	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	obj.value = temp;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey;
	} else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl) {
		return true;
	}
	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	return isFirstN || isFirstD || reg.test(keychar);
}
function acceptCommablockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey;
	} else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	//if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	
	if(keychar == ',')
	{
		return true;
	}
	else
	{
		if (isNaN(key)) return true;
		// check for backspace or delete, or if Ctrl was pressed
		
		if (key == 8 || isCtrl) {
			return true;
		}
		reg = /\d/;
		var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
		var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
		return isFirstN || isFirstD || reg.test(keychar);
	}
}

function cleanupSentence(Sentence) 
{
	var SourceSentence = Sentence;
	if(SourceSentence!='') {
		SourceSentence	= SourceSentence.replace(new RegExp(/^\s+/),""); // START
		SourceSentence	= SourceSentence.replace(new RegExp(/\s+$/),""); // END
		SourceSentence	= escape(SourceSentence);
		return SourceSentence;
	}
}

// Returns true if the last key pressed was a member of the valid character list,
// or a control key.  Useful to restrict input in a text box when used in conjunction
// with the onKeyPressed() event.
// <INPUT NAME=INT onKeyPress="return restrictChars(event,'0123456789')">
// Above will allow only numeric input into the text box. This function is 
// case insensitive so including "A" in the list is equivalent to "a".
function getKey(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}
function restrictChars(e, validList)
{
	if (validList=="0-9") {
		validList = "0123456789 "; // These space at end will allow space between charaters
	} else if (validList=="A-Z") {
		validList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; // These space at end will allow space between charaters
	} else if (validList=="0-9A-Z") {
		validList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "; // These space at end will allow space between charaters
	}
	var key, keyChar;
	key = getKey(e);
	if (key == null) return true;
	// get character - remove toLowerCase for case sensitive checking
	keyChar = String.fromCharCode(key).toLowerCase();
	// check valid characters - remove toLowerCase for case sensitive checking
	if (validList.toLowerCase().indexOf(keyChar) != -1)
	return true;
	// control keys
	// null, backspace, tab, carriage return, escape
	if ( key==0 || key==8 || key==9 || key==13 || key==27 )
	   return true;
	// else return false
	return false;
}

function stackmeupDiv() 
{	
	/*scroll(0,0);*/
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		StackResult		= eval(xmlHttp.responseText);
		var bzDivName	=	StackResult[0].ResultDivName;
		if(bzDivName == 'td_StockByCompanyRslt')
		{
			scroll(0,100);
		}
		else if(bzDivName == 'td_Top100GainersRslt')
		{
			scroll(0,150);
		}
		else if(bzDivName == 'td_Top100LosersRslt')
		{
			scroll(0,200);
		}
		else if(bzDivName != '')
		{
			scroll(0,300);
		}
		else
		{
			scroll(0,0);
		}
		var IncomeError	= StackResult[0].IncomeError; /* Only for displaying error message in the Income section */
		var AlertMessage = StackResult[0].AlertMessage; /* If any alert have to be given without showing the results */
		if (AlertMessage!="" && AlertMessage) {
			alert(AlertMessage);
			return false;
		} else {
			if (IncomeError==1) {
				alert('Please enter an amount greater than 0');
				document.frm_IncomeNationally.income.value="";
				document.frm_IncomeNationally.income.focus();
				return false;
			} else if(IncomeError==2) {
				alert('Please enter an amount greater than 0');
				document.frm_IncomeState.income.value="";
				document.frm_IncomeState.income.focus();
				return false;
			} else if(IncomeError==3) {
				alert('Please enter an amount greater than 0');
				document.frm_IncomeCounty.income.value="";
				document.frm_IncomeCounty.income.focus();
				return false;
			} else if(IncomeError==4) {
				alert('Please enter an amount greater than 0');
				document.frm_IncomeCity.income.value="";
				document.frm_IncomeCity.income.focus();
				return false;
			}/*End of displaying error message in the Income section*/
			else {
				var divStatus = sanitizeString(StackResult[0].DivStatus);
				$('rsltDivStatus').value	=	divStatus;
				if(divStatus!=3) {
					var result = sanitizeString(StackResult[0].ResultMessage);
				} else {
					var result = StackResult[0].ResultMessage;
				}
				if(result!="") {
					$('Question_div').className = 'hidediv';
					if (divStatus==1) {
						$('Result_NoratingImage_div').className = 'hidediv';
						$('Result_Listing_div').className = 'hidediv';
						$('Result_div').className = 'result_div';
						// Displaying the percentage value
						var PercentageResult 		= StackResult[0].PercentageResult;
						$('RankingID1').innerHTML 	= PercentageResult;
						// Showing the coloroured bar
						$('ratingTextarea1').className		= '';
						// Displaying the result text
						$('ResultMessage1').innerHTML 		= result;
						// Hiding JoinCommunity link and displaying Top of the stack div
						$('joinCommunityDiv').className		= 'HideJoinCommunityDiv';
						$('topStackPlaceHolder').className	= 'ShowtopstackDiv';
						// Displaying the top of the stack
						var topStackHtml					= sanitizeString(StackResult[0].TopStacker);
						$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						if (topStackHtml=="") {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						} else {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						}
						// Displaying the animation
						var AnimationHTML					= sanitizeString(StackResult[0].Animation);
						$('AnimationPlaceHolder1').innerHTML = AnimationHTML;
						var UpdateButton					= StackResult[0].DisplayUpdate;
						$('updateBtnPlaceHolder1').innerHTML = UpdateButton;
					} else if (divStatus==2) {
						$('Result_Listing_div').className = 'hidediv';
						$('Result_div').className = 'hidediv';
						$('Result_NoratingImage_div').className = 'result_div';
						// Displaying the percentage value
						var PercentageResult 		= StackResult[0].PercentageResult;
						$('RankingID2').innerHTML 	= PercentageResult;
						// Displaying the result text
						$('ResultMessage2').innerHTML 		= result;
						// Hiding JoinCommunity link and displaying Top of the stack div
						$('joinCommunityDiv').className		= 'HideJoinCommunityDiv';
						$('topStackPlaceHolder').className	= 'ShowtopstackDiv';
						// Displaying the top of the stack
						var topStackHtml					= sanitizeString(StackResult[0].TopStacker);
						$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						if (topStackHtml=="") {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						} else {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						}
						// Displaying the animation
						var AnimationHTML					= sanitizeString(StackResult[0].Animation);
						$('AnimationPlaceHolder2').innerHTML = AnimationHTML;
						var UpdateButton					= StackResult[0].DisplayUpdate;
						$('updateBtnPlaceHolder2').innerHTML = UpdateButton;
					} else if (divStatus==3) {
						$('Result_div').className = 'hidediv';
						$('Result_NoratingImage_div').className = 'hidediv';
						$('Result_Listing_div').className = 'result_div';
						// Displaying the result text
						$('ResultMessage3').innerHTML 		= result;
						// Hiding JoinCommunity link and displaying Top of the stack div
						$('joinCommunityDiv').className		= 'HideJoinCommunityDiv';
						$('topStackPlaceHolder').className	= 'ShowtopstackDiv';
						// Displaying the top of the stack
						var topStackHtml					= sanitizeString(StackResult[0].TopStacker);
						/* Placing the Top Stacking Home tab on the top */
						if (topStackHtml=="") {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						} else {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						}
						// Displaying the animation
						var AnimationHTML					= sanitizeString(StackResult[0].Animation);
						$('AnimationPlaceHolder3').innerHTML = AnimationHTML;
						var UpdateButton					= StackResult[0].DisplayUpdate;
						$('updateBtnPlaceHolder3').innerHTML = UpdateButton;
					}
					else if (divStatus==4) {
						/*$('Result_div').className = 'hidediv';
						$('Result_NoratingImage_div').className = 'hidediv';
						$('Result_Listing_div').className = 'result_div';*/
						hideCommonDivs();
						// Displaying the result text
						var divName	=	StackResult[0].ResultDivName;
						$(divName).innerHTML 		= result;
						// Hiding JoinCommunity link and displaying Top of the stack div
						$('joinCommunityDiv').className		= 'HideJoinCommunityDiv';
						$('topStackPlaceHolder').className	= 'ShowtopstackDiv';
						// Displaying the top of the stack
						var topStackHtml					= sanitizeString(StackResult[0].TopStacker);
						/* Placing the Top Stacking Home tab on the top */
						if (topStackHtml=="") {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						} else {
							$('topStackPlaceHolder').innerHTML 	= topStackHtml;
						}
						// Displaying the animation
						var AnimationHTML					= sanitizeString(StackResult[0].Animation);
						$('AnimationPlaceHolder3').innerHTML = AnimationHTML;
						var UpdateButton					= StackResult[0].DisplayUpdate;
						$('updateBtnPlaceHolder3').innerHTML = UpdateButton;
					}
					//displaying the result status
					$('StatMsg').innerHTML 				= StackResult[0].ResStatMsg;
					if (divStatus==1 || divStatus==2) {
						// Showing the coloroured bar
						var OverallPerformance = StackResult[0].Overall;
						/*if(OverallPerformance == 5)
						{
							if(divStatus==1)
							{
								$('Result_F_T1').style.display = "none";
								$('ResultTopStacker_F_T1').style.display = "inline";
							}
							else if(divStatus==2)
							{
								$('Result_F_T2').style.display = "none";
								$('ResultTopStacker_F_T2').style.display = "inline";
							}
						}
						else
						{
							if(divStatus==1)
							{
								$('ResultTopStacker_F_T1').style.display  = "none";
								$('Result_F_T1').style.display  = "inline";
							}
							else
							{
								$('ResultTopStacker_F_T2').style.display  = "none";
								$('Result_F_T2').style.display  = "inline";
							}
						}*/
						var resultGraphAreaName;
						switch (OverallPerformance) 
						{
							case "1" :
								setTimeout("PlayFlashMovie();",500);
								if (divStatus==1) {
									$('ratingTextarea1').className = 'poorTextarea';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "<!--[if gte IE 6]><script type='text/javascript'>startIeFix();</script><![endif]--><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='18' height='265'><param name='movie' value='"+rootPath+"images/animations/barAnimation1.swf'><param name='quality' value='high'><param name='bgcolor' value='#ffffff'><param name='wmode' value='transparent'><embed src='"+rootPath+"images/animations/barAnimation1.swf' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='265'></object><!--[if gte IE 6]></noscript><script type='text/javascript'>endIeFix();</script><![endif]-->";
								break;
							case "2" :
								setTimeout("PlayFlashMovie();",1000);
								if (divStatus==1) {
									$('ratingTextarea1').className = 'fairTextarea';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "<!--[if gte IE 6]><script type='text/javascript'>startIeFix();</script><![endif]--><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='18' height='265'><param name='movie' value='"+rootPath+"images/animations/barAnimation2.swf'><param name='quality' value='high'><param name='bgcolor' value='#ffffff'><param name='wmode' value='transparent'><embed src='"+rootPath+"images/animations/barAnimation2.swf' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='265'></object><!--[if gte IE 6]></noscript><script type='text/javascript'>endIeFix();</script><![endif]-->";
								break;
							case "3" :
								setTimeout("PlayFlashMovie();",1500);
								if (divStatus==1) {
									$('ratingTextarea1').className = 'averageTextarea';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "<!--[if gte IE 6]><script type='text/javascript'>startIeFix();</script><![endif]--><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='18' height='265'><param name='movie' value='"+rootPath+"images/animations/barAnimation3.swf'><param name='quality' value='high'><param name='bgcolor' value='#ffffff'><param name='wmode' value='transparent'><embed src='"+rootPath+"images/animations/barAnimation3.swf' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='265'></object><!--[if gte IE 6]></noscript><script type='text/javascript'>endIeFix();</script><![endif]-->";
								break;
							case "4" :
								setTimeout("PlayFlashMovie();",2000);
								if (divStatus==1) {
									$('ratingTextarea1').className = 'goodTextarea';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "<!--[if gte IE 6]><script type='text/javascript'>startIeFix();</script><![endif]--><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='18' height='265'><param name='movie' value='"+rootPath+"images/animations/barAnimation4.swf'><param name='quality' value='high'><param name='bgcolor' value='#ffffff'><param name='wmode' value='transparent'><embed src='"+rootPath+"images/animations/barAnimation4.swf' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='265'></object><!--[if gte IE 6]></noscript><script type='text/javascript'>endIeFix();</script><![endif]-->";
								break;
							case "5" : 
								setTimeout("PlayFlashMovie();",2500);
								if (divStatus==1) {
									$('ratingTextarea1').className = 'excellentTextarea';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "<!--[if gte IE 6]><script type='text/javascript'>startIeFix();</script><![endif]--><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='18' height='265'><param name='movie' value='"+rootPath+"images/animations/barAnimation5.swf'><param name='quality' value='high'><param name='bgcolor' value='#ffffff'><param name='wmode' value='transparent'><embed src='"+rootPath+"images/animations/barAnimation5.swf' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='265'></object><!--[if gte IE 6]></noscript><script type='text/javascript'>endIeFix();</script><![endif]-->";
								break;
							default : 
								if (divStatus==1) {
									$('ratingTextarea1').className = '';
									resultGraphAreaName = 'resultGraphArea1';
								} else if(divStatus==2) {
									resultGraphAreaName = 'resultGraphArea2';
								}
								$(resultGraphAreaName).innerHTML = "";
								break;
						}
						/*// Code to display the join us pop up if the user is not logged in and the user became 100 percent (top stacker)
						var PercentageValue = StackResult[0].PercentageValue;
						if(PercentageValue==1 && (divStatus!=2 || divStatus!=3)) {
							setTimeout("showStaticPopup('divTopStackerNonMember','','61')",5700);
						}*/
						//Code to display congratulation message for the first 100 top stackers
						var PercentageValue = StackResult[0].PercentageValue;
						if(PercentageValue == 1 || PercentageValue == 2 || PercentageValue == 3)
						{
							if(divStatus==1)
							{
								$('Result_F_T1').style.display = "none";
								$('ResultTopStacker_F_T1').style.display = "inline";
							}
							else if(divStatus==2)
							{
								$('Result_F_T2').style.display = "none";
								$('ResultTopStacker_F_T2').style.display = "inline";
							}
						}
						else
						{
							if(divStatus==1)
							{
								$('ResultTopStacker_F_T1').style.display  = "none";
								$('Result_F_T1').style.display  = "inline";
							}
							else if(divStatus==2)
							{
								$('ResultTopStacker_F_T2').style.display  = "none";
								$('Result_F_T2').style.display  = "inline";
							}
						}
						/*if(divStatus!=2 && divStatus!=3)*/
						if(divStatus!=3)
						{
							var timeDelay;
							if($('ratingTextarea1').className == 'averageTextarea')
							{
								timeDelay	=	4560;
							}
							else if($('ratingTextarea1').className == 'fairTextarea')
							{
								timeDelay	=	3900;
							}
							else if($('ratingTextarea1').className == 'goodTextarea')
							{
								timeDelay	=	4260;
							}
							else
							{
								timeDelay	=	3600;
							}
							if(PercentageValue == 3) 
							{
								setTimeout("showStaticPopup('divTopStackerNonMember2','','50')",timeDelay);
							}
							else if(PercentageValue == 1) 
							{
								setTimeout("showStaticPopup('divTopStackerNonMember3','','50')",timeDelay);
							}
							else if(PercentageValue == 2) 
							{
								setTimeout("showStaticPopup('divTopStackerNonMember','','50')",timeDelay);
							}
						}
					}
					
					var DivGoTo = StackResult[0].DivGoTo; /* If the scrolling Div top position has to be changed */
					if (DivGoTo!="" && DivGoTo) {
						window.location.href="#"+DivGoTo;
						scroll(0,0);
					} 
				}
			}
		}
	}
}
function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	} else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		return document.getElementById(movieName);
	}
}
function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject("animationMan");
	flashMovie.Play();
}
function replaceAll(strText)
{
	var strReplaceAll = strText;
	var intIndexOfMatch = strReplaceAll.indexOf( "," );
	// Loop over the string value replacing out each matching
	// substring.
	while (intIndexOfMatch != -1){
	// Relace out the current instance.
	strReplaceAll = strReplaceAll.replace( ",", "" )
	// Get the index of any next matching substring.
	intIndexOfMatch = strReplaceAll.indexOf( "," );
	}
 	return strReplaceAll;
}
function alltrim(str) 
{
     return str.replace(/^\s+|\s+$/g, '');
}
function validateprice(str) 
{
	str = alltrim(str);
	return /^\$?[1-9][0-9]{0,2}(,[0-9]{3})*(\.[0-9]{2})?$/.test(str);
}
function hideCommonDivs()
{
	document.getElementById('StatMsg').innerHTML 					= 	"";
	document.getElementById('Result_div').className					= 	'hidediv';
	document.getElementById('Result_NoratingImage_div').className	= 	'hidediv';
	document.getElementById('Result_Listing_div').className			= 	'hidediv';
	document.getElementById('Question_div').className				= 	'question_div';
	document.getElementById('AnimationPlaceHolder1').innerHTML 		=	"";
	document.getElementById('AnimationPlaceHolder2').innerHTML		=	"";
	document.getElementById('AnimationPlaceHolder3').innerHTML 		=	"";
	return true;
}
// JavaScript Document
/****************************************************************
The keystone of AJAX is the XMLHttpRequest object.

Different browsers use different methods to create the XMLHttpRequest object.

Internet Explorer uses an ActiveXObject, while other browsers uses the built-in JavaScript object called XMLHttpRequest.

To create this object, and deal with different browsers, we are using a "try and catch" statement.
*****************************************************************/
function myXMLHttpObject(handler)
{	
	var myRequest = null;
	try 
	{	
		myRequest = new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
	}
	catch (trymicrosoft) 
	{	
		try /* Internet Explorer */
			{	myRequest = new ActiveXObject("Msxml2.XMLHTTP");//Internet Explorer 6.0+
			}
			catch (othermicrosoft)
			{	try
				{	myRequest = new ActiveXObject("Microsoft.XMLHTTP");//Internet Explorer 5.5+
				}
				catch (failed)
				{	myRequest = null;
				}
			}
	}
	if (myRequest==null)
	alert("Error initializing XMLHttpRequest!");
	else
	{	
		if(handler!=null)
			myRequest.onreadystatechange=handler; 
		return myRequest;
	}
}

/*function trim(str)
{
  str = str.replace( /^\s+/g, "" ); // strip leading
  str = str.replace( /\s+$/g, "" ); // strip trailing
  return str;
} */
/*function trim(str) {
return ltrim(rtrim(str));
}

function ltrim(str) {
chars =  "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str) {
chars = "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}*/
/**
 * This function allows the user to enter only the numeric values in to a field
 * Give onkeypress="return isNumberKey(event)"  on to your input tag
 */
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	 return true;
}
function isDecimalKey(evt)
{
	 var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 46 || charCode > 57 || charCode ==47 ))
		return false;
	 return true;
}
// ==========================================================================
// Fuctions to mimic LTrim, RTrim, and Trim...

// Author          Aurélien Tisné	(CS)
// Date            03 avr. 2003 23:11:39
// Last Update     $Date$
// Version         $Revision$
// ==========================================================================

// --------------------------------------------------------------------------
// Remove leading blanks from our string.

// I               str - the string we want to LTrim
// Return          the input string without any leading whitespace

// Date            03 avr. 2003 23:12:13
// Author          Aurélien Tisné	(CS)
// --------------------------------------------------------------------------
function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

// --------------------------------------------------------------------------
// Remove trailing blanks from our string.

// I               str - the string we want to RTrim
// Return          the input string without any trailing whitespace

// Date            03 avr. 2003 23:13:50
// Author          Aurélien Tisné	(CS)
// --------------------------------------------------------------------------
function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}


// --------------------------------------------------------------------------
// Remove trailing and leading blanks from our string.

// I               str - the string we want to Trim
// Return          the trimmed input string

// Date            03 avr. 2003 23:15:09
// Author          Aurélien Tisné	(CS)
// --------------------------------------------------------------------------
function trim(str)
{
  return RTrim(LTrim(str));
}
function showMoreAnswers(id)
{
	if(document.getElementById("span"+id).innerHTML=="See more responses")
	{
		document.getElementById("span"+id).innerHTML="Hide more responses";
		document.getElementById("div"+id).style.display="inline";
	}
	else
	{
		document.getElementById("span"+id).innerHTML="See more responses";
		document.getElementById("div"+id).style.display="none";
	}
}
// EOF
var bo_ns_id = 0;
function startIeFix()
{
	if(isIE()) {
		document.write('<noscript id="bo_ns_id_' + bo_ns_id + '">');
	}
}
function endIeFix()
{
	if(isIE()) {
		var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
		var theNoScript = theObject.innerHTML;
		document.write(theNoScript);
	}
}
function isIE()
{
	var strBrowser = navigator.userAgent.toLowerCase();
	if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0) {
		return true;
	} else {
		return false;
	}
}
// JavaScript Document
var rand_no = Math.random();
var loginEvent;
function LoginValidation(evt)
{
	loginEvent = evt;
	var alias = trim($F('txtAlias'));
	var password = trim($F('txtPassword'));
	var retunURL = trim($F('returnURL'));
	if (alias=="") {
		alert('Enter Username');
		$('txtAlias').focus();
		return false;
	} else if (password=="") {
		alert('Enter Password');
		$('txtPassword').focus();
		return false;
	} else {
		parameters = "password="+base64_encode(password)+"&alias="+alias+'&retunURL='+retunURL;
		parameters += '&sNo='+rand_no;
		var Ajaxurl = ajaxPath + "signin_chk.php";
		makeRequest(Ajaxurl,parameters,signInCheck,"POST",false);
		return false;
	}
}
function LoginPopupValidation(evt)
{
	loginEvent = evt;
	var alias = trim($F('txtPopupAlias'));
	var password = trim($F('txtPopupPassword'));
	var retunURL = trim($F('returnURL'));
	if (alias=="") {
		alert('Enter Username');
		$('txtPopupAlias').focus();
		return false;
	} else if (password=="") {
		alert('Enter Password');
		$('txtPopupPassword').focus();
		return false;
	} else {
		parameters = "password="+base64_encode(password)+"&alias="+alias+'&retunURL='+retunURL;
		parameters += '&sNo='+rand_no;
		var Ajaxurl = ajaxPath + "signin_chk.php";
		makeRequest(Ajaxurl,parameters,signInCheck,"POST",false);
		return false;
	}
}
function signInCheck()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		LoginResult	= eval(xmlHttp.responseText);
		var StatusMessage = sanitizeString(LoginResult[0].StatusMessage);
		var ReturnURL = sanitizeString(LoginResult[0].ReturnURL);
		if (StatusMessage=="Success") {
			if($('windowOpener').value== 'FB_T_TOPSTACKER')
			{
				window.close();
				window.opener.location.href=ReturnURL;
			}
			else
			{
				window.location.href=ReturnURL;
			}
			return false;
		} else if (StatusMessage=="InvalidPassword") {
			if ($('divLoginBox')) {
				$('divLoginBox').className = 'hidediv'
			}
			$('div_forgetPassword').className = 'hidediv';
			showStaticPopup('divInvalidPassword',loginEvent,300);
			return false;
		} else if (StatusMessage=="InvalidAlias") {
			if ($('divLoginBox')) {
				$('divLoginBox').className = 'hidediv'
			}
			$('div_forgetAlias').className = 'hidediv';
			showStaticPopup('divInvalidAlias',loginEvent,300);
			return false;
		}
	}
}
function openRegistrationPage(retURL)
{
	window.close();
	window.opener.location.href=retURL;
}
function showForgetPassword()
{
	$('div_forgetPassword').className = 'showdiv';
	$('div_forgetPasswordError').innerHTML = '';
	$('forgetPasswordEmail').value = "";
	$('forgetPasswordEmail').focus();
}
function forgetPassword()
{
	/*var alias = trim($F('txtAlias'));*/
	var alias = "";
	var email = $F('forgetPasswordEmail');
	var emailError	= validateEmail(email);
	if (emailError != true) {
		$('div_forgetPasswordError').className = 'showdiv';
		$('div_forgetPasswordError').innerHTML = emailError;
	} else {
		parameters = "email="+email;
		parameters += "&alias="+alias;
		parameters += '&sNo='+rand_no;
		var Ajaxurl = ajaxPath + "community/SendPassword.php";
		makeRequest(Ajaxurl,parameters,sendPasswordResult,"POST",false);
		return false;
	}
}
function sendPasswordResult()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		passwordResult	= eval(xmlHttp.responseText);
		var StatusMessage = sanitizeString(passwordResult[0].StatusMessage);
		if (StatusMessage=="Send") {
			$('div_forgetPasswordError').className = 'showdiv';
			/*$('div_forgetPasswordError').innerHTML = StatusMessage;*/
			$('div_forgetPasswordError').innerHTML = 'Mail sent successfully. Please check your mail for new password';
			/*hidePopup('divInvalidPassword');*/
		} else { 
			$('div_forgetPasswordError').className = 'showdiv';
			$('div_forgetPasswordError').innerHTML = StatusMessage;
		}
	}
}
function showForgetAlias()
{
	$('div_forgetAlias').className = 'showdiv';
	$('div_forgetAliasError').innerHTML = '';
	$('forgetAliasEmail').value = "";
	$('forgetAliasEmail').focus();
}
function forgetAlias()
{
	var email = $F('forgetAliasEmail');
	var emailError	= validateEmail(email);
	if (emailError != true) {
		$('div_forgetAliasError').className = 'showdiv';
		$('div_forgetAliasError').innerHTML = emailError;
	} else {
		parameters = "email="+email;
		parameters += '&sNo='+rand_no;
		var Ajaxurl = ajaxPath + "community/SendAlias.php";
		makeRequest(Ajaxurl,parameters,sendAliasResult,"POST",false);
		return false;
	}
}
function sendAliasResult()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		aliasResult	= eval(xmlHttp.responseText);
		var StatusMessage = sanitizeString(aliasResult[0].StatusMessage);
		if (StatusMessage=="Send") {
			$('div_forgetAliasError').className = 'showdiv';
			/*$('div_forgetAliasError').innerHTML = StatusMessage;*/
			$('div_forgetAliasError').innerHTML = 'Mail sent successfully. Please check your mail for Username.';
			/*hidePopup('divInvalidAlias');*/
		} else { 
			$('div_forgetAliasError').className = 'showdiv';
			$('div_forgetAliasError').innerHTML = StatusMessage;
		}
	}
}
function showLoginPopup(divID,evt,height,retURL)
{
	if(retURL && retURL!="") {
		var retunURL = retURL;
		$('returnURL').value=retURL;
	} else {
		var retunURL = trim($F('returnURL'));
	}
	$(divID).className = 'showdiv';
	showStaticPopup(divID,evt,height);
}
function base64_encode( data ) 
{
	// Encodes data with MIME base64
	// 
	// +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_base64_encode/
	// +       version: 809.522
	// +   original by: Tyler Akins (http://rumkin.com)
	// +   improved by: Bayron Guevara
	// +   improved by: Thunder.m
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)        
	// -    depends on: utf8_encode
	// *     example 1: base64_encode('Kevin van Zonneveld');
	// *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
	// mozilla has this native
	// - but breaks in 2.0.0.12!
	//if (typeof window['atob'] == 'function') {
	//    return atob(data);
	//}
	var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc="", tmp_arr = [];
	data = utf8_encode(data);
	do { // pack three octets into four hexets
		o1 = data.charCodeAt(i++);
		o2 = data.charCodeAt(i++);
		o3 = data.charCodeAt(i++);
		bits = o1<<16 | o2<<8 | o3;
		h1 = bits>>18 & 0x3f;
		h2 = bits>>12 & 0x3f;
		h3 = bits>>6 & 0x3f;
		h4 = bits & 0x3f;
		// use hexets to index into b64, and append result to encoded string
		tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
	} while (i < data.length);
	enc = tmp_arr.join('');
	switch( data.length % 3 )
	{
		case 1:
			enc = enc.slice(0, -2) + '==';
			break;
		case 2:
			enc = enc.slice(0, -1) + '=';
			break;
	}
	return enc;
}
function utf8_encode ( string ) 
{
	// Encodes an ISO-8859-1 string to UTF-8
	// 
	// +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_utf8_encode/
	// +       version: 811.1414
	// +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: sowberry
	// +    tweaked by: Jack
	// +   bugfixed by: Onno Marsman
	// +   improved by: Yves Sucaet
	// +   bugfixed by: Onno Marsman
	// *     example 1: utf8_encode('Kevin van Zonneveld');
	// *     returns 1: 'Kevin van Zonneveld'
	string = (string+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n");
	var utftext = "";
	var start, end;
	var stringl = 0;
	start = end = 0;
	stringl = string.length;
	for (var n = 0; n < stringl; n++) {
		var c1 = string.charCodeAt(n);
		var enc = null;
		if (c1 < 128) {
			end++;
		} else if((c1 > 127) && (c1 < 2048)) {
			enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
		} else {
			enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
		}
		if (enc != null) {
			if (end > start) {
				utftext += string.substring(start, end);
			}
			utftext += enc;
			start = end = n+1;
		}
	}
	if (end > start) {
		utftext += string.substring(start, string.length);
	}
	return utftext;
}
/* 
Javascript function to open the topstacker from the other topstackers pop up window
*/
function showTopstackerFrmPopup(retURL, showLogin) {
	/*alert(showLogin);*/
	if(showLogin==1) {
		window.location.href=retURL;
		/*alert(retURL);*/
	} else {
		showLoginPopup('divLoginBox',loginEvent,300,retURL);
	}
}
function RegisterValidation()
{
	var submitstatus = true;
	password = trim($F('txtOptInPassword'));
	confpassword = trim($F('txtOptInConfirmPassword'));
	if(trim($F('txtOptInEmail'))=="")
	{
		alert("Please enter Email Address");
		$('txtOptInEmail').value="";
		$('txtOptInEmail').focus();
		submitstatus = false;
		return false;
	} else {
		var emailError	= validateEmail($F('txtOptInEmail'));
		if (emailError != true) {
			alert(emailError);
			$('txtOptInEmail').focus();
			submitstatus = false;
			return false;
		}
		var confemail = trim($F('txtOptInConfirmEmail'));
		if (confemail=="" || confemail!=$F('txtOptInEmail')) {
			alert("Please confirm your email address");
			$('txtOptInConfirmEmail').focus();
			submitstatus = false;
			return false;
		}
	}
	if(password=="")
	{
		alert("Please enter Password");
		$('txtOptInPassword').value="";
		$('txtOptInPassword').focus();
		submitstatus = false;
		return false;
	}
	if(confpassword!=$F('txtOptInPassword'))
	{
		alert("Check the password typed.");
		$('txtOptInPassword').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtOptInFname'))=="")
	{
		alert("Please enter First name");
		$('txtOptInFname').value="";
		$('txtOptInFname').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtOptInLname'))=="")
	{
		alert("Please enter Last name");
		$('txtOptInLname').value="";
		$('txtOptInLname').focus();
		submitstatus = false;
		return false;
	}
	var zipcode = trim($F('txtOptInZipCode'));
	if(zipcode=="")
	{
		alert("Please enter Zip Code");
		$('txtOptInZipCode').value="";
		$('txtOptInZipCode').focus();
		submitstatus = false;
		return false;
	} else if (isNaN(zipcode)) {
		alert("Please enter correct Zip Code");
		$('txtOptInZipCode').focus();
		submitstatus = false;
		return false;
	}
	var dobStatus = true;
	if(trim($F('txtOptInDOBMonth'))==0) {
		alert("Please select Month of Birth");
		$('txtOptInDOBMonth').value="";
		$('txtOptInDOBMonth').focus();
		submitstatus = false;
		dobStatus = false;
		return false;
	}
	if(trim($F('txtOptInDOBDay'))==0) {
		alert("Please select Day of Birth");
		$('txtOptInDOBDay').value="";
		$('txtOptInDOBDay').focus();
		submitstatus = false;
		dobStatus = false;
		return false;
	}
	if(trim($F('txtOptInDOBYear'))==0) {
		alert("Please select Year of Birth");
		$('txtOptInDOBYear').value="";
		$('txtOptInDOBYear').focus();
		submitstatus = false;
		dobStatus = false;
		return false;
	}
	if (dobStatus==true) {
		var dob = $F('txtOptInDOBMonth')+'/'+$F('txtOptInDOBDay')+'/'+$F('txtOptInDOBYear');
		var dobError = isValidDate(dob);
		if (dobError != true) {
			alert(dobError);
			$('txtOptInDOBMonth').focus();
			submitstatus = false;
			return false;
		} else {
			$('txtOptInDOB').value = dob;
		}
	}
	/*if(trim($F('txtOptInDOB'))=="")
	{
		alert("Please enter Date of Birth");
		$('txtOptInDOB').value="";
		$('txtOptInDOB').focus();
		submitstatus = false;
		return false;
	} else {
		var dobError = isValidDate($F('txtOptInDOB'));
		if (dobError != true) {
			alert(dobError);
			$('txtOptInDOB').focus();
			submitstatus = false;
			return false;
		}
	}*/
	
	var radioLen = document.frmOptIn.txtOptInGender.length;
	var gender = 0;
	for(var i = 0; i < radioLen; i++) 
	{
		if(document.frmOptIn.txtOptInGender[i].checked == true)
			gender=document.frmOptIn.txtOptInGender[i].value;
	}
	if (gender==0) {
		alert("Select your gender");
		submitstatus = false;
		return false;
	}
	var alias = trim($F('txtOptInAlias'));
	if (alias=="") {
		alert("Please enter Username");
		$('txtOptInAlias').focus();
		return false;
	}
	var agree = document.frmOptIn.OptInagree.checked;
	if (agree==false) {
		alert("You must agree to our Privacy Policy and Terms of Use");
		submitstatus = false;
		return false;
	}
	
	if (submitstatus==true) {
		InsertOptInInfo(alias,$F('txtOptInEmail'),password,trim($F('txtOptInFname')),trim($F('txtOptInLname')),document.getElementById('txtOptInCountry').value,$('txtOptInZipCode').value,dob,gender)
	}
}
function validateEmail(tfld) 
{
    var error="";
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (tfld=="") {
        error = "Enter email address.\n";
    } else if (!emailFilter.test(tfld)) {
        error = "Enter valid email address.\n";
    } else if (tfld.match(illegalChars)) {
    	error = "Enter valid email address.\n";
		//error = "Email address contains illegal characters.\n";
    } else {
        return true;
    }
    return error;
}
function isValidDate(dateStr) 
{
	var currentTime = new Date();
	var currentYear	= currentTime.getFullYear();
	var allowedYear = currentYear-16; // 16 years old or more only allowed to register
	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
	// Also separates date into month, day, and year variables
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
	// To require a 4 digit year entry, use this line instead:
	// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	var error = "";
	if (matchArray == null) {
		error = "Date is not in a valid format.";
		return error;
	} else {
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
	
		if (month < 1 || month > 12) { // check month range
			error = "Month must be between 1 and 12.";
			return error;
		} else if (day < 1 || day > 31) {
			error = "Day must be between 1 and 31.";
			return error;
		} else if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			error = "Month "+month+" doesn't have 31 days!";
			return error;
		} else if (year > allowedYear) {
			error = "You must be 16 years old or more";
			return error;
		} else if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) {
				error = "February " + year + " doesn't have " + day + " days!";
				return error;
		   	} else {
				return true;
		   	}
		} else {
			return true;
		}
	} 
}
function InsertOptInInfo(Alias,Email,Password,FirstName,LastName,CountryCode,ZipCode,DOB,Gender)
{
	var Ajaxurl 		= ajaxPath + "community/InsertLoginInfo.php";
	var parameters		='&Alias=' +Alias+'&Email=' +Email+ '&Password='+Password+ '&FirstName='+FirstName+ '&LastName='+LastName+ 
						'&CountryCode='+CountryCode+ '&ZipCode='+ZipCode+ '&DOB='+DOB+ '&Gender='+Gender;
	makeRequest(Ajaxurl,parameters,InsertOptInInfoStatus,"POST",false);
}
function InsertOptInInfoStatus() 
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		if(trim(xmlHttp.responseText)=='Username already exist. Please try some other.') {
			alert(trim(xmlHttp.responseText));
			document.getElementById('txtAliasEdit').value="";
			document.getElementById('txtAliasEdit').focus();
		} else if(trim(xmlHttp.responseText)!="") {
			alert("Your Opt-In details inserted successfully.");
			window.location = xmlHttp.responseText;
		} else {
			alert("Your log-info updated successfully.");
		}
	}
}
// JavaScript Document
/*
	Developer   : Abhilash Kumar	
	E-Mail      : mabhilashkumar@gmail.com
	Description : Ajax Functions
*/
/* --------------------------   AJAX FUNCTION STARTS HERE  -------------------------- */
/*
Return the id of the attribute.
*/
function $(id){return document.getElementById(id);}

/*
Return the value of the attribute.
*/
function $F(id){return document.getElementById(id).value;}

/*
Return the xmlHttpObject
*/
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		try
		{
			objXmlHttp=new XMLHttpRequest()
			objXmlHttp.onload=handler
			objXmlHttp.onerror=handler 
			return objXmlHttp
		}
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 	
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		try
		{
			objXmlHttp=new XMLHttpRequest()
			objXmlHttp.onload=handler
			objXmlHttp.onerror=handler 
			return objXmlHttp
		}
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 	
	}
} 
/*
Send an ajax request to the url mentioned
URL		   : SERVER SIDE SCRIPT NAME
PARAMETERS : URL parameters
callback   : callback function
requesttype: POST OR GET
async      : asycronous or synchronous, TRUE or FALSE
*/
function makeRequest(url,parameters,callback,requesttype,async)
{
	
	if(requesttype=='POST')
	{
		xmlHttp=GetXmlHttpObject(callback) 
		xmlHttp.open("POST",url,async);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlHttp.send(parameters);
	}else if(requesttype=="GET")
	{
		url    = url+'?'+parameters;
		xmlHttp=GetXmlHttpObject(callback) 
		xmlHttp.open("GET", url , async) 
		xmlHttp.send(null) 
	}
}

/* -------------------------------------------------------------
// function for sanitizing tha data
----------------------------------------------------------------- */
function sanitizeString(resText)
{
	var response = resText.replace(/(\r\n|\r|\n)/g, "<br />");
	response = response.replace(/(<br>)/g, "");
	response = response.replace(/(&quot;)/g, "\"");
	return response;
}
var ns6	= document.getElementById&&!document.all;
var x = 0, y = 0;

function showStaticPopup(divid,e,topheight)
{ 
	document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
	document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	document.getElementById('both-grid-overlay').style.height = _docHeight+'px';
	getScrollXY();
	var top=0;
	var left=0;
	if(topheight != 1)
		scroll(0,50);
	if(topheight==50) {
		top=0;
		left=90;topheight=50;
		document.getElementById('both-grid-overlay').style.height = (_docHeight+700)+'px';
	} else if(topheight==60) { 
		top=0;
		left=90;topheight=50;
	} else if(topheight==300) {
		top = 0;
	} else if(topheight==61) {
		top = 5;
	}else {
		topheight=50;
	}
	if (ns6) {
		document.getElementById(divid).style.left = (_docWidth/4)-left+'px';
		document.getElementById(divid).style.top = topheight+top+'px';
	} else {
		document.getElementById(divid).style.pixelLeft = (_docWidth/4)-left;
		document.getElementById(divid).style.pixelTop = topheight+top;
	} 
	document.getElementById(divid).style.display = "";
	document.getElementById(divid).style.zIndex =200;
	try {
		document.getElementById("lblResult").innerHTML="";
	}
	catch(err) {
		return false ;
	}
	
	return false ;
}
function fadeOpenerWindow(divid,e,topheight,retURL)
{ 
	/*window.opener.document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (window.opener.document.height !== undefined) ? window.opener.document.height : window.opener.document.body.offsetHeight;
	var _docWidth = (window.opener.document.width !== undefined) ? window.opener.document.width : window.opener.document.body.offsetWidth;
	window.opener.document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	window.opener.document.getElementById('both-grid-overlay').style.height = _docHeight+'px';*/
	showLoginPopup(divid,e,topheight,retURL);
}
function closeWindow(retURL)
{
	window.close();
	window.opener.location.href=retURL;
}
function getScrollXY() {
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
}
function hidePopup(divid)
{
	document.body.style.overflow="auto";
	scroll(x,y);
	document.getElementById('both-grid-overlay').style.display='none';
	document.getElementById(divid).style.display="none";
}
function hidePopupOpener(divid)
{
	window.opener.document.body.style.overflow="auto";
	window.opener.scroll(x,y);
	window.opener.document.getElementById('both-grid-overlay').style.display='none';
	window.opener.document.getElementById(divid).style.display="none";
	hidePopup(divid)
}
function showEmail(divid,e,topheight,Email)
{
	document.getElementById('lblEmail').innerHTML=Email.toUpperCase();
	document.getElementById('txtEmailBody').value="";
	document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
	document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	document.getElementById('both-grid-overlay').style.height = _docHeight+'px';
	getScrollXY();
	scroll(0,0);
	if (ns6) {
		document.getElementById(divid).style.left = _docWidth/4+'px';
		document.getElementById(divid).style.top = topheight+'px';

	} else {
		document.getElementById(divid).style.pixelLeft = _docWidth/4;
		document.getElementById(divid).style.pixelTop = topheight;
	}
	document.getElementById(divid).style.display = "";
	document.getElementById("divContactUS").style.display = "none";
	document.getElementById("divAdvertiseUS").style.display = "none";
	document.getElementById("divFAQ").style.display = "none";
	document.getElementById("divPrivacyTerms").style.display = "none";
	return false ;
}
function hidePopupEmail(divid,e)
{
	document.getElementById(divid).style.display="none";
	document.getElementById('both-grid-overlay').style.display='none';
}
function showMessage(divid,e,topheight,MessageId,UserId)
{
	document.getElementById('tdExpertise').innerHTML=document.getElementById('tdExpertise'+UserId).innerHTML;
	document.getElementById("hdPrivateRecordId").value=UserId;
	document.getElementById("hdBrainTrustId").value=UserId;
	document.getElementById("tdViewPMBody").disabled=true;
	document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
	document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	document.getElementById('both-grid-overlay').style.height = _docHeight+'px';
	getScrollXY();
	var top=0;
	scroll(0,0);
	if(topheight>30) {
		document.body.style.overflow="hidden";
	} else if(topheight=25) {
		top=30;
	}
	if (ns6) {
		document.getElementById(divid).style.left = _docWidth/4+'px';
		document.getElementById(divid).style.top = topheight+top+'px';
	} else {
		document.getElementById(divid).style.pixelLeft = _docWidth/4;
		document.getElementById(divid).style.pixelTop = topheight+top;
	}
	document.getElementById(divid).style.display = "";
	if(document.getElementById("divInBox").style.display=="inline") {
		CommentId="hdComment"+MessageId;
		document.getElementById("imgSendPrivateReply").style.display="none";
		document.getElementById("imgReplyPrivateMessage").style.display="inline";
		document.getElementById("imgBrainTrustPrivateMessage").style.display="inline";
		document.getElementById("imgSavePrivateMessage").style.display="inline";
		document.getElementById("imgBlockUserPrivate").style.display="inline";
		var subject=document.getElementById("tdPMSubject"+MessageId).innerHTML;
		var date=document.getElementById("tdMessageDate"+MessageId).innerHTML;
		var	MessageCount=document.getElementById("hdCount").value;
		if(MessageCount!="NO") 	{
			ReadMessage(MessageId);
			/*if((document.getElementById("tdPMSubject"+MessageId).innerHTML.indexOf("<b>")!=-1) || (document.getElementById("tdPMSubject"+MessageId).innerHTML.indexOf("<B>")!=-1))
			{
				MessageCount=MessageCount-1;
				if(MessageCount<10 && MessageCount>0) {
					MessageCount="0"+""+MessageCount;
				}
				document.getElementById("hdCount").value=MessageCount;
			}
			if(MessageCount==0) {
				MessageCount="NO";
			}
			document.getElementById("tdMessageCount").innerHTML="&nbsp;"+MessageCount+" NEW MESSAGES&nbsp;";*/
		} else {
			document.getElementById("hdCount").value="NO";
			document.getElementById("tdMessageCount").innerHTML="&nbsp;NO MESSAGES&nbsp;";
		}
		subject=subject.replace("<b>","");
		subject=subject.replace("</b>","");
		subject=subject.replace("<B>","");
		subject=subject.replace("</B>","");
		date=date.replace("<b>","");
		date=date.replace("</b>","");
		date=date.replace("<B>","");
		date=date.replace("</B>","");
		document.getElementById("tdPMSubject"+MessageId).innerHTML=subject;
		document.getElementById("tdMessageDate"+MessageId).innerHTML=date;
		document.getElementById("tdViewPMSubject").innerHTML=subject;
		document.getElementById("tdViewPMDate").innerHTML=date;
		document.getElementById("tdViewPMImageSRC").src=document.getElementById("tdSenderImage"+MessageId).src;
		document.getElementById("tdViewPMBody").value=document.getElementById(CommentId).value;
		document.getElementById("tdViewSenderName").innerHTML=document.getElementById("tdSendername"+MessageId).innerHTML;
		document.getElementById("tdMessageFrom1").innerHTML="MESSAGE FROM";
		document.getElementById("tdMessageFrom2").innerHTML="MESSAGE FROM";
		document.getElementById("hdMessageId").value=MessageId;
		document.getElementById("tdBRViewFrom1").innerHTML="BRAIN REQUEST FROM";
		document.getElementById("tdBRViewFrom2").innerHTML="BRAIN REQUEST FROM";
		document.getElementById("imgAccept").style.display="inline";
		document.getElementById("imgDeny").style.display="inline";
		document.getElementById("tdViewBRName").innerHTML=document.getElementById("tdSendername"+MessageId).innerHTML;
		document.getElementById("tdViewBRSubject").innerHTML=subject;
		document.getElementById("tdViewBRDate").innerHTML=date;
		document.getElementById("tdViewBRImageSRC").src=document.getElementById("tdSenderImage"+MessageId).src;
		document.getElementById("tdViewBRBody").value=document.getElementById(CommentId).value;
	} else {
		CommentId="hdSentComment"+MessageId;
		var subject=document.getElementById("tdSentPMSubject"+MessageId).innerHTML;
		var date=document.getElementById("tdSentMessageDate"+MessageId).innerHTML;
		document.getElementById("imgSendPrivateReply").style.display="none";
		document.getElementById("imgReplyPrivateMessage").style.display="none";
		document.getElementById("imgBrainTrustPrivateMessage").style.display="none";
		document.getElementById("imgSavePrivateMessage").style.display="none";
		document.getElementById("imgBlockUserPrivate").style.display="none";
		document.getElementById("tdMessageFrom1").innerHTML="MESSAGE TO";
		document.getElementById("tdMessageFrom2").innerHTML="MESSAGE TO";
		document.getElementById("tdViewPMSubject").innerHTML=subject;
		document.getElementById("tdViewPMDate").innerHTML=date;
		document.getElementById("tdViewPMImageSRC").src=document.getElementById("tdSentSenderImage"+MessageId).src;
		document.getElementById("tdViewPMBody").value=document.getElementById(CommentId).value;
		document.getElementById("tdViewSenderName").innerHTML=document.getElementById("tdSentSendername"+MessageId).innerHTML;
		document.getElementById("tdBRViewFrom1").innerHTML="BRAIN REQUEST TO";
		document.getElementById("tdBRViewFrom2").innerHTML="BRAIN REQUEST TO";
		document.getElementById("imgAccept").style.display="none";
		document.getElementById("imgDeny").style.display="none";
		document.getElementById("tdViewBRName").innerHTML=document.getElementById("tdSentSendername"+MessageId).innerHTML;
		document.getElementById("tdViewBRSubject").innerHTML=subject;
		document.getElementById("tdViewBRDate").innerHTML=date;
		document.getElementById("tdViewBRImageSRC").src=document.getElementById("tdSentSenderImage"+MessageId).src;
		document.getElementById("tdViewBRBody").value=document.getElementById(CommentId).value;
	}
	return false ;
}
function SendEmail(Subject)
{	
	if(trim(document.getElementById("txtEmailBody").value)!="") {
		var Ajaxurl 		= ajaxPath + "community/SendEmail.php";
		var parameters		='TO=' +document.getElementById("lblEmail").innerHTML.toLowerCase()+ '&Body='+document.getElementById("txtEmailBody").value+ '&Subject='+Subject;
		makeRequest(Ajaxurl,parameters,SendEmailStatus,"POST",false);
	} else {
		document.getElementById("txtEmailBody").value="";
		document.getElementById("txtEmailBody").focus();
		alert("Message body cannot be blank.");
	}
}
function SendEmailStatus() 
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		hidePopup('divContactUSEmail');
		alert(xmlHttp.responseText);
	}
	
}
function ReadMessage(MessageId)
{
	
	var Ajaxurl 		= ajaxPath + "community/ReadMessage.php";
	
	var parameters		='ID=' +MessageId;
	makeRequest(Ajaxurl,parameters,ReadMessageStatus,"POST",false);
}
function ReadMessageStatus() 
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		GetMessageCount()
	}
	
}
function SaveAdvertiseDetails()
{
	var Ajaxurl 		= ajaxPath + "community/AdvertiseDetails.php";
	var parameters		='Fname=' +document.getElementById("txtFname").value+ '&Lname='+document.getElementById("txtLname").value+'&Company='+document.getElementById("txtCompany").value+ '&WebSite='+document.getElementById("txtWebSite").value+ '&Email='+document.getElementById("txtEmail").value+'&Phone='+document.getElementById("txtPhone").value+ '&Country='+document.getElementById("ddlCountry").value+'&ZipCode='+document.getElementById("txtZipCode").value+ '&Industry='+document.getElementById("txtIndustry").value+'&Budget='+document.getElementById("txtBudget").value+ '&Section='+document.getElementById("txtSection").value+'&SubSection='+document.getElementById("txtSubSection").value+ '&Market='+document.getElementById("txtAreaMarket").value+'&Agree'+document.getElementById("chkAgree").checked;
	makeRequest(Ajaxurl,parameters,SaveAdvertiseStatus,"POST",false);
}
function SaveAdvertiseStatus() 
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		hidePopup("divAdvertiseUS");
	}
	
}
///////////////////END///////////////////
function AdvertiseValidation()
{
	var submitstatus = true;
		
	if(trim($F('txtFname'))=="")
	{
		alert("Please enter First name");
		$('txtFname').value="";
		$('txtFname').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtLname'))=="")
	{
		alert("Please enter Last name");
		$('txtLname').value="";
		$('txtLname').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtCompany'))=="")
	{
		alert("Please enter Company name");
		$('txtCompany').value="";
		$('txtCompany').focus();
		submitstatus = false;
		return false;
	}
	
	if(trim($F('txtWebSite'))=="")
	{
		alert("Please enter Website Address");
		$('txtWebSite').value="";
		$('txtWebSite').focus();
		submitstatus = false;
		return false;
	} else {
		var emailError	= Validate();
		if (emailError != true) {
			alert("Please enter valid Website Address.Example: http://www.stackmeup.com/");
			$('txtWebSite').focus();
			submitstatus = false;
			return false;
		}
		
	}
	
	if(trim($F('txtEmail'))=="")
	{
		alert("Please enter Email Address");
		$('txtEmail').value="";
		$('txtEmail').focus();
		submitstatus = false;
		return false;
	} else {
		var emailError	= validateEmail($F('txtEmail'));
		if (emailError != true) {
			alert(emailError);
			$('txtEmail').focus();
			submitstatus = false;
			return false;
		}
		
	}
	if(trim($F('txtPhone'))=="")
	{
		alert("Please enter phone number");
		$('txtPhone').value="";
		$('txtPhone').focus();
		submitstatus = false;
		return false;
	}
	else
	{
		var emailError	= check_usphone($('txtPhone').value);
		if (emailError != true) {
			alert("Please enter valid phone number");
			$('txtPhone').focus();
			submitstatus = false;
			return false;
		}
	}
	var zipcode = trim($F('txtZipCode'));
	if(zipcode=="")
	{
		alert("Please enter Zip Code");
		$('txtZipCode').value="";
		$('txtZipCode').focus();
		submitstatus = false;
		return false;
	} else if (isNaN(zipcode)) {
		alert("Please enter correct Zip Code");
		$('txtZipCode').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtIndustry'))=="")
	{
		alert("Please enter industry name");
		$('txtIndustry').value="";
		$('txtIndustry').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtBudget'))=="")
	{
		alert("Please enter your total budget.");
		$('txtBudget').value="";
		$('txtBudget').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtSection'))=="")
	{
		alert("Please enter section name.");
		$('txtSection').value="";
		$('txtSection').focus();
		submitstatus = false;
		return false;
	}
	if(trim($F('txtSubSection'))=="")
	{
		alert("Please enter section name.");
		$('txtSubSection').value="";
		$('txtSubSection').focus();
		submitstatus = false;
		return false;
	}
	if (submitstatus==true) {
		SaveAdvertiseDetails();
	}
}
function check_usphone(phonenumber){
    var regex = /^(\()?(\d{3})([\)-\. ])?(\d{3})([-\. ])?(\d{4})$/;
    return regex.test(phonenumber);
} 
function Validate() {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	return (v.test(document.getElementById("txtWebSite").value));

} 
function validateEmail(tfld) 
{
    var error="";
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;

    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (tfld=="") {
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        error = "Please enter a valid email address.\n";
    } else if (tfld.match(illegalChars)) {
        error = "The email address contains illegal characters.\n";
    } else {
        return true;
    }
    return error;
}
function showPublicComment(divid,e,topheight,MessageId)
{
	document.getElementById("imgReplyMessage").style.display="inline";
	document.getElementById("imgBrainTrustMessage").style.display="inline";
	document.getElementById("imgSaveMessage").style.display="inline";
	document.getElementById("imgBlockUser").style.display="inline";
	document.getElementById("tdViewPublicBody").disabled=true;
	document.getElementById('tdPublicMessageFrom2').innerHTML="MESSAGE FROM";
	document.getElementById('tdPublicMessageFrom1').innerHTML="MESSAGE FROM";
	document.getElementById("imgSendReply").style.display="none";
	document.getElementById("hdRecordId").value=MessageId;
	document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
	document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	document.getElementById('both-grid-overlay').style.height = _docHeight+'px';
	getScrollXY();
	var top=0;
	scroll(0,0);
	if(topheight>30) {
		document.body.style.overflow="hidden";
	} else if(topheight=25) {
		top=30;
	}
	if (ns6) {
		document.getElementById(divid).style.left = _docWidth/4+'px';
		document.getElementById(divid).style.top = topheight+top+'px';
	} else {
		document.getElementById(divid).style.pixelLeft = _docWidth/4;
		document.getElementById(divid).style.pixelTop = topheight+top;
	}
	document.getElementById(divid).style.display = "";
	CommentId="hdPComment"+MessageId;
	var subject=document.getElementById("tdPSubject"+MessageId).innerHTML;
	var date=document.getElementById("tdPCommentDate"+MessageId).innerHTML;
	var	MessageCount=document.getElementById("hdCommentCount").value;
	
	if(MessageCount!="NO")
	{
		ReadComment(MessageId);
		if(document.getElementById("tdPSubject"+MessageId).innerHTML.indexOf("<b>")!=-1 ||document.getElementById("tdPSubject"+MessageId).innerHTML.indexOf("<B>")!=-1)
		{
			MessageCount=MessageCount-1;
			if(MessageCount<10 && MessageCount>0)
			{
				MessageCount="0"+""+MessageCount;
			}
			else if(MessageCount==0) {
				MessageCount="NO";
			}
		}
		document.getElementById("hdCommentCount").value=MessageCount;
		document.getElementById("tdCommentCount").innerHTML="&nbsp;"+MessageCount+" NEW MESSAGES&nbsp;";
	}
	else {
		document.getElementById("hdCommentCount").value="NO";
		document.getElementById("tdCommentCount").innerHTML="&nbsp;NO MESSAGES&nbsp;";
	}
	subject=subject.replace("<b>","");
	subject=subject.replace("</b>","");
	subject=subject.replace("<B>","");
	subject=subject.replace("</B>","");
	date=date.replace("<b>","");
	date=date.replace("</b>","");
	date=date.replace("<B>","");
	date=date.replace("</B>","");
	document.getElementById("tdPSubject"+MessageId).innerHTML=subject;
	document.getElementById("tdPCommentDate"+MessageId).innerHTML=date;
	document.getElementById("tdViewPublicSubject").innerHTML=subject;
	document.getElementById("tdViewPublicDate").innerHTML=date;
	document.getElementById("tdViewPublicImageSRC").src=document.getElementById("tdPSenderImage"+MessageId).src;
	document.getElementById("tdViewPublicBody").value=document.getElementById(CommentId).value;
	document.getElementById("tdViewPublicSenderName").innerHTML=document.getElementById("tdPSendername"+MessageId).innerHTML;
	return false ;
}
function ReadComment(CommentId)
{
	var Ajaxurl 		= ajaxPath + "community/ReadComment.php";
	var parameters		='ID=' +CommentId;
	makeRequest(Ajaxurl,parameters,ReadCommentStatus,"POST",false);
}
function ReadCommentStatus() 
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		GetCommentCount()
	}
	
}
function showContactEmail(divid,e,topheight,Email)
{
	document.getElementById('lblEmail').innerHTML=Email.toUpperCase();;
	document.getElementById('both-grid-overlay').style.display='block';
	var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
	document.getElementById('both-grid-overlay').style.width = _docWidth-20+'px';
	document.getElementById('both-grid-overlay').style.height = _docHeight+'px';
	alert(_docHeight);
	getScrollXY();
	alert(y);
	scroll(x,y);
	if (ns6) {
		document.getElementById(divid).style.left = (_docWidth/4)+50+'px';
		if(_docHeight>1000) {
			document.getElementById(divid).style.top = 630+'px';
		}
		else {
			document.getElementById(divid).style.top = 350+'px';
		}
	} else {
		document.getElementById(divid).style.pixelLeft = (_docWidth/4)+50;
		if(_docHeight>1000) {
			document.getElementById(divid).style.pixelTop = 630;
		} else {
			document.getElementById(divid).style.pixelTop = 350;
		}
	}
	document.getElementById(divid).style.display = "";
	return false ;
}
function SearchWithoutLogin(evt)
{
	document.getElementById('returnURL').value = window.document.location.toString();
	showLoginPopup('divLoginBox',evt,300);
}
function VisibleOptInDiv(Id)
{
	if(document.getElementById(Id).style.display=="none")
	{
		document.getElementById(Id).style.display="block";
	}
	else
	{
		document.getElementById(Id).style.display="none";
	}
}


