function DoForgetPasswordCheckValidation()	{
	if($('EmailAddress').value == "")	{
		alert("Email Address Should not be empty");
		$('EmailAddress').focus();
		return false;	
	}
	if(!isEmail($('EmailAddress').value))	{
		$('EmailAddress').focus();
		return false;	
	}
	return true;
}
function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0') { //MOZILLA/NETSCAPE support
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}

function setFormatPhoneNumber(strPhoneNumber) {
	
	//var key = window.event ? e.keyCode : e.which;
	//if(key != '37')	{
		strFormatPhoneNumber = "";
		strPhoneNumber = trim(strPhoneNumber);
		strPhoneNumber = strPhoneNumber.replace("(","");
		strPhoneNumber = strPhoneNumber.replace(")","");
		strPhoneNumber = strPhoneNumber.replace(" ","");
		strPhoneNumber = strPhoneNumber.replace("-","");
		strLastEntered = strPhoneNumber.substr(strPhoneNumber.length-1);
		if(!IsValidNumber(strLastEntered))
		{
			strPhoneNumber = strPhoneNumber.substr(0,strPhoneNumber.length-1);
		}
		if(strPhoneNumber.length < 3)
			return strPhoneNumber;
		else
		{
			strFormatPhoneNumber = "(" + strPhoneNumber.substr(0,3) + ") ";
			if(strPhoneNumber.length>= 3 && strPhoneNumber.length < 6)
				strFormatPhoneNumber = strFormatPhoneNumber + strPhoneNumber.substr(3,3);
			else
				strFormatPhoneNumber = strFormatPhoneNumber + strPhoneNumber.substr(3,3) + "-" + strPhoneNumber.substr(6,4);
		}
	return strFormatPhoneNumber;
}

var prevValue="";
var changedValue		= "";
var openZipCodeTxtBox  	= "";
var openZipCodeLayerId 	= "";
var openZipcodeLayer	= "";
var objZipCodeContent 	= "";
function EditGlobalZipcode(LayerId) {ShowZipcodeEdit(LayerId);}
function ShowZipcodeEdit(LayerId) {
	//dynamicLoadJS("javascript/Ajax/Prototype.js");load
	if(openZipCodeTxtBox != "" && document.getElementById(openZipCodeTxtBox))
		return;
	   prevValue = document.getElementById(LayerId).innerHTML;
		openZipCodeTxtBox 	= LayerId+"_Edit";
		openZipCodeLayerId	= LayerId;
		//var txtZipcode ="<input id='" + openZipCodeTxtBox + "' name='" + LayerId + "_Edit' type='text' value=\"" + document.getElementById(LayerId).innerHTML + "\" size='3'  maxlength='5' class='GlobalZipCode_Edit' onkeyup=\"GetZipCodeDetails(this,'" + LayerId +"');\">";		
		var txtZipcode ="<input id='" + openZipCodeTxtBox + "' name='" + LayerId + "_Edit' type='text' value=\"" + document.getElementById(LayerId).innerHTML + "\"  class='NewZipCode_Edit' onkeyup=\"GetZipCodeDetails(this,'" + LayerId +"');\">";
     		document.getElementById(LayerId).style.padding = "0px";
		document.getElementById(LayerId).innerHTML = txtZipcode;
		document.getElementById(LayerId + '_Edit').focus();
		document.getElementById(LayerId + '_Edit').select();
}
function GetZipCodeDetails(objZipcode,LayerId) {
	
	strZipCode 	= objZipcode.value;

	if(strZipCode == prevValue){
		return;
	}	
	/*if(!CheckValidZipcode(strZipCode))
	{
		objZipcode.value = strZipCode.substring(0,(strZipCode.length)-1);
		return;
	}*/
	if(!CheckValidCity(strZipCode))
	{
		objZipcode.value = strZipCode.substring(0,(strZipCode.length)-1);
		return;
	}
	if(strZipCode.length >= 5){
		changedValue	  	= strZipCode;
		objZipCodeContent 	= objZipcode.id + "_Content";
		openZipcodeLayer 	= "";
		//ShowZipCodeLayer(objZipcode,80,40,objZipCodeContent,LayerId);
		//ShowZipCodeLayer(objZipcode,70,-116,objZipCodeContent,LayerId);
		ShowModalWindow('City','400','150',strZipCode,LayerId,'','','','');

		/*xmlHttp = AjaxHttpObject();
		if (xmlHttp==null) { 
			alert("Your browser does not support AJAX !!!");
			return;
		}     
		var page = 'ajax/zipcode.php?op=GetZipCodeValues&ZipCode='+strZipCode;
		xmlHttp.onreadystatechange=function(){ GetZipCodeDetailsComplete(strZipCode,objZipCodeContent,LayerId);}
		xmlHttp.open("POST", page, true);
		xmlHttp.send(null);*/
	}
}
function GetZipCodeDetailsComplete(strZipCode,objZipCodeContent,LayerId) 
{ 
if (xmlHttp.readyState == 4) {
   if(xmlHttp.responseText == "")
	{		
		document.getElementById(objZipCodeContent).innerHTML ='<font color="#993333">Invalid Zipcode!</font>';
	}
	else
	{
		strContent = "<span style='float:left;width:100%;font-family:Arial;font-weight:bold;font-size:45px;color:#FA0410;'>Click below</span><span style='float:left;width:100%;font-family:Arial;font-size:36px;font-weight:bold;color:#FC0202;'>to confirm your city:</span><br />";
		strContentSplit = xmlHttp.responseText.split("||");
		strStateCode = strContentSplit[1];
		strCityName = strContentSplit[2];		
		if(LayerId == "SearchLocation"){	
			strContent += "<a href='javascript:UpdateBusinessLocation(\""+ strStateCode +"\",\"" + strCityName + "\",\"" + strZipCode+ "\")' class='LayerStateCity'>"+ strCityName +", " + strStateCode + " - " + strZipCode + "</a>";
		}else{
			strContent += "<a href='javascript:UpdateZipcode(\""+ strStateCode +"\",\"" + strCityName + "\",\"" + strZipCode+ "\")' class='LayerStateCity'>"+ strCityName +", " + strStateCode + " - " + strZipCode + "</a>";
		}

		document.getElementById(objZipCodeContent).innerHTML =strContent;
	}
}
}

function ShowZipCodeLayer(objZipcode,xPos,yPos,objZipCodeContent,LayerId) {
		if(document.getElementById("ZipCodeSuggestionLayer")){
			document.getElementById("ZipCodeSuggestionLayer").style.display="none";
		}
		
		//openZipcodeLayer = "MainZipcodeLayer";
		openZipcodeLayer = "NewMainZipcodeLayer";
		var LoadingImg = "images/loading.gif";		
		ZipCodeLayer = "<DIV id='ZipCodeLayer'><span id='" + objZipCodeContent + "' style='font-size:12px;'><img src=\""+LoadingImg+"\"/>Finding Zipcode...</span></DIV><DIV id='ZipCodeLayerClose'><img src='images/zipclose.png' style='cursor:pointer;' onclick='CloseZipCodeLayer(\"" + LayerId + "\");' /></DIV>";
		/*ZipCodeLayer = "<table border='0' width='160' cellspacing='0' callpadding='0' align='left'><tr><td width='95%' valign='top'></td><td align='right' valign='top' width='5%'></td></tr></table>";*/
		if(LayerId == "SearchLocation")
		{			
			//Element.update("SearchLocationLayer",ZipCodeLayer);
			document.getElementById("SearchLocationLayer").innerHTML =ZipCodeLayer;
			DisplayLayer(objZipcode,"SearchLocationLayer",'',xPos,yPos);
		}
		else
		{			
			//Element.update(openZipcodeLayer,ZipCodeLayer);
			document.getElementById(openZipcodeLayer).innerHTML =ZipCodeLayer;
			DisplayLayer(objZipcode,openZipcodeLayer,'',xPos,yPos);
		}
}
function CancelUpdate(LayerId) {
	if(LayerId == "TabPageZipcode" && TabZipCodeEditMode)
	{
		TabZipCodeEditMode = false;
		Element.update(objTabZipCodeSpan,strPrevTabZipCode);
		Element.hide(openZipcodeLayer);
		return;
	}
	if(openZipcodeLayer != "")
		Element.hide(openZipcodeLayer);
	if(openZipCodeLayerId != "")
		Element.show(openZipCodeLayerId);
	if(openZipCodeLayerId != "")
		Element.update(openZipCodeLayerId,prevValue);
	if(openZipCodeTxtBox != "")
		Element.hide(openZipCodeTxtBox);
	changedValue = "";
}

function DisplayLayer(objLayer, objLayerId, opt_position,XPOS,YPOS){ 
	if (document.getElementById){
		var objShow=document.getElementById(objLayerId)
		objShow.style.display = "block";
		/* var xpos=getposOffset(objLayer, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(objShow.offsetWidth-objLayer.offsetWidth) : 0) 
		var ypos=getposOffset(objLayer, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? objLayer.offsetHeight : 0)
		xpos=xpos-XPOS;ypos=ypos+YPOS;objShow.style.left=xpos+"px";objShow.style.top=ypos+"px" */
		return false;
	}else
		return true;
}
/*
function GetZipCodeDetailsComplete(t,strZipCode,objZipCodeContent,LayerId) {
	if(t.responseText == "")
	{
		Element.update(objZipCodeContent,'<font color="#993333">Invalid Zipcode!</font>');
	}
	else
	{
		strContentSplit = t.responseText.split("||");
		strStateCode = strContentSplit[1];
		strCityName = strContentSplit[2];		
		if(LayerId == "SearchLocation"){	
			strContent = "<a href='javascript:UpdateBusinessLocation(\""+ strStateCode +"\",\"" + strCityName + "\",\"" + strZipCode+ "\")' class='LayerStateCity'>"+ strCityName +", " + strStateCode + " - " + strZipCode + "</a>";
		}else{
			strContent = "<a href='javascript:UpdateZipcode(\""+ strStateCode +"\",\"" + strCityName + "\",\"" + strZipCode+ "\")' class='LayerStateCity'>"+ strCityName +", " + strStateCode + " - " + strZipCode + "</a>";
		}

		Element.update(objZipCodeContent,strContent);
	}
}
*/
function UpdateZipcode(strStateCode,strCityName,strZipCode) {
	//strContent = strCityName  +", " + strStateCode;
	/* strContent	= '<div id="HeaderStateCity" style="cursor:pointer;"><DIV class="Left">&nbsp;</DIV><DIV class="StateCity"  >';
	strContent	+= strCityName  +", " + strStateCode;
	strContent	+= '<div style="padding-right:15px;font-size: 9px;cursor:pointer; padding-top:2px; text-transform:none;color:#FFFFFF; text-align:right">Click and type in your Zip Code&nbsp;<img src="images/arrow4.gif" width="4" height="8" align="absmiddle" /></div></DIV><DIV class="Right"></DIV></div>';
	strContent	+= '<div id="HeaderZipCodeArea"><div id="HeaderZipCode">';
	strContent	+= '<SPAN id="GlobalZipCode" class="GlobalZipCode" onmouseover="this.className=\'GlobalZipCodeHover\'" onmouseout="this.className=\'GlobalZipCode\'" onclick="EditGlobalZipcode(\'GlobalZipCode\')">'+strZipCode+'</SPAN><span id="MainZipcodeLayer" class="ZipCodeLayerClass"></span></div></div>'; */

	/* Previus style content -
	strContent	= '<div id="HeaderZipCodeArea"><div id="HeaderZipCode">';
	strContent	+= '<SPAN id="GlobalZipCode" class="GlobalZipCode" onmouseover="this.className=\'GlobalZipCodeHover\'" onmouseout="this.className=\'GlobalZipCode\'" onclick="EditGlobalZipcode(\'GlobalZipCode\')">'+strZipCode+'</SPAN><span id="MainZipcodeLayer" class="ZipCodeLayerClass"></span></div></div>';
	strContent	+= '<div class="NewStateCity">';
	strContent	+= '<span class="NewWelcome"> Welcome Guest</span><br /><span class="NewCity">Your current location is:</span><br />';
	strContent	+= '<span class="NewState">'+strCityName+', '+strStateCode+'. </span><span class="NewClk" onclick="EditGlobalZipcode(\'GlobalZipCode\')">Click to edit</span></div>';
	document.getElementById("HeaderStateCityDisplay").innerHTML =strContent; */

	strContent	= '<div class="ZipSearchBox1" align="left">';
	strContent	+= '<SPAN id="NewZipCode" class="NewZipCode" onmouseover="this.className=\'NewZipCodeHover\'" onmouseout="this.className=\'NewZipCode\'" onclick="EditGlobalZipcode(\'NewZipCode\')">'+strStateCode,strCityName,strZipCode+'</SPAN>';
	strContent	+= '<span id="NewMainZipcodeLayer" class="NewZipCodeLayerClass"></span></div>';

	document.getElementById("NewZipCode").innerHTML =strContent;
	window.location.href = globalRequestPageForZipCode+'zipcode='+strZipCode;
}
function ZipCodeEditFailed(t) {
	
}
function UpdateBusinessLocation(strStateCode,strCityName,strZipCode){
	strContent = strCityName  +", " + strStateCode;
	$("location").value=strContent;
	$("SearchLocationLayer").style.display="none";
	$("ZipCodeSuggestionLayer").style.display="none";
	$("hdZipCode").value = strZipCode; 	
}
function CheckValidZipcode(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   if(sText==""){
	   return false;
	}
   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1){
         IsNumber = false;
      }
   }
   return IsNumber;
}

if (window.captureEvents){
	window.captureEvents(Event.CLICK);window.onclick = onMainClickEvent;
	}else{
		document.onclick=onMainClickEvent;
	}
var dontHide = false;
function onMainClickEvent(e) {
	if(document.all)e = event;
	if (e.target) source = e.target;
		else if (e.srcElement) source = e.srcElement;
	if(openZipCodeTxtBox == "" && !document.getElementById(openZipCodeTxtBox))
		return;
	if(source.id == "ZipCodeLayer" || source.id == "MainZipcodeLayer")
		return; 
	//Type = prevValue = changedValue = openZipCodeTxtBox = openZipCodeLayerId = "";
	if(source.id == openZipCodeTxtBox || source.id == openZipCodeLayerId|| source.id == objZipCodeContent)
		return;
	if(document.getElementById(openZipCodeLayerId)){		
		 document.getElementById(openZipCodeLayerId).removeAttribute("style");
		 document.getElementById(openZipCodeLayerId).style.display="block";
	}
	if(document.getElementById(openZipCodeTxtBox)) document.getElementById(openZipCodeTxtBox).style.display ="none";
	if(document.getElementById(openZipCodeLayerId)) {
		document.getElementById(openZipCodeLayerId).innerHTML = prevValue;
		document.getElementById(openZipCodeLayerId).className = 'GlobalZipCode';
	}
	if(document.getElementById(openZipcodeLayer)) document.getElementById(openZipcodeLayer).style.display ="none";
	TabZipCodeEditMode = false;
	prevValue = changedValue = openZipCodeTxtBox = openZipCodeLayerId = "";
}
/*function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}*/
function overlay(curobj, subobjstr, opt_position){
	document.getElementById('ClearMsg').innerHTML = "";	
	if (document.getElementById){
		var subobj=document.getElementById(subobjstr)
		subobj.style.display=(subobj.style.display!="block")? "block" : "none"
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
		xpos=xpos-XPOS;
		ypos=ypos+YPOS;
		subobj.style.left=xpos+"px"
		subobj.style.top=ypos+"px"
		return false
	}
	else
		return true
}
function closealloverlay(overlay1,overlay2){
	document.getElementById(overlay1).style.display="none"
	document.getElementById(overlay2).style.display="none"
}

function LoginValidation() {
	if(document.MemberLogin.UserName.value == "") {
		alert("User Name Should Not Be Empty")
		document.MemberLogin.UserName.focus();
		return false;
	}
	if(document.MemberLogin.Password.value == "") {
		alert("Password Should Not Be Empty")
		document.MemberLogin.Password.focus();
		return false;
	}
	
	document.MemberLogin.fAction.value	= 'login';
	//document.MemberLogin.submit();
}
function IsValidUserName(username)	{
		var reg = new RegExp( /^[A-Za-z][-A-Za-z0-9_]{0,49}$/i);
		if(reg.test(username))
			return true;
		else
			return false;
}
function isValidPassword(password)	{
	var reg = new RegExp(/^[-A-Za-z0-9_]*$/i);
	if(reg.test(password))
		return true;
	else
		return false;
}
function ValidateRegistration()		{
		var B_UserName  				= $('Business_UserName');
		var B_UserPassword 				= $('Business_UserPassword');
		var B_UserConfirmPassword		= $('Business_UserConfirmPassword');
		var Business_UserEmailAddress 	= $('Business_UserEmailAddress');
		var Business_UserZip 			= $('Business_UserZip');
		var Business_VerificationCode	= $('Business_VerificationCode');
		if(trim(B_UserName.value) == '')	{
			alert('Enter Your Login User Name!');
			B_UserName.focus();
			return false;
		}
		if(!IsValidUserName(trim(B_UserName.value)))
		{
			alert('Invalid UserName');
			B_UserName.focus();
			return false;
		}
		if(trim(B_UserName.value).length < 5)	{
			alert('Username Should be atleat 5 charecters');
			B_UserName.focus();
			return false;
		}
		else if(trim(B_UserPassword.value) == '')	{
			alert('Enter Your Login Password!');
			B_UserPassword.focus();
			return false;
		}
		if(!isValidPassword(trim(B_UserPassword.value)))
		{
			alert('Invalid Characters Found in the Password');
			B_UserPassword.select();
			return false;
		}
		if(B_UserPassword.value.length < 5)	{
			alert('Password Should be atleat 5 charecters');
			B_UserPassword.focus();
			return false;
		}
		else if(trim(B_UserConfirmPassword.value) == '')	{
			alert('Enter Your Confirm Password!');
			B_UserConfirmPassword.focus();
			return false;
		}
		else if(B_UserConfirmPassword.value != B_UserPassword.value)	{
			alert('Password Mismatch. Please try again');
			B_UserConfirmPassword.select();
			return false;
		}
		if(trim(Business_UserEmailAddress.value) == '')	{
			alert('Email Address should not be empty!');
			Business_UserEmailAddress.select();
			return false;
		}
		if(!CheckExacltyAnEmail(Business_UserEmailAddress.value,1))	{
			Business_UserEmailAddress.select();
			return false;
		}else if(Business_UserZip.value == "")	{
			alert('Zip code should not be empty!');
			Business_UserZip.select();
			return false;
		}
		if(trim(Business_UserZip.value)!=''){
			var e=trim(Business_UserZip.value);
			 if(isAlpha(e)){
				alert('Invalid Zipcode');
				Business_UserZip.select();
				return false;
				}
		}
		if(Business_VerificationCode.value == '')
  		{
			alert("Please enter your Verification Code");
			Business_VerificationCode.select();
			return (false);
  		}
		document.MemberRegister.fAction.value	= 'register';
		//document.MemberRegister.submit();
	}

	function CheckExacltyAnEmail(addr,db)	{
		var invalidChars = '\/\'\\ ";:?!()#$^+&*[]\{\}^|,';
		for (i=0; i<invalidChars.length; i++) {
		   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
			  if (db) alert('Email address contains invalid characters');
			  return false;
		   }
		}
		for (i=0; i<addr.length; i++) {
		   if (addr.charCodeAt(i)>127) {
			  if (db) alert("Email address contains non ascii characters.");
			  return false;
		   }
		}
		var atPos = addr.indexOf('@',0);
		if (atPos == -1) {
		   if (db) alert('Email address must contain an @');
		   return false;
		}
		if (atPos == 0) {
		   if (db) alert('Email address must not start with @');
		   return false;
		}
		if (addr.indexOf('@', atPos + 1) > - 1) {
		   if (db) alert('Email address must contain only one @');
		   return false;
		}
		if (addr.indexOf('.', atPos) == -1) {
		   if (db) alert('Email address must contain a period in the domain name');
		   return false;
		}
		if (addr.indexOf('@.',0) != -1) {
		   if (db) alert('Period must not immediately follow @ in email address');
		   return false;
		}
		if (addr.indexOf('.@',0) != -1){
		   if (db) alert('Period must not immediately precede @ in email address');
		   return false;
		}
		if (addr.indexOf('..',0) != -1) {
		   if (db) alert('Two periods must not be adjacent in email address');
		   return false;
		}
		var suffix = addr.substring(addr.lastIndexOf('.')+1);
		if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
		   if (db) alert('Invalid primary domain in email address');
		   return false;
		}
		return true;
	}	

function CheckAvailability()	{
	var strUserName	= $('Business_UserName').value;
	if(strUserName == "")
	{
		alert("Please enter the username to check");	
		return false;
	}	else	{
		var success = function(t){CheckAvailabilityComplete(t);}
		var failure = function(t){editFailed(t);}
		var url = "ajax/register.php";
		var pars = 'op=CheckValidData&UserName='+strUserName;		
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
}

function CheckAvailabilityComplete(t){
	var strValue = t.responseText;
	if(t.responseText != "")	{
		document.getElementById("username").innerHTML= "<img src = 'images/exclamation.png' width='16' align='absmiddle' height='16'>&nbsp;<font color='#ff0000'>"+t.responseText+"</span>";
	} else	{
		document.getElementById(spanId).innerHTML= "";
	}
}

function LoadPopularVideo(VideoToLoad,Aws,AutoPlay,Imagename)	{
		/* if(Aws == 'yes')
			var ConfigPath	= "config.xml";
		else
			var ConfigPath	= "config1.xml"; */
		/* if(AutoPlay == 'undefined')
			AutoPlay = 'true'; */
		/* if(AutoPlay == 'true')
			Imagename = ''; */
		var EmbedSrc  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="/YouTube_video/youtube" width="400" height="350">';
		EmbedSrc +='<param name="allowFullScreen" value="true" />';
		EmbedSrc +='<param name="wmode" value="transparent" />';
		EmbedSrc +='<param name="movie" value="player.swf?video=' + VideoToLoad + '&autostart='+ AutoPlay +'&videoimage='+Imagename+'&width=400&height=350" />';
		EmbedSrc +='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
		EmbedSrc +='<embed src="player.swf?video=' + VideoToLoad + '&autostart='+ AutoPlay +'&videoimage='+Imagename+'&width=400&height=350" swliveconnect="true" NAME="rssmovie" quality="high" bgcolor="#ffffff" width="400" height="350" name="/YouTube_video/youtube" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" wmode="transparent"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		EmbedSrc +='</object>';
		if(document.getElementById("LoadPopularVideo"))
		document.getElementById("LoadPopularVideo").innerHTML = EmbedSrc;	
}
function LoadPopularVideo_OldBkUp(VideoToLoad,Aws)	{
		if(Aws == 'yes')
			var ConfigPath	= "config.xml";
		else
			var ConfigPath	= "config1.xml";
		var EmbedSrc  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="/YouTube_video/youtube" width="400" height="350">';
		EmbedSrc +='<param name="allowFullScreen" value="true" />';
		EmbedSrc +='<param name="wmode" value="transparent" />';
		EmbedSrc +='<param name="movie" value="rl.swf?xml='+ConfigPath+'&video=' + VideoToLoad + ' " />';
		EmbedSrc +='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
		EmbedSrc +='<embed src="rl.swf?xml='+ConfigPath+'&video=' + VideoToLoad + '" swliveconnect="true" NAME="rssmovie" quality="high" bgcolor="#ffffff" width="400" height="350" name="/YouTube_video/youtube" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" wmode="transparent"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		EmbedSrc +='</object>';
		if($("LoadPopularVideo"))
		$("LoadPopularVideo").innerHTML = EmbedSrc;	
}

function LoadPopularVideoClick(VideoToLoad,Aws)	{
	
		var flashMovie=getFlashMovieObject("rssmovie");
	
		flashMovie.src = "rl.swf?xml=config1.xml&video=44/227/Videos/NormalFlv/174_44.flv";
		flashMovie.setAttribute('src','rl.swf?xml=config1.xml&video=44/227/Videos/NormalFlv/174_44.flv');
		//flashMovie.StopPlay();
		//flashMovie.Play();
			
		if(Aws == 'yes')
			var ConfigPath	= "config.xml";
		else
			var ConfigPath	= "config1.xml";
		/* 	
		var EmbedSrc  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="/YouTube_video/youtube" width="400" height="350">';
		EmbedSrc +='<param name="allowFullScreen" value="true" />';
		EmbedSrc +='<param name="wmode" value="transparent" />';
		EmbedSrc +='<param name="movie" value="rl.swf?xml='+ConfigPath+'&video=' + VideoToLoad + ' " />';
		EmbedSrc +='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
		EmbedSrc +='<embed src="rl.swf?xml='+ConfigPath+'&video=' + VideoToLoad + '" quality="high" bgcolor="#ffffff" width="400" height="350" name="/YouTube_video/youtube" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" wmode="transparent"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		EmbedSrc +='</object>';
		if($("LoadPopularVideo"))
		$("LoadPopularVideo").innerHTML = EmbedSrc;	 */
}

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 searchForCompany(objForm){
	
	if(objForm.txtSearch.value == "" || objForm.txtSearch.value=="Enter Business Name or Key Words"){
		 if(document.getElementById("searchoption").value==""){
			location.href="index.php?op=directory";	
			return false;
		 }else if(document.getElementById("searchoption").value=="Advice"){
			location.href="index.php?op=search&searchoption=Advice&doAct=SearchAll";	
			return false;
		 }else if(document.getElementById("searchoption").value=="Coupons"){
			location.href="index.php?op=search&searchoption=Coupons&doAct=SearchAll";	
			return false;
		 }else if(document.getElementById("searchoption").value=="Deals"){
			location.href="index.php?op=search&searchoption=Deals&doAct=SearchAll";	
			return false;
		 }
    }
	objForm.submit();
}
//----------- for latest design fns -----------
function BrowseCategoryUnique(CatIdent,CatName){
	ShowModalWindow('BrowseCategory','320','500','','','',CatIdent,CatName,'');
}
function BrowseCategory(){
	ShowModalWindow('BrowseCategory','320','500','','','','','','');
}
function SearchKeyword(){
	/* if(trim(document.frmSearch.txtSearch.value) == "Find this KEYWORD")
		document.frmSearch.txtSearch.value = ""; */
	
	if(trim(document.frmSearch.txtSearch.value) == "Enter keyword here" || trim(document.frmSearch.txtSearch.value) == ''){
		alert("Please enter a search term");
		document.frmSearch.txtSearch.focus();
		document.frmSearch.txtSearch.value.replace("/", "%2F");
		return false;
	}
	
	document.frmSearch.submit();
}
function SearchCompany(){
	/* if(trim(document.frmSearchBiz.txtSearch.value) == "Find this COMPANY")
		document.frmSearchBiz.txtSearch.value = ""; */
	if(trim(document.frmSearchBiz.txtSearch.value) == "Find this COMPANY" || trim(document.frmSearchBiz.txtSearch.value) == ""){
		alert("Please enter a search term");
		document.frmSearchBiz.txtSearch.focus();
		return false;
	}
	document.frmSearchBiz.submit();
}
//----------- for latest design fns -----------
function searchForBusinessName(){
	if(trim(document.frmBizSearch.txtSearch.value) != "Enter Business Name" || trim(document.frmBizSearch.txtSearch.value) != "Enter business name to search again."){
		// location.href="index.php?op=search"
		document.frmBizSearch.txtSearch.value=document.frmBizSearch.txtSearch.value.replace("&","amp");
		//document.frmBizSearch.txtSearch.value=document.frmBizSearch.txtSearch.value.replace("'","or");
		document.frmBizSearch.submit();
		return false;
	}
	else	{
		alert("Please Enter a Business Name");
	  	return false;
   }
}
/* function changeTap(op){	
	  if(op == "deal"){
	    document.getElementById("deal1").src = "images/tab_over_left.gif";
		document.getElementById("deal3").src = "images/tab_over_right.gif";
		document.getElementById("deal2").className="tab_over"; 
		document.getElementById("consumer1").src = "images/tab_normal_left.gif";
		document.getElementById("consumer3").src = "images/tab_normal_right.gif";
		document.getElementById("consumer2").className="tab_normal";
		document.getElementById("gallery1").src = "images/tab_normal_left.gif";
		document.getElementById("gallery3").src = "images/tab_normal_right.gif";
		document.getElementById("gallery2").className="tab_normal";
	    document.getElementById("deal").style.display="block";
		document.getElementById("consumer").style.display="none";
		document.getElementById("gallery").style.display="none";
		
	  } 
	  if(op == "consumer"){
		document.getElementById("consumer1").src = "images/tab_over_left.gif";
		document.getElementById("consumer2").className="tab_over";
		document.getElementById("consumer3").src = "images/tab_over_right.gif";
		document.getElementById("deal1").src = "images/tab_normal_left.gif";
		document.getElementById("deal3").src = "images/tab_normal_right.gif";
		document.getElementById("deal2").className="tab_normal"; 
		document.getElementById("gallery1").src = "images/tab_normal_left.gif";
		document.getElementById("gallery3").src = "images/tab_normal_right.gif";
		document.getElementById("gallery2").className="tab_normal";
	    document.getElementById("consumer").style.display="block";
		document.getElementById("deal").style.display="none";
	    document.getElementById("gallery").style.display="none";
	  } 
	   if(op == "gallery"){
		document.getElementById("consumer1").src = "images/tab_normal_left.gif";
		document.getElementById("consumer2").className="tab_normal";
		document.getElementById("consumer3").src = "images/tab_normal_right.gif";
		document.getElementById("deal1").src = "images/tab_normal_left.gif";
		document.getElementById("deal3").src = "images/tab_normal_right.gif";
		document.getElementById("deal2").className="tab_normal"; 
		document.getElementById("gallery1").src = "images/tab_over_left.gif";
		document.getElementById("gallery3").src = "images/tab_over_right.gif";
		document.getElementById("gallery2").className="tab_over";
	    document.getElementById("gallery").style.display="block";
		document.getElementById("deal").style.display="none";
	    document.getElementById("consumer").style.display="none";
	  } 
} */
function changeTap(op){	
	  if(op == "deal"){
		  
		document.getElementById("deal1").src = "images/s-lt.gif";
		document.getElementById("deal3").src = "images/s-rt.gif";
		document.getElementById("deal2").className="hometab_over"; 
		document.getElementById("consumer1").src = "images/u-lt.gif";
		document.getElementById("consumer3").src = "images/u-rt.gif";
		document.getElementById("consumer2").className="hometab_normal";
		document.getElementById("gallery1").src = "images/u-lt.gif";
		document.getElementById("gallery3").src = "images/u-rt.gif";
		document.getElementById("gallery2").className="hometab_normal";
		document.getElementById("consumer").style.display="none";
	    document.getElementById("deal").style.display="block";
		document.getElementById("gallery").style.display="none";
		
	  } 
	  if(op == "consumer"){
		
		document.getElementById("consumer1").src = "images/s-lt.gif";
		document.getElementById("consumer2").className="hometab_over";
		document.getElementById("consumer3").src = "images/s-rt.gif";
		document.getElementById("deal1").src = "images/u-lt.gif";
		document.getElementById("deal3").src = "images/u-rt.gif";
		document.getElementById("deal2").className="hometab_normal"; 
		document.getElementById("gallery1").src = "images/u-lt.gif";
		document.getElementById("gallery3").src = "images/u-rt.gif";
		document.getElementById("gallery2").className="hometab_normal";
	    document.getElementById("consumer").style.display="block";
		document.getElementById("deal").style.display="none";
	    document.getElementById("gallery").style.display="none";
	  } 
	   if(op == "gallery"){
		
		document.getElementById("consumer1").src = "images/u-lt.gif";
		document.getElementById("consumer2").className="hometab_normal";
		document.getElementById("consumer3").src = "images/u-rt.gif";
		document.getElementById("deal1").src = "images/u-lt.gif";
		document.getElementById("deal3").src = "images/u-rt.gif";
		document.getElementById("deal2").className="hometab_normal"; 
		document.getElementById("gallery1").src = "images/s-lt.gif";
		document.getElementById("gallery3").src = "images/s-rt.gif";
		document.getElementById("gallery2").className="hometab_over";
	    document.getElementById("gallery").style.display="block";
		document.getElementById("deal").style.display="none";
	    document.getElementById("consumer").style.display="none";
	  } 
}


	function dofrmfrmAnonymousTipsValidation()	{
		var AnonymousUserEmail 			= $('AnonymousUserEmail');
		var AnonymousUserComments		= $('AnonymousUserComments');
		var VerificationCode			= $('VerificationCode');
		if(trim(AnonymousUserEmail.value) != "")
		{
			if(!isEmail(trim(AnonymousUserEmail.value)))
			{
				AnonymousUserEmail.select();
				return false;
			}
		}
		if(trim(AnonymousUserComments.value) == '')	{
			alert('Enter Your Valuable  Comments.');
			AnonymousUserComments.value = '';
			AnonymousUserComments.focus();
			return false;
		}
		 if (VerificationCode.value == '')
  		{
		    alert("Please enter the Verification Code");
			VerificationCode.value = '';
			VerificationCode.focus();
			return false;
	    }
		$('fAction').value = 'anonymoustips';
		return true;
	}
	
	function showStatus(sMsg) {
		var win = window;
		win.status = sMsg ;
		return true ;
	}
	
function FrontPage_Form1_Validator(theForm)
{

  if (trim(theForm.CallerFirstName.value) == "")
  {
    alert("Please enter your \"FirstName\".");
	theForm.CallerFirstName.value = '';
    theForm.CallerFirstName.focus();
    return (false);
  }

  if (trim(theForm.CallerFirstName.value).length > 50)
  {
    alert("Please enter at most 50 characters in the \"FirstName\" field.");
    theForm.CallerFirstName.focus();
    return (false);
  }

  if (trim(theForm.CallerLastName.value) == "")
  {
    alert("Please enter your \"LastName\".");
	theForm.CallerLastName.value = '';
    theForm.CallerLastName.focus();
    return (false);
  }

  if (trim(theForm.CallerLastName.value).length > 50)
  {
    alert("Please enter at most 50 characters in the \"LastName\" field.");
    theForm.CallerLastName.focus();
    return (false);
  }

  if (trim(theForm.CallerCity.value) == "")
  {
    alert("Please enter your \"City\".");
	theForm.CallerCity.value = '';
    theForm.CallerCity.focus();
    return (false);
  }

  if (trim(theForm.CallerCity.value).length > 50)
  {
    alert("Please enter at most 50 characters in the \"City\" field.");
    theForm.CallerCity.focus();
    return (false);
  }

  if (trim(theForm.CallerState.value) == "")
  {
    alert("Please Select your \"State\".");
    theForm.CallerState.focus();
    return (false);
  }

  if (trim(theForm.CallerZip.value) == "")
  {
    alert("Please enter your \"ZipCode\".");
    theForm.CallerZip.focus();
    return (false);
  }
  if (!IsValidZipCode(trim(theForm.CallerZip.value), "ZipCode"))
  {
    theForm.CallerZip.focus();
    return (false);
  }
  if (trim(theForm.CallerPhone.value) == "")
  {
    alert("Please enter your \"Phone Number\".");
	theForm.CallerPhone.value = '';
    theForm.CallerPhone.focus();
    return (false);
  }
  if(trim(theForm.CallerEMail.value) == "")
  {
    alert("Please enter your \"EMail\".");
	theForm.CallerEMail.value = '';
    theForm.CallerEMail.focus();
    return (false);
  }
  if (!isEmail(theForm.CallerEMail.value))
  {
    theForm.CallerEMail.focus();
    return (false);
  }
  if (trim(theForm.CallerEMailSubject.value) == "")
  {
    alert("Please enter your \"EMail Subject\".");
	theForm.CallerEMailSubject.value = '';
    theForm.CallerEMailSubject.focus();
    return (false);
  }
  if (trim(theForm.CallerEMailSubject.value).length > 100)
  {
    alert("Please enter at most 100 characters in the \"CallerEMailSubject\" field.");
    theForm.CallerEMailSubject.focus();
    return (false);
  }
  if (trim(theForm.BusinessName.value) == "")
  {
    alert("Please enter your \"BusinessName\".");
	theForm.BusinessName.value = '';
    theForm.BusinessName.focus();
    return (false);
  }
  if (trim(theForm.BusinessName.value).length > 50)
  {
    alert("Please enter at most 50 characters in the \"BusinessName\" field.");
    theForm.BusinessName.focus();
    return (false);
  }
  if (theForm.ProblemType.selectedIndex < 0)
  {
    alert("Please select one of the \"ProblemType\" options.");
    theForm.ProblemType.focus();
    return (false);
  }
  if (theForm.ProblemType.selectedIndex == 0)
  {
    alert("Please select one of the \"Problem Type\" options.");
    theForm.ProblemType.focus();
    return (false);
  }
  if (theForm.ProblemType2.selectedIndex < 0)
  {
    alert("Please select one of the \"ProblemType2\" options.");

    theForm.ProblemType2.focus();
    return (false);
  }
  if (theForm.ProblemType2.selectedIndex == 0)
  {
    alert("Please select one of the \"Problem Detail\" options.");
    theForm.ProblemType2.focus();
    return (false);
  }
  if (trim(theForm.Problem.value) == "")
  {
    alert("Please enter your \"Problem\".");
	theForm.Problem.value = '';
    theForm.Problem.focus();
    return (false);
  }
  if (trim(theForm.Problem.value).length > 10000)
  {
    alert("Please enter at most 10000 characters in the \"Problem\" field.");
	theForm.Problem.value.length = 10000; 
    theForm.Problem.focus();
    return (false);
  }
 if (theForm.ReportDisputeCaptcha.value == "")
  {
    alert("Please enter your \"Verification Code\".");
	theForm.ReportDisputeCaptcha.value = '';
	theForm.ReportDisputeCaptcha.focus();
	return (false);
  }

  theForm.fAction.value = 'report';
  return (true);
}
function mouseOver(op)
{
	if(op == 'Deals')	{
		if($('Deals').className == 'SearchOptionNotSelected')
			$('Deals').style.backgroundColor='#FCE0A0';
		else if($('Deals').className == 'SearchOptionSelected')	{
			$('Deals').style.backgroundColor='#65C2F8';
			$('Advice').style.backgroundColor = 'white';
			$('Coupons').style.backgroundColor = 'white'
		}
	}
	if(op == 'Advice')	{
		if($('Advice').className == 'SearchOptionNotSelected')
			$('Advice').style.backgroundColor='#FCE0A0';
		else if($('Advice').className == 'SearchOptionSelected')	{
			$('Advice').style.backgroundColor='#65C2F8';
			$('Coupons').style.backgroundColor = 'white';
			$('Deals').style.backgroundColor = 'white';
		}
	}
	if(op == 'Coupons')	{
		if($('Coupons').className == 'SearchOptionNotSelected')
			$('Coupons').style.backgroundColor='#FCE0A0';
		else if($('Coupons').className == 'SearchOptionSelected')	{
			$('Coupons').style.backgroundColor='#65C2F8';
			$('Advice').style.backgroundColor = 'white';
			$('Deals').style.backgroundColor = 'white';
		}
	}
}
function mouseOut(op)
{
	if(op == 'Advice')	{
		if($('Advice').className == 'SearchOptionNotSelected')
			$('Advice').style.backgroundColor='white';
		else if($('Advice').className == 'SearchOptionSelected')	{
			$('Advice').style.backgroundColor='#65C2F8';
			$('Coupons').style.backgroundColor = 'white';
			$('Deals').style.backgroundColor = 'white';
		}
	}
	if(op == 'Deals')	{
		if($('Deals').className == 'SearchOptionNotSelected')
			$('Deals').style.backgroundColor='white';
		else if($('Deals').className == 'SearchOptionSelected')	{
			$('Deals').style.backgroundColor='#65C2F8';
			$('Advice').style.backgroundColor = 'white';
			$('Coupons').style.backgroundColor = 'white'
		}
	}
	if(op == 'Coupons')	{
		if($('Coupons').className == 'SearchOptionNotSelected')
			$('Coupons').style.backgroundColor='white';
		else if($('Coupons').className == 'SearchOptionSelected')	{
			$('Coupons').style.backgroundColor='#65C2F8';
			$('Advice').style.backgroundColor = 'white';
			$('Deals').style.backgroundColor = 'white';
		}
	}
}

function ChangeSearchOption(op){
	/*document.getElementById('Deals').className = "tabnormal";
	document.getElementById('Advice').className = "tabnormal";	
	document.getElementById('Coupons').className = "tabnormal";	
	document.getElementById('Company').className = "tabnormal";
	if(op == 'Company')	{	
		document.getElementById('Company').className = "tabnew";	
	}
	if(op == 'Deals')	{	
		document.getElementById('Deals').className = "tabnew";	
	}
	if(op == 'Advice')	{
		document.getElementById('Advice').className = "tabnew";	
	}
	if(op == 'Coupons')	{
		document.getElementById('Coupons').className = "tabnew";	
	}
	if(op != 'Company')
		document.getElementById("searchoption").value = op;
	else
		document.getElementById("searchoption").value = "";*/
}

function SearchOption(op){
	$('Search').className='utabc';
	$('Searchr').className = "utabr";
	$('Search1').className = "utab1";
	$('Deals').className='utabc';
	$('Dealsr').className = "utabr";
	$('Deals1').className = "utab1";
	$('Advice').className = 'utabc';
	$('Advicer').className = "utabr";
	$('Advice1').className = "utab1";
	$('Coupons').className = 'utabc'
	$('Couponsr').className = "utabr";
	$('Coupons1').className = "utabl";
	if(op == 'Search')	{
		$('Search').className = "tabc";
		$('Searchr').className = "tabr";
		$('Search1').className = "tab1";
	}
	if(op == 'Deals')	{
		$('Deals').className = "tabc";
		$('Dealsr').className = "tabr";
		$('Deals1').className = "tab1";
	}
	if(op == 'Advice')	{
		$('Advice').className = "tabc";
		$('Advicer').className = "tabr";
		$('Advice1').className = "tab1";
	}
	if(op == 'Coupons')	{
		$('Coupons').className = "tabc";
		$('Couponsr').className = "tabr";
		$('Coupons1').className = "tab1";
	}
	if(op != 'Search')
		$("searchoption").value = op;
	else
		$("searchoption").value = "";
}

function doContactUsValidation()	{
		var ContactUsName  				= $('ContactUsName');
		var ContactUsEmail 			    = $('ContactUsEmail');
		var ContactUsComments	        = $('ContactUsComments');
		if(trim(ContactUsName.value) == '')	{
			alert('Enter Your Name!');
			ContactUsName.value = '';
			ContactUsName.focus();
			return false;
		}
		if(!isAlpha(trim(ContactUsName.value)))
		{
			alert('Invalid Characters Found in Your Name.');
			ContactUsName.value = '';
			ContactUsName.focus();
			return false;
		}
		else if(trim(ContactUsEmail.value) == '')	{
			alert('Enter Your Email Address.');
			ContactUsEmail.value = '';
			ContactUsEmail.focus();
			return false;
		}
		if(!isEmail(trim(ContactUsEmail.value)))
		{
			ContactUsEmail.select();
			return false;
		}
		if(trim(ContactUsComments.value) == '')	{
			alert('Enter Your Valuable  Comments.');
			ContactUsComments.value = '';
			ContactUsComments.focus();
			return false;
		}
		$('fAction').value = 'ContactUs';
		return true;
	}

function ShowZipSuggetion(LayerId){
		$(LayerId).style.display="block";	
		$(LayerId).innerHTML = '<img src="images/loading.gif"/>';
		var success = function(t){ShowZipSuggetionComplete(t,LayerId);}
		var failure = function(t){ZipCodeEditFailed(t);}
		var url = 'ajax/business.php';
		var pars = 'op=GetCookieZipCodeSuggestion';
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});	
}
function ShowZipSuggetionComplete(t,LayerId){	
		$(LayerId).innerHTML = t.responseText;		
}

function CloseZipCodeLayer(LayerId){
	if(LayerId == "SearchLocation"){
			LayerId = "SearchLocationLayer";
	}
	document.getElementById(LayerId).style.display = "none";	
}

function ClearZipCookies(){ 
		var success = function(t){ClearZipCookiesComplete(t);}
		var failure = function(t){ZipCodeEditFailed(t);}
		var url = 'ajax/business.php';
		var pars = 'op=ClearZipCodeCookies';
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}

function ClearZipCookiesComplete(t){		
	if(t.responseText == "success"){	
		$("ZipCodeSuggestionLayer").style.display = "none";
		location.href="index.php?op=directory&doAct=ClearZipCode";
	}	
}

function SetLocation(strZipCode){
		var success = function(t){SetLocationComplete(t,strZipCode);}
		var failure = function(t){ZipCodeEditFailed(t);}
		var url  = 'ajax/zipcode.php';
		var pars = 'op=GetZipCodeValues&ZipCode='+strZipCode;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}

function SetLocationComplete(t,strZipCode){
		strContentSplit = t.responseText.split("||");		
		strStateCode = strContentSplit[1];
		strCityName  = strContentSplit[2];				
		strContent   = strCityName +", " + strStateCode;
		Element.update("GlobalZipCode",strZipCode);
		Element.update("HeaderStateCityDisplay",strContent);
}

	// Function to disable CTRL & SHIFT
	function noCTRL(e)
	{
		var code = (document.all) ? event.keyCode:e.which;
		var msg = "Sorry, this functionality is disabled.";
		if (parseInt(code)==17 || parseInt(code) == 16) //CTRL & SHIFT
		{
			alert(msg);
			//window.event.returnValue = false;
			//window.document.event.returnValue = false;
			return false;
		}
	} 	
 function LoginExistingValidation() {
	if(trim(document.MemberLogin.UserName.value) == "") {
		alert("User Name Should Not Be Empty")
		document.MemberLogin.UserName.focus();
		return false;
	}
	if(trim(document.MemberLogin.Password.value) == "") {
		alert("Password Should Not Be Empty")
		document.MemberLogin.Password.focus();
		return false;
	}
	if(trim(document.MemberLogin.Verification.value) == "") {
		alert("Verification code Should Not Be Empty")
		document.MemberLogin.Verification.focus();
		return false;
	}
	if(document.MemberLogin.Verification.value != document.MemberLogin.Verify.value){
	    alert("Verification code does not match!")
		document.MemberLogin.Verification.focus();
		return false;
	}
	document.MemberLogin.fAction.value	= 'login';
	//document.MemberLogin.submit();
}
function sendMsg(ItemName){
	  document.getElementById("sendMsgLayer").style.visibility="visible";
	  document.getElementById("SendSubject").value = "Request from Referral List visitor: I would like to see "+ItemName+" on your profile";
}
function chkValidation()	{
	if(document.getElementById("Captcha").value	== "")	{
		alert("Please enter the verification code shown below.");	
		document.getElementById("Captcha").focus();
		return false;
	}else	{
		document.getElementById('MessageId').style.color	= "#3BA538";
		document.getElementById('MessageId').style.fontWeight	= "bold";
		document.getElementById('MessageId').innerHTML	= "Message Sending...";
		var success = function(t){chkValidationComplete(t);}
		var failure = function(t){}
		var url  = 'ajax/business.php';
		var pars = 'op=sendmessagetomember&Captcha='+document.getElementById("Captcha").value+'&isAjax=Yes';
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	
	}
}
function chkValidationComplete(t)	{

	if(t.responseText == 'Error')	{
		document.getElementById('MessageId').style.color	= "#990000";
		document.getElementById('MessageId').style.fontWeight	= "bold";
		document.getElementById('MessageId').innerHTML = "Invalid Verification Code... Please try again";
		
	}else if(t.responseText == '')	{
		document.getElementById('MessageId').innerHTML =  "";
		document.frm.submit();	
	}
}

function closeSendMsg(){
	  document.getElementById("sendMsgLayer").style.visibility="hidden";
}
var GlobalupgradeType;
function showContactForm(curobj,upgradeType){
  GlobalupgradeType = upgradeType;
  switch(upgradeType){
		case "Countries":
			getXYPosition(curobj,'ContactUsLayer',160,-290,'','');	
		break;
		case "Keywords":
			getXYPosition(curobj,'ContactUsLayer',160,-290,'','');	
		break;
		case "Categories":
			getXYPosition(curobj,'ContactUsLayer',180,-290,'','');	
		break;

  } 
 
   document.getElementById("ContactUsLayer").style.visibility="visible";
}

var MarketName;
var ContractEnd;
function showMyaccountContactForm(curobj,upgradeType,marketName,contractEnd){
  GlobalupgradeType = upgradeType;
  MarketName = marketName;
  ContractEnd = contractEnd;
  switch(upgradeType){
		case "Countries":
			getXYPosition(curobj,'MyAccountContactUsLayer',-240,-190,'','');	
		break;
		case "BusinessPlan":
			getXYPosition(curobj,'MyAccountContactUsLayer',-240,-210,'','');	
		break;
		case "Categories":
			getXYPosition(curobj,'MyAccountContactUsLayer',-260,-230,'','');	
		break;
  } 
   document.getElementById("MyAccountContactUsLayer").style.visibility="visible";
}

function MyAccountContactUsLayerForm(){
	  document.getElementById("MyAccountContactUsLayer").style.visibility="hidden";
}

function closeContactForm(){
	  document.getElementById("ContactUsLayer").style.visibility="hidden";
}
function validateUpgrade(){
   if(trim(document.getElementById("SendName").value) == ""){
	  alert("Name should not be empty");
	  document.getElementById("SendName").focus();
	  return false;
  }
  if(trim(document.getElementById("SendPhone").value) == ""){
	  alert("Phone number should not be empty");
	  document.getElementById("SendPhone").focus();
	  return false;
  }

  document.getElementById("upgradeSuccess").innerHTML = '<img src="images/loading_trans.gif" align="asbmiddle">&nbsp;&nbsp;sending ...';
  name  	= document.getElementById("SendName").value;
  phone 	= document.getElementById("SendPhone").value;
  message 	= document.getElementById("SendMessage").value;
  		
		var success = function(t){doUpgradeSendComplete(t);}
		var failure = function(t){ZipCodeEditFailed(t);}
		var url  = 'ajax/business.php';
		var pars = 'op=sendupgrade&name='+name+'&phone='+phone+'&message='+message+'&type='+GlobalupgradeType+'&MarketName='+MarketName+'&ContractEnd='+ContractEnd;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}

function doUpgradeSendComplete(t){
  document.getElementById("upgradeSuccess").innerHTML = t.responseText;
  setTimeout('document.getElementById("upgradeSuccess").innerHTML=""',5000);
}

	function doFeedBackValidation()	{
		var ContactUsName  				= $('ContactUsName');
		var ContactUsEmail 			    = $('ContactUsEmail');
		var ContactUsComments	        = $('FeedBack');
		var MyBugsAbout			        = $('BugsAbout');
var VerificationCode			= $('VerificationCode');
		if(trim(ContactUsName.value) == '')	{
			alert('Enter Your Name!');
			ContactUsName.value = '';
			ContactUsName.focus();
			return false;
		}
		if(!isAlpha(trim(ContactUsName.value)))
		{
			alert('Invalid Characters Found in Your Name.');
			ContactUsName.value = '';
			ContactUsName.focus();
			return false;
		}
		else if(trim(ContactUsEmail.value) == '')	{
			alert('Enter Your Email Address.');
			ContactUsEmail.value = '';
			ContactUsEmail.focus();
			return false;
		}
		if(!isEmail(trim(ContactUsEmail.value)))
		{
			ContactUsEmail.select();
			return false;
		}
		if(trim(MyBugsAbout.value) == '')	{
			alert('My issue is about field should not be empty.');
			MyBugsAbout.value = '';
			MyBugsAbout.focus();
			return false;
		}
		if(trim(ContactUsComments.value) == '')	{
			alert('Enter the Bugs You have Found.');
			ContactUsComments.value = '';
			ContactUsComments.focus();
			return false;
		}
		if(VerificationCode.value == ''){
			alert('Please Enter Verification Code!.');
			VerificationCode.value = '';
			VerificationCode.focus();
			return false;
		}
		$('fAction').value = 'feedback';
		return true;
	}
function doBusinessCompare() {
		ListingToCompare = "";
		if(intCompareCount <=1)
		{
			alert("Kindly select atleast 2 businesses to compare");
			return;
		}
		for(i=1;i<=20;i++)
		{
			chkBox = document.getElementById("CompareCheckBox"+i);
			if(chkBox)
			{
				if(chkBox.className == "LocationChecked")
					ListingToCompare = ListingToCompare + document.getElementById("BusinessListing"+i).value+ ",";
			}
		}
		ListingToCompare = ListingToCompare.substr(0,ListingToCompare.length - 1);
		window.location.href="index.php?op=directory.compare&list="+ListingToCompare;
}
var intCompareCount = 0;
function ChangeChecked(chkBox) {
		if(chkBox.className == "LocationUnChecked")
		{
			if(intCompareCount >=5)
			{
				alert("You can only able to select 5 Business to Compare");
				return;
			}
			intCompareCount++;
			chkBox.className = "LocationChecked";
		}
		else
		{
			intCompareCount--;
			chkBox.className = "LocationUnChecked";
		}
}
function showPhoneNumber(Ident,ListingIdent,strPhoneNumber) {
		document.getElementById("PhoneNumber"+ListingIdent).innerHTML = strPhoneNumber;
		document.getElementById("PhoneNumber"+Ident).innerHTML = strPhoneNumber;
}
function CheckValidCity(sText)
{
   var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,  ";
   var IsValid=true;
   var Char;
   if(sText=="") {return false;}
   for (i = 0; i < sText.length && IsValid == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsValid = false;
      }
   }
   return IsValid;
}
function GetZipKeywordSuggesstion(strText){

	var Keyword = trim(strText.value);
	if(Keyword.length>=1){
		var url  = 'ajax/zipcode.php';
		var pars = 'op=GetZipKeywordSuggesstion&Keyword='+Keyword;		
		//var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
		xmlHttp = AjaxHttpObject();
		if (xmlHttp==null) {
			alert("Your browser does not support AJAX !!!");
			return;
		}     
		var page = url+"?"+pars;	
		xmlHttp.onreadystatechange=function(){GetZipKeywordSuggesstionComplete();}
		xmlHttp.open("POST", page, true);
		xmlHttp.send(null);
	}else{
		if(document.getElementById("ZipcodeLayer").style.display =="block"){
			Slide(document.getElementById("ZipcodeLayer")).slideUp("slow");	
		}
	}
}
function GetZipKeywordSuggesstionComplete(){	

	if (xmlHttp.readyState == 4) {  
		if(xmlHttp.responseText!=""){	
			document.getElementById("ZipcodeLayer").innerHTML  = xmlHttp.responseText;	
			Slide(document.getElementById("ZipcodeLayer")).slideDown("slow");	
			
			scrolldiv_setColor('#FFFFFF');	// Setting border color of the scrolling content
		    //setSliderBgColor('#E2EBED');	// Setting color of the slider div
			setContentBgColor('#FFFFFF');	// Setting color of the scrolling content
			setScrollButtonSpeed(1);	// Setting speed of scrolling when someone clicks on the arrow or the slider
			setScrollTimer(5);	// speed of 1 and timer of 5 is the same as speed of 2 and timer on 10 - what's the difference? 1 and 5 will make the scroll move a little smoother.
			scrolldiv_setWidth(300);	// Setting total width of scrolling div
			scrolldiv_setHeight(130);	// Setting total height of scrolling div
			scrolldiv_initScroll();	// Initialize javascript functions
		}
	}else{
	//	if(document.getElementById("KeywordLayer").style.display =="block"){
	//			Slide(document.getElementById("KeywordLayer")).slideUp("slow");	
	//	}
	}
	
}
function ChangeZipDisplay(DisplayOnly){
	if(DisplayOnly == "Close"){
		//$("KeywordLayer").style.display = "none";
		Slide(document.getElementById("ZipcodeLayer")).slideUp("slow");	
	}

}
function UpdateCityZip(strStateCode,strCityName,strZipCode) {
	
		window.location.href = globalRequestPageForZipCode+'zipcode='+strZipCode;
	
}


/**Set Captcha Image**/

function ShowCaptchaImage(ImageContainerID,AjaxFileName,width,height,font,characters) { 
	var Filename=SiteAjaxFolder+AjaxFileName; 
	/*if($(ImageContainerID))
		$(ImageContainerID).innerHTML="<div align='center' style='width:130px;padding-top:10px'>"+loadingstatus_1+"</span>"; */
	var success = function(t){ShowCaptchaImage_Complete(t,ImageContainerID,AjaxFileName,width,height,font,characters);}
	var failure = function(t){ShowOnFailure(t);}
	var url = Filename; var pars = '&Condition=CreateCaptcha&width='+width+'&height='+height+'&font='+font+'&characters='+characters; 
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}

function ShowCaptchaImage_Complete(t,ImageContainerID,AjaxFileName,width,height,font,characters){
	var strValue = t.responseText;
	var strArray = strValue.split("^^");

	var RefreshLink="<a onclick=\"ShowCaptchaImage(\'"+ImageContainerID+"\',\'"+AjaxFileName+"\',"+width+","+height+",\'"+font+"\',"+characters+")\" >"; 
	if($(ImageContainerID))
		$(ImageContainerID).innerHTML = RefreshLink+strArray[0]+"</a>";
	if($('captchacodeid'))
		$('captchacodeid').value = strArray[1];

}

