

/*userReg.js*/

var imgThmPath = "/wt/"+bkTheme+"/images/";
var flag;
var memberType = 'buyer';
var inviteId;
var from;
var regButtonFocus=false;

function entRegSub(event,id) 
{
	if (!regButtonFocus)
	{
		if (event && event.keyCode == 13)
		{
			if(id=="frmReg"){}
				//chkAvailable(0,'UR');
		}
	}	
	return false;		
}

function selectMember(mType,brokerid)
{
	memberType=mType;
	if (mType=='buyer')
	{
			memberType="buyer";
			brokerId = brokerid;
			$('title0').innerHTML="";
	}
	if (mType=='seller')
	{
			memberType="seller";
			brokerId = brokerid;
			$('title0').innerHTML="";
	}
	if (mType=='agent')
	{
			memberType="agent";
			$('title0').innerHTML="";
			brokerId = brokerid;			
	}

	if (mType=='broker')
	{
			memberType="broker";
			$('title0').innerHTML="Broker Membership Registration";
	}
}

function clientTimeZone()
{
	var d = new Date()
	var min=(d.getTimezoneOffset()/60)*(-1);
	var stringMin=''+min;
	if(stringMin.search(/\./)<0)
	{
		if(stringMin.search(/\-/)<0)
		{
			tz="+"+stringMin+":00";
		}
		else
		{
			tz=stringMin+":00";
		}		
	}
	else
	{
		tzArr=stringMin.split(".");
		
		if(tzArr[1].length>1)
		{
			mn=60*(parseFloat(tzArr[1])/100);
		}
		else
		{
			mn=60*(parseFloat(tzArr[1])/10);
		}
		
		if(stringMin.search(/\-/)<0)
		{
			tz="+"+tzArr[0]+":"+mn;
		}
		else
		{
			tz=tzArr[0]+":"+mn;
		}		
	}
	if(tz=="-5:00" || tz=="-6:00" || tz=="-7:00" || tz=="-8:00" || tz=="-10:00")
		$('timesel').value=tz;
	else
		$('timesel').value="-10:00";
}

function setChkBtn()
{
	$('divChkAvailable').innerHTML='<button id="btnNext" class="loginBtn" name="btnNext" type="button" onclick="chkAvailable(1);">Check Availability</button>';
}

function chkAvailable(f,frm) 
{
	$('fname').className="textbox";

	chkU=($F('email1').substring(0,5));
	chkID=($F('email1').substring(5,$F('email1').length));
	
	if(trim($F('fname')) == '')
	{
		$('msgbox1').innerHTML="Please enter name";
		$('fname').className="textboxRed";
		$('fname').focus();
		return false;
	}

	
	if(chkU=='guest')
	{
		if ((chkID.match(/[0-5][0-9][0-9][0-9]/)==chkID) && (chkID<5001))
		{
			$('divChkAvailable').innerHTML="<font color='red'>User already exists, please try again.</font>";
			$('email1').className="textbox";
			$('password1').className="textbox";
			$('password2').className="textbox";
			$('fname').className="textbox";			
			return false;
		}
	}
		
	if(!isBlank('email1','e-mail address'))
	{
		$('msgbox1').innerHTML=alertErrorMsg;
		$('email1').className="textboxRed";
		$('email1').focus();
		return false;
	}
	else
	{
		if (!emailIsValid('email1'))
		{
			$('msgbox1').innerHTML=alertErrorMsg;
			$('email1').className="textboxRed";
			$('email1').focus();
			return false;
		}
		else
		{
			from=frm;
			var url = '/app/user/checklogin.php';
			var queryString = "loginId=" + $F('email1');
			flag=f;
			$('regDiv').style.display="none";
			$('msgbox').innerHTML='Processing! Please wait <img alt="Registration" src="' + imgThmPath + '/common/loaderLogin.gif" />';
			ajaxRequest(url,queryString,usrMyCallBack);
		}
	}
}

function usrMyCallBack(originalRequest)
{
	var checkLog=originalRequest.responseText;
	$('msgbox').innerHTML = "";
	$('msgbox1').innerHTML = "";
	$('regDiv').style.display="block";
	$('email1').className="textbox";
	$('password1').className="textbox";
	$('password2').className="textbox";
	$('fname').className="textbox";
	$('phoneNumber').className="textbox";
	if(checkLog!=0)
	{	
		$('msgbox1').innerHTML="<font color='red'>User already exists, please try again.</font>";
		$('email1').className="textboxRed";
		$('email1').value="";
		$('password1').value="";
		$('password2').value="";
		$('fname').value="";
		clientTimeZone();
	}
	else
	{
		if (flag==0)
		{
			submitRegister();	
		}
		else if(flag==1)
		{
			$('divChkAvailable').innerHTML="<font color='green' class='clrChkAvailable'>You Got It!</font>";
		}
	}	
}

function validateForm()
{
	$('fname').className="textbox";
	$('email1').className="textbox";
	$('password1').className="textbox";
	$('password2').className="textbox";
	$('fname').className="textbox";	
	$('phoneNumber').className="textbox";
	$('msgbox1').innerHTML  = "";
	
	if(trim($F('fname')) == '')
	{
		$('msgbox1').innerHTML="Please specify valid name";
		$('fname').className="textboxRed";
		$('fname').focus();
		return false;
	}
	else if (!emailIsValid('email1'))
	{
		$('msgbox1').innerHTML=alertErrorMsg;
		$('email1').className="textboxRed";
		return false;
	}
	else if(trim($F('phoneNumber')) == '' || !phoneIsValid('phoneNumber'))
	{
		$('msgbox1').innerHTML="Please enter valid phone number like 306-954-2548";			
		$('phoneNumber').className="textboxRed";
		return false;
	}
	else if (!passwordIsValid('password1','password2',5,15))
	{
		$('msgbox1').innerHTML=alertErrorMsg;
		$('password1').value="";
		$('password2').value="";
		$('password1').className="textboxRed";
		$('password2').className="textboxRed";
		$('password1').focus();
		return false;
	}		
	else if($("yes"))
	{
		if($("yes").checked == true && ($("agentName").value == "" || $("agentName").value == "0"))
		{
			$('msgbox1').innerHTML="Please Enter Agent Name";			
			return false;
		}

	}
	return true;
}

function submitRegister() 
{
	if ( $('tdLoginHeader'))
		$('tdLoginHeader').style.paddingLeft = '5px';

	if ( $('txtLoginHeader'))
		$('txtLoginHeader').style.display = 'none';

	$('regDiv').style.display="none";
	$('msgbox').innerHTML = 'Processing! Please wait <img alt="Registration" src="' + imgThmPath + '/common/loaderLogin.gif" />';
	var myPageUrl="";

	if(myPage != "") myPage = myPage;

	if (validateForm())
    {		
    	if(myPage != "" && typeof(myPage) != 'undefined')
			myPageUrl = '&fromPage='+myPage;
		
    	var theQuery = "email1="+ $F('email1');
    	theQuery = theQuery + "&password="+ escape($F('password1'));
		theQuery = theQuery + "&eoa=B";
		theQuery = theQuery + "&fname="+ $F('fname');		
		if(memberType=='buyer' || memberType=='' || memberType=='undefined')
		{
			theQuery = theQuery + "&eua=B"+"&BKID="+brokerId;
		}		
		if(memberType=='seller')
		{
			theQuery = theQuery + "&eua=Sl"+"&BKID="+brokerId;
		}		
		if(memberType=='agent')
		{
		   	theQuery = theQuery + "&eua=A"+"&BKID="+brokerId+"&inviteId="+inviteId;
		}	
		var objQS = new Querystring();	
		var agentId = objQS.get('agd');
		if(agentId == null || agentId == "" || agentId == "0" ) { agentId = objQS.get('aid'); }
		if( (agentId) && (agentId != null ) )
		{
			theQuery = theQuery + "&agid="+ trim(agentId);
		}
		else if(typeof(fromSiteFlg) != "undefined" && fromSiteFlg == "agentsite" && typeof(aid) != "undefined" && aid != "")
		{
			agentId = aid;
			theQuery = theQuery + "&agid="+ trim(aid);
		}
		else if( typeof(agtHomeSite) != "undefined" && agtHomeSite == "1" && agent_userId != "")
		{
			agentId = agent_userId;
			theQuery = theQuery + "&agid="+ trim(agent_userId);
		}
		else if(typeof(aid) != "undefined" && aid != "")
		{
			agentId =  aid;
			theQuery = theQuery + "&agid="+ trim(aid);
		}
		else
		{
			theQuery = theQuery + "&agid=0";
		}
		var frm = objQS.get('frm');		
		theQuery = theQuery + "&phoneNumber="+ $F('phoneNumber')+myPageUrl;
		//working with agent checkbox
		if($("yes").checked)	
		{
			//changes done when ATP ask for agents should b shown in dropdown...Jahnvi
			var agentArr = $('agentName').value.split("=^^=");
			theQuery = theQuery + "&agentName="+ escape(agentArr[0])+"&wagtid="+agentArr[1];
		}
		if(typeof(ref_url) != 'undefined' && typeof(ref_url) != null)
		{
			if(ref_url.indexOf('/Search') != -1)
			{
				theQuery = theQuery + "&serCrt="+escape(encodeURI(getSearchCriteriaStringForEmail()));
			}
		}
		theQuery = theQuery + "&comments="+escape(encodeURI(trim($F('txtComments'))));
		var url = '/app/user/userAdd.php';
		ajaxRequest(url,theQuery,userAdd);
	}
	else
	{
		$('regDiv').style.display="block";
		$('msgbox').innerHTML = "";
	}
}

function userAdd(originalRequest)
{
	var checkLog=trim(originalRequest.responseText);
	if(from!="UR")
	{
		var checkLog=originalRequest.responseText;
		if(checkLog=="SU")
		{
			var url = '/app/auth/validateLogin.php';
			var queryString = "usid=" + $F('email1') + "&pass=" + escape($F('password1'))+"&from="+from;
			ajaxRequest(url,queryString,login);
		}
		else
		{
			_alert("User Not Registered, please try again!");
			$('regDiv').style.display="block";
			$('msgbox').innerHTML = "";
		}
	}
	else
	{
		var checkLog=trim(originalRequest.responseText);
		var agentLogin="";

		if(checkLog.indexOf("=^^=") != -1)
		{
			//Call For Agentsite user only
			var response  = checkLog.split("=^^=");
			checkLog = response[0];
			agentLogin = response[1];
		}
		if(trim(checkLog)=="SU")
		{
			var objQs=new Querystring();
			var agtid=objQs.get('agd');	
			var frm = objQs.get('frm');
			if ((agtid) && (agtid != null ))
			{				
				//case if regstration from agentsite
				if(typeof(ref_url) != 'undefined')
					location.href = ref_url;
				else
					location.href='/app/user/congratulations.php?setHeader=null&frm=agt&aid='+agtid;
			}
			else
			{
				if(typeof(ref_url) != 'undefined')
					location.href = ref_url;
				else
					location.href='/app/user/congratulations.php?setHeader=null';
			}
			$A(document.getElementsByTagName("input")).each(function(node){node.value="";node.className="textbox"});
			setChkBtn();
			$("msgbox1").innerHTML = "";
		}
		else
		{
			_alert("User Not Registered, please try again!");
			$('regDiv').style.display="block";
			$('msgbox').innerHTML = "";
		}
	}
}

/*signIn.js*/

/* function handling the user login process*/
var signInButtonFocus=false;
var passCheck=true;
var loginCheck=true;
var myPage="";
var myref = '';
function rememberIdPassword(uname,password)
{
	strCookie = uname+";"+password;
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	if($("chkRemember").checked == true)
	{
		setCookie("remConsIdPwd",strCookie,now);
	}
	else
	{
		setCookie("remConsIdPwd","");
	}
}

function chkCookieRemember()
{
	var strck = "";
	strck = getCookie("remConsIdPwd");
	if(strck=="" || strck==null )
	{}
	else
	{
		var strcksplit = strck.split(";");
		$("usrName").value = strcksplit[0];
		$("usrPwd").value = strcksplit[1];
		$("chkRemember").checked = true
	}
}
function entSub(event,id,fromPage) 
{
	if (!signInButtonFocus)
	{
		if (event && event.keyCode == 13)
		{
			if(id=="frmLogin")
				validateUserLogin('UR',fromPage);
			else if(id=="frmFgtLogin")
				submitForget();
			else if(id=="frmFgtLoginV")
				submitForgetVendor();
			else if ( id == "frmLoginNewNew" )
				validateLoginForNewWidget ();
		
		}
	}	
	return false;		
}

function validateUserLogin(from,fromPage)
{
	myPage=fromPage;
	if($('optCLogin') && $('optCLogin').checked == true)
		var lStatus  = 	'C';
	else
		var lStatus = 'L';

	if(!isBlank('usrName',"e-mail address"))
	{
		$('failMsg1').innerHTML=alertErrorMsg;
		$('usrName').focus();
		$('usrName').className="textboxRed";
		$('usrPwd').className="textbox";
		return false;
	}

	if(!isBlank('usrPwd',"Password"))
	{
		$('failMsg1').innerHTML=alertErrorMsg;
		$('usrPwd').focus();
		$('usrName').className="textbox";
		$('usrPwd').className="textboxRed";
		return false;
	}

	var url = '/app/auth/validateLogin.php';
	var queryString = "usid=" + $F('usrName') + "&pass=" + escape($F('usrPwd'))+"&from="+from;

	queryString = queryString +"&status="+lStatus;
	if(location.pathname.search("vendor")!=-1)
		queryString = queryString +"&page=vendor";
	
	Element.toggle('signBtn');
	Element.toggle('signInDiv');	
	ajaxRequest(url,queryString,login);	
}

function login(originalRequest)
{	
	var uname = $F('usrName');
	var password = $F('usrPwd');
	if(trim(ref_url) != "")
		refral = ref_url;	
	if(originalRequest.responseText=="other")
	{
		location.href='/app/misc/newWidget.php?PHPSESSID='+sessid;
		return;
	}
	var checkLog=originalRequest.responseText;
	var arr=checkLog.split('|');	
	switch (arr[0])
	{
		case 'NR':
			$('failMsg1').innerHTML="E-mail and password did not match!";
			$('usrName').value="";
			$('usrPwd').value="";
			$('usrName').focus();
			$('usrName').className="textbox";
			$('usrPwd').className="textbox";
			Element.toggle('signInDiv');
			Element.toggle('signBtn');
		break;
		case 'NA':
			var objQs=new Querystring();
			var agtid=objQs.get('agd');

			if(myPage != "" && typeof(myPage) != 'undefined')
				myPage = '&fromPage='+myPage;
				
			if(agtid!=null && trim(agtid)!='')
			{
				//case if regstration from agentsite
				location.href='/app/auth/accountNotActivated.php?setHeader=null&uid='+arr[1]+'&frm=agt&aid='+agtid+myPage;
			}
			else
		    {
				location.href='/app/auth/accountNotActivated.php?setHeader=null&uid='+arr[1]+myPage;
			}			
		break;
		case 'FST':
			rememberIdPassword(uname,password);
			location.href='/app/auth/intermediateProfile.php?PHPSESSID='+sessid+'&page=login';
		break;
		case 'misc':
			rememberIdPassword(uname,password);
			location.href='/app/misc/newWidget.php??PHPSESSID='+sessid;
		break;
		case 'SP':
			rememberIdPassword(uname,password);
			location.href='../ajaxim/support.php?PHPSESSID='+sessid;
		break;		
		case 'SRCH':
			rememberIdPassword(uname,password);
			loginDlg.hide();
			var arr = chkCalledFrom.split(',');
			if (arr[0] == "addMyFavourite")
			{
				addMyFavourite(arr[1]);
			}
			else
			{
				addMyOpenHome(arr[1]);
			}
			ajaxRequest('./addMenuBar.php','type=searchResult',setMenuCallBack);
		break;
		case 'B':
			rememberIdPassword(uname,password);
			location.href=refral;
		break;
		case 'A':
			rememberIdPassword(uname,password);
			location.href=refral;
ak;
		case 'BK':
			rememberIdPassword(uname,password);
			location.href=refral;
		case 'FBDA':
			alert("Your account has been deactivated. Try again later.");
//			top.GB_hide();
			return;
		break;
	}
}

function validateLoginForNewWidget()
{
	if(!isBlank('usrName',"e-mail address"))
	{
		$('failMsg1').innerHTML=alertErrorMsg;
		$('usrName').focus();
		$('usrName').className="textboxRed";
		$('usrPwd').className="textbox";
		return false;
	}
	if(!isBlank('usrPwd',"Password"))
	{
		$('failMsg1').innerHTML=alertErrorMsg;
		$('usrPwd').focus();
		$('usrName').className="textbox";
		$('usrPwd').className="textboxRed";
		return false;
	}
	var url = '/app/auth/validateLogin.php';
	var queryString = "usid=" + $F('usrName') + "&pass=" + escape($F('usrPwd'));
	Element.toggle('signBtn');
	Element.toggle('signInDiv');

	ajaxRequest(url,queryString,newWindgetLogin);
}

function newWindgetLogin (originalRequest)
{
	var checkLog=originalRequest.responseText;
	var arr=checkLog.split('|');

	if ( arr[0] == 'NR' )
	{
		$('failMsg1').innerHTML="E-mail and password did not match!";
		$('usrName').value="";
		$('usrPwd').value="";
		$('usrName').focus();
		$('usrName').className="textbox";
		$('usrPwd').className="textbox";
		Element.toggle('signInDiv');
		Element.toggle('signBtn');
	}
	else
	{
		location.href='/app/misc/newWidget.php';
	}
}

function setMenuCallBack(originalRequest)
{
	var response = originalRequest.responseText;	
	$('divMenu').innerHTML=response;	
}

function sendNewEmail(uid,fromPage)
{
	var url = '/app/auth/sendNewEmail.php';
	var queryString = "uid=" +uid + "&fromPage=" + fromPage;
	ajaxRequest(url,queryString,mailCallBack);
}

function mailCallBack(originalRequest)
{
	var status=trim(originalRequest.responseText);

	if(status=="1")
	{
		_alert("Email has been sent to you.");
	}
	else
	{
		_alert("Not able to send you email now. Please try again later.");
	}
}

function continueProfile(role,statu)
{
	switch (statu)
	{
		case 'N':
			location.href='/app/user/userInformation.php?PHPSESSID='+sessid;
		break;
		case 'Y':
			switch(role)
			{
				case 'B':
					location.href='/index.php';
				break;
				case 'A':
					location.href='/app/dashboard/dashboard.php?PHPSESSID='+sessid;
				break;
				case 'BK':
					location.href='/app/dashboard/dashboard.php?PHPSESSID='+sessid;
				break;
			}
		break;
	}
}

function forgotPassword(switchLoginDiv)
{
	if(switchLoginDiv == 1)
	{
		$('divLogin').style.display = "none";
		$('fgetLink').style.display = 'none';
		$('divForget').style.display = 'block';
		$('fgetUserName').focus();
	}
	else
	{
		$('divForget').style.display = 'none';
		$('fgetLink').style.display = 'block';
		$('divLogin').style.display = "block";
		
		$('usrName').className="textbox";
		$('usrPwd').className="textbox";
		
		if($('usrName').value==""){
			$('usrName').focus();
		}
		else {
			$('usrPwd').focus();
		}
		
	}	
	$('failMsg2').innerHTML="";
	$('failMsg1').innerHTML="";
	$('fgetUserName').className="textbox";
	
	
}

function submitForgetVendor(from)
{
	if(!isBlank('fgetUserName',"e-mail address"))
	{
		$('failMsg2').innerHTML=alertErrorMsg;
		$('fgetUserName').focus();
		$('fgetUserName').className="textboxRed";
		return false;
	}
	var url = '/app/auth/resendLogin.php';
	var queryString = "usid=" + $F('fgetUserName') + "&from=vendor";
	$('fgetUserName').value="";
	$('usrName').value="";
	$('usrPwd').value="";
	if (from == 'landing')
		ajaxRequest(url,queryString,resendLanding);
	else
		ajaxRequest(url,queryString,resendLogin);
}

function submitForget(from)
{
	if(!isBlank('fgetUserName',"e-mail address"))
	{
		$('failMsg2').innerHTML=alertErrorMsg;
		$('fgetUserName').focus();
		$('fgetUserName').className="textboxRed";
		return false;
	}
	var url = '/app/auth/resendLogin.php';
	var queryString = "usid=" + $F('fgetUserName');
	$('fgetUserName').value="";
	$('usrName').value="";
	$('usrPwd').value="";
	if (from == 'landing')
		ajaxRequest(url,queryString,resendLanding);
	else
		ajaxRequest(url,queryString,resendLogin);
}

function resendLogin(originalRequest)
{
	var status=trim(originalRequest.responseText);
	$('failMsg2').innerHTML="";
	$('fgetUserName').className="textbox";
	switch(status)
	{
		case 'NR':
			_alert("You are not registered with the system!");
			
			$('usrName').className="textbox";
			$('usrPwd').className="textbox";
			
		break;		
		case 'SU':
			_alert("Email has been sent to you.");
		break;		
		default:
			_alert("Not able to send you email now. Please try again later.");	
	}
	$('divForget').style.display='none';
	$('divLogin').style.display='block';
	$('fgetLink').style.display = 'block';
	$('usrName').focus();
}

function resendLanding(originalRequest)
{
	var status=originalRequest.responseText;
	switch(status)
	{
		case 'NR':
			_alert("Yor are not registered with the system!Please Register and then Login");
		break;		
		case 'SU':
			_alert("Email has been sent to you.");
		break;		
		default:
			_alert("Not able to send you email now. Please try again later.");	
	}
	$('failMsg2').innerHTML="&nbsp;";
	$('fgetUserName').focus();
	$('fgetUserName').className="textbox";
}

function validateLoginForWidget()
{
	alert('for new code');
}

function capsDetect( e,id ) {
	if( !e ) { e = window.event; } if( !e ) { MWJ_say_Caps( false,e,id ); return; }
	//what (case sensitive in good browsers) key was pressed
	var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
	//was the shift key was pressed
	var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //bitWise AND
	//if upper case, check if shift is not pressed. if lower case, check if shift is pressed
	MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ),e,id );
}
function MWJ_say_Caps( oC,e,id ) {
	if( typeof( capsError ) == 'string' ) { if( oC ) { alert( capsError ); } } else { capsError( oC,e,id ); }
}

function capsError( capsEngaged,event,id )
{
	if( capsEngaged )
	{
		createCapsDiv(event,id);
	}
	else
	{
		closeSticky(id);
		loginCheck=true;
		passCheck=true;
	}
}

function closeSticky(id)
{
	if($(id))
	{
		$(id).remove();
		if(id=="capsLoginDiv")
			loginCheck=false;
		else if(id=="capsPasswdDiv")
			passCheck=false;
	}
}

function createCapsDiv(evt,id)
{
	if($(id))
	{
		if(id=="capsLoginDiv")
		{
			$('capsLoginDiv').style.display="block";
			if($('capsPasswdDiv'))
			$('capsPasswdDiv').style.display="none";		
		}
		else if(id=="capsPasswdDiv")
		{
			if($('capsLoginDiv'))
				$('capsLoginDiv').style.display="none";
			$('capsPasswdDiv').style.display="block";		
		} 
		return;
	}
	myDiv=document.createElement('div');
	if(id=="capsLoginDiv" && loginCheck)
	{
		var divLeft = getPositionLeft("usrName");
		var divTop = getPositionTop("usrName");
		var leftPos = eval(divLeft+150);
		var topPos = divTop;
		myDiv.id=id;
		var toSet="<table width=\"275px\" border=\"0\"><tr><td class=\"helpTopLeft\"/><td class=\"helpTopCenter\" align=\"right\"/><td class=\"helpTopRight crsr\" title=\"Donot show this warning again!\" onclick=\"closeSticky('"+id+"');\"\"/></tr><tr><td class=\"helpMiddleLeft\"/><td class=\"widHelpInner\"><table width=\"100%\" height=\"100%\" style=\"font-size:1.2em\"><tr><td colspan=\"2\" class=\"stickyLabel\" align=\"center\"><span class=\"lang\"><u>Caps Lock Is On</u></span></td></tr><tr><td class=\"stickyLabel\">Having The Caps Lock on may cause you<br/>to enter your password incorrectly.</td></tr><tr><td>&nbsp;</td></tr><tr><td colspan=\"2\">You should press Caps Lock to turn it off<br />before entering your password.</td></tr></table></td><td class=\"helpMiddleRight\"/></tr><tr><td class=\"helpBottomLeft\"/><td class=\"helpBottomCenter\"></td><td class=\"helpBottomRight\"/></tr></table>";
		myDiv.style.height="80px";
		myDiv.style.width="200px";
		myDiv.style.zIndex="1000";
		myDiv.style.position="absolute";
		myDiv.style.left=leftPos+"px";
		myDiv.style.top=topPos+"px";
		$('divLogin').appendChild(myDiv);
		myDiv.innerHTML=toSet;
		if($("capsPasswdDiv"))
		{
			$('capsPasswdDiv').style.display="none";			
		}
			
	}
	else if(id=="capsPasswdDiv" && passCheck)
	{
		var divLeft = getPositionLeft("usrPwd");
		var divTop = getPositionTop("usrPwd");
		var leftPos = eval(divLeft+150);
		var topPos = divTop;
		myDiv.id=id;
		var toSet="<table width=\"275px\" border=\"0\"><tr><td class=\"helpTopLeft\"/><td class=\"helpTopCenter\" align=\"right\"/><td class=\"helpTopRight crsr\" title=\"Donot show this warning again!\" onclick=\"closeSticky('"+id+"');\"\"/></tr><tr><td class=\"helpMiddleLeft\"/><td class=\"widHelpInner\"><table width=\"100%\" height=\"100%\" style=\"font-size:1.2em\"><tr><td colspan=\"2\" class=\"stickyLabel\" align=\"center\"><span class=\"lang\"><u>Caps Lock Is On</u></span></td></tr><tr><td class=\"stickyLabel\">Having The Caps Lock on may cause you<br/>to enter your password incorrectly.</td></tr><tr><td>&nbsp;</td></tr><tr><td colspan=\"2\">You should press Caps Lock to turn it off<br />before entering your password.</td></tr></table></td><td class=\"helpMiddleRight\"/></tr><tr><td class=\"helpBottomLeft\"/><td class=\"helpBottomCenter\"></td><td class=\"helpBottomRight\"/></tr></table>";
		myDiv.style.height="80px";
		myDiv.style.width="200px";
		myDiv.style.zIndex="1000";
		myDiv.style.position="absolute";
		myDiv.style.left=leftPos+"px";
		myDiv.style.top=topPos+"px";
		$('divLogin').appendChild(myDiv);
		myDiv.innerHTML=toSet;
		if($("capsLoginDiv"))
		{
			$('capsLoginDiv').style.display="none";			
		}
	}	
}

function setCreateAccHeader()
{	
	var alertType = '';
	if(typeof(myPriceParmObj) != 'undefined' && typeof(myPriceParmObj.alertType) != 'undefined' && typeof(myPriceParmObj.alertType) != null)
		alertType = myPriceParmObj.alertType;
	if($('rowCreateAccTxt'))
	{
		if(myref == 'homeSaveLink')
			$('rowCreateAccTxt').innerHTML = 'To save this property, please create an account.';
		else if(myref == 'homeSHViewLink')
			$('rowCreateAccTxt').innerHTML = 'Please create an account to view details.';
		else if(myref == 'homeSavePSAlertLink')
			$('rowCreateAccTxt').innerHTML = 'To receive status alerts on this property, please create an account.';
		else if(myref == 'homeSaveEmailAlertLink' || alertType == 'marketReport')
			$('rowCreateAccTxt').innerHTML = 'To create an email alert, please create an account.';
		else
			$('rowCreateAccTxt').innerHTML = 'Please create an account to view details.';
	}

	if((typeof(fromSiteFlg) != "undefined" && fromSiteFlg == "agentsite" && typeof(aid) != "undefined" && aid != "") || ( typeof(frmAid) != "undefined" && frmAid != "") || ( typeof(agtHomeSite) != "undefined" && agtHomeSite == "1" && agent_userId != "") || (typeof(aid) != "undefined" && aid != ""))
	{
		$('rowWorkingAgt').hide();
	}
}
function showAgentNames()
{
	var optArr = document.getElementById('tblCreateAcc').getElementsByTagName("option");
	if($("yes").checked == true)
	{
		if(optArr.length ==0 )
		{
			var qs='';
			qs += "limit=all&showAgents=dropdown";
			var url = "/getAgents.php";
			ajaxRequest(url,qs,cbfngetAgents);
		}
		$("agentNameSelectBox").style.display=""; 
		$("agentNameLabel").style.display=""; 
	}
	else
	{
		$("agentNameSelectBox").style.display="none"; 
		$("agentNameLabel").style.display="none"; 
	}
}
function cbfngetAgents(resp)
{
	var response = resp.responseText;
	$("agentNameSelectBox").innerHTML = response;
}

function validateFBLogin(uid)
{	
	var url = '/app/auth/validateFBLogin.php';
	var queryString = "userid="+uid;	
	
	Element.toggle('signBtn');
	Element.toggle('signInDiv');	
	ajaxRequest(url,queryString,login);
}

/***** New Code for Signin Page..Chintan Shah... ******/
function showLoginTbl()
{
	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblForgotPass').style.display="none";
	document.getElementById('tblLoginAcc').style.display="";
	document.getElementById('tblMarketReportSample').style.display="none";
	document.getElementById('tblEmailAlertSample').style.display="none";
	document.getElementById('tblHomeSiteSample').style.display="none";
	setTimeout(function () 
	{
		if($('txtLoginHeader') )
		{
			if ( $('tblLoginAcc').style.display != "none" )
				$('txtLoginHeader').focus(); 
		}
	},4000);
} 
function showCreareAccTbl()
{
	document.getElementById('tblCreateAcc').style.display="";
	document.getElementById('tblMarketReportSample').style.display="none";
	document.getElementById('tblEmailAlertSample').style.display="none";
	document.getElementById('tblHomeSiteSample').style.display="none";
	document.getElementById('tblLoginAcc').style.display="none";
	document.getElementById('tblForgotPass').style.display="none";
	if($('txtLoginHeader'))$('txtLoginHeader').focus();
}
function showForgotPassTbl()
{
	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblLoginAcc').style.display="none";
	document.getElementById('tblForgotPass').style.display="";
	if($('txtLoginHeader'))$('txtLoginHeader').focus();
}	
function showEmailAlertSample()
{
	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblEmailAlertSample').style.display="";
	document.getElementById('tblHomeSiteSample').style.display="none";
	document.getElementById('tblMarketReportSample').style.display="none";
	if($('txtLoginHeader'))$('txtLoginHeader').focus();
}
function showHomeSiteSample()
{
	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblHomeSiteSample').style.display="";
	document.getElementById('tblEmailAlertSample').style.display="none";		
	document.getElementById('tblMarketReportSample').style.display="none";
	if($('txtLoginHeader'))$('txtLoginHeader').focus();
}
function showMarketReportSample()
{
	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblMarketReportSample').style.display="";
	document.getElementById('tblEmailAlertSample').style.display="none";
	document.getElementById('tblHomeSiteSample').style.display="none";	
	if($('txtLoginHeader'))$('txtLoginHeader').focus();
}

function openLoginDiv()
{
	window.scrollTo(0,0);
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	//document.documentElement.style.overflow=document.body.style.overflow='hidden';
	document.documentElement.style.overflow = 'hidden';	 // firefox, chrome
	document.body.scroll = "no";	// ie only
}

function closeLoginDiv()
{
	clearAllEle();

	document.getElementById('tblCreateAcc').style.display="none";
	document.getElementById('tblMarketReportSample').style.display="none";
	document.getElementById('tblEmailAlertSample').style.display="none";
	document.getElementById('tblMarketReportSample').style.display="none";
	document.getElementById('tblLoginAcc').style.display="none";	

	document.getElementById('light').style.display='none';
	document.getElementById('fade').style.display='none';
	document.documentElement.style.overflowY = 'scroll';	 // firefox, chrome
	document.body.scroll = "yes";	// ie only
}

function clearAllEle()
{
	if ( document.getElementById('tblCreateAcc').style.display != 'none' )
	{
		document.getElementById('msgbox1').innerHTML = '';
		document.getElementById('fname').value = '';
		document.getElementById('fname').className = 'textbox';
		document.getElementById('email1').value = '';
		document.getElementById('email1').className = 'textbox';
		document.getElementById('phoneNumber').value = '';
		document.getElementById('phoneNumber').className = 'textbox';
		document.getElementById('password1').value = '';
		document.getElementById('password1').className = 'textbox';
		document.getElementById('password2').value = '';
		document.getElementById('password2').className = 'textbox';
		document.getElementById('txtComments').value = '';		
		document.getElementById('txtComments').className = 'textbox';
	}
	else if ( document.getElementById('tblLoginAcc').style.display != 'none' )
	{
		document.getElementById('failMsg1').innerHTML = '';
		document.getElementById('usrName').value = '';
		document.getElementById('usrName').className = 'textbox';
		document.getElementById('usrPwd').value = '';
		document.getElementById('usrPwd').className = 'textbox';
		document.getElementById('chkRemember').checked = false;
	}
	else if ( document.getElementById('tblForgotPass').style.display != 'none' )
	{
		document.getElementById('failMsg2').innerHTML = '';
		document.getElementById('fgetUserName').value = '';
		document.getElementById('fgetUserName').className = 'textbox';
	}
}

function opensignInRegDlg(ref,chkSignIn,op,fromPage)
{
	frompage = fromPage;

	if(typeof(fromPage) != "undefined" && fromPage != "")
		myPage = fromPage;
	else
		myPage = 'propSearch';

	if(typeof(op) == 'undefined') op = '';
	if(ref == '') { ref = '/index.php';}
	var flag = false;
	myref = ref_url = ref;	
	if(chkSignIn != "R" && chkSignInReqd == "1") flag = true;

	if( (uid == "" || uid == "0") && (chkSignIn == "R" || flag) )
	{
			if(ref_url == 'homeSHViewLink' || ref_url == 'homeSaveLink' || ref_url == 'homeSavePSAlertLink' || ref_url == 'homeSaveEmailAlertLink' || ref_url == 'aSavSearch' || ref_url == 'getEmlAlertOH')
			{
				var curPage = document.location.href;

				if(curPage.indexOf('?') != -1)
					ref_url = curPage+'&cf='+ref_url;			
				else
					ref_url = curPage+'?cf='+ref_url;

			}				
			openLoginDiv();
			if (op == 'login' )
				showLoginTbl();
			else
				showCreareAccTbl();
	}
	else
	{
		window.location.href = ref;
	}		
}
/***************************************************/


/*validation.js*/

var alertErrorMsg="";

function isYear(id)
{
	var dt = new Date();
	dt = dt.getFullYear();
	var yr = Number($(id).value);
	if(isNaN(yr))
	{
		alertErrorMsg = "Please Enter valid Year.";
		return false;
	}
	if(yr<1000 || yr>3000)
	{
		alertErrorMsg = "Please Enter valid Year.";
		return false;
	}
/*	if($(id).value.length != oflength)
	{
		alertErrorMsg = "Only "+oflength+" characters alllowed."
		return false;
	}*/
	return true;
}
function isSqft(id)
{
	var sqft = $(id).value;
	sqft = sqft.gsub(",","");
	if(isNaN(Number(sqft)))
	{
		alertErrorMsg = "Enter valid value.";
		return false;
	}
	return true;
}
function isOfLength(id,oflength,limit)
{
	if(limit==null)
	{
		if($(id).value.length != oflength)
		{
			alertErrorMsg = "Only "+oflength+" characters alllowed."
			return false;
		}
	}
	else
	if($(id).value.length > oflength)
	{
		alertErrorMsg = "Maximum "+oflength+" characters alllowed."
		return false;
	}
	return true;
}

function isOverMaxLength(id,maxlength)
{
	return $(id).value.length > maxlength;
}

function isUnderMinLength(id,minlength)
{
	return $(id).value.length < minlength;
}

function regExTest(id,expression)
{
	return $(id).value.match(expression) != null;
}

function isDecimal(val)
{
	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	return val.match(decimalRE) != null;
}

function isNonDecimal(number)
{
	numRegExp = /^[0-9]+$/
  	return numRegExp.test(number);
}

function isNonNegDecimal(element)
{
	var nonnegdecimalRE = "^[0-9][0-9]*(\\.[0-9]*)?$";
	return regExTest(element,nonnegdecimalRE);
}

function isProperMoney(id)
{
	if($(id).value<=0)
		return null;
	var nonnegdecimalRE = "^[0-9][0-9]*(\\.[0-9]*)?$";
	var num=String(money2num($(id).value));
	return num.match(nonnegdecimalRE) != null;
	
}

function usernameIsValid(id,min,max)
{
	if (!isBlank(id,'Username')) 
	{
		return false;
	}
	if (isOverMaxLength(id,max) || isUnderMinLength(id,min))
	{
		alertErrorMsg = "Username should between "+min+" - "+max+" characters";
		return false;
	}
	var uName = $(id).value;
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < uName.length; i++) 
	{
  		if (iChars.indexOf(uName.charAt(i)) != -1)
  		{
  			alertErrorMsg = "Username should not contain special characters";
  			return false;
  		}
  	}
	return true;
}

function passwordIsValid(id,reid,min,max)
{
	if ($F(id) != $F(reid))
	{
		alertErrorMsg = "Password do not match";
		return false;
	}
	if (!isBlank(id,'Password')) //|| (IsDecimal('txtName'))
	{
		return false;
	}
	if (isOverMaxLength(id,max) || isUnderMinLength(id,min))
	{
		alertErrorMsg = "Password should be between "+min+" - "+max+" characters";
		return false;
	}
	return true;
}

function emailIsValid(id)
{
	var testresults;
	if (!isBlank(id,"E-mail Address")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter E-mail.";
		return false;
	}
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid email address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

function chkOnlyEmailIsValid(id)
{
	var testresults;
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if (filter.test(str) || str == "")
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid email address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

function isValidURL(id,newRegEx){

	var flag=0;
	if (!isBlank(id,"URL")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter URL.";
		return false;
	}
	var url=$F(id);

	if (url.indexOf ('http://') == -1)
	{
		if (url.indexOf ('https://') == -1)
		{
			$(id).focus();
			alertErrorMsg = "URL must start with http:// or https://";
			return false;
		}
		else
			flag=1;
	}
	else
		flag=1;

	if(flag==1)
	{
		if(url.substring(0,7)=="http://" || url.substring(0,8)=="https://" )
		{	//nothing 	
		}
		else
		{
			$(id).focus();
			alertErrorMsg = "URL must start with http:// or https://";
			return false;
		}

	}  
	var newRegCheck = false;
	if(newRegEx)
	{
		if(newRegEx != '' || newRegEx == '1')
			newRegCheck = true;
	}

	if(newRegCheck)
	{
		var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	}
	else
	{
		var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	}

    if(RegExp.test(url))
	{
        return true;
    }
	else
	{
    	$(id).value="";
		$(id).focus();
		alertErrorMsg = "Please Enter valid URL.";		
        return false;
    }
} 

function validURL(id){
	if (!isBlank(id,"URL")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter URL.";
		return false;
	}
	var url=$F(id);
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url))
	{
        return true;
    }	
	else
	{
    	$(id).value="";
		$(id).focus();
		alertErrorMsg = "Please Enter valid URL.";		
        return false;
    }
}


function phoneIsValid(id,disp)
{
	return validatePhone(id,disp);
}

function zipIsValid(id,how)
{
	(how==null)?"alert":"";
	var valid = "0123456789-";
	var hyphencount = 0;

	if($F(id) != "" && $F(id) != " ")
	{
		//alert("val = "+document.getElementById(id).value+"ens");
		if ($(id).value.length!=5 && $(id).value.length!=10)
		{
			if(how=="alert")
				_alert("Please enter your 5 digit or 5 digit+4 zip code.");
			else
				alertErrorMsg = "Please enter your 5 digit or 5 digit+4 zip code.";
			$(id).value="";
			$(id).focus();
			return false;
		}
		for (var i=0; i < $(id).value.length; i++)
		{
			temp = "" + $(id).value.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1")
			{
				if(how=="alert")
					_alert("Invalid characters in your zip code.  Please try again.");
				else
					alertErrorMsg = "Invalid characters in your zip code.";
				$(id).value="";
				$(id).focus();
				return false;
			}
			if ((hyphencount > 1) || (($(id).value.length==10) && ""+$(id).value.charAt(5)!="-"))
			{
				if(how=="alert")
					_alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
				else
					alertErrorMsg = "The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.";
				
				$(id).value="";
				$(id).focus();
				return false;
			}
		}
	}
	return true;
}

function zipValid(id)
{
	var valid = "0123456789-";
	var hyphencount = 0;

	if($F(id) != "" && $F(id) != " ")
	{
		//alert("val = "+document.getElementById(id).value+"ens");
		if ($(id).value.length!=5 && $(id).value.length!=10)
		{
			alertErrorMsg = "Please enter your 5 digit or 5 digit+4 zip code.";
			$(id).value="";
			$(id).focus();
			return false;
		}
		for (var i=0; i < $(id).value.length; i++)
		{
			temp = "" + $(id).value.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1")
			{
				alertErrorMsg = "Invalid characters in your zip code.";
				$(id).value="";
				$(id).focus();
				return false;
			}
			if ((hyphencount > 1) || (($(id).value.length==10) && ""+$(id).value.charAt(5)!="-"))
			{
				alertErrorMsg = "The hyphen character should be used formatted properly.";
				$(id).value="";
				$(id).focus();
				return false;
			}
		}
	}
	return true;
}


function numberIsValid(id,msg,disp,min,max)
{
	if (($F(id) != "") && ($F(id) != " ") && (isNaN($F(id))))
	{
		alertErrorMsg=msg;
		//alert(msg);
		$(id).value="";
		$(id).focus();
		return false;
	}
	if (min !=null && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		alertErrorMsg=disp+" should be more than "+min+" characters";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if (max !=null && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		alertErrorMsg=disp+" should be less than "+max+" characters";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}

function albhabetIsValid(id,msg,disp,min,max)
{
	if(($F(id) != "") && ($F(id) != " ") && $F(id).match(/^[A-Za-z\s]+$/g) == null)
	{
		alertErrorMsg=msg;
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((min != null) && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+" should have atleast "+min+" characters.")
		alertErrorMsg="Value of "+disp+" should have atleast "+min+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((max != null) && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+"allows only "+max+" characters.")
		alertErrorMsg="Value of "+disp+"allows only "+max+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}

function alphaNumericIsValid(id,msg,disp,min,max)
{
	if(($F(id) != "") && ($F(id) != " ") && $F(id).match(/^[A-Za-z0-9_\s]+$/g) == null)
	{
		alertErrorMsg=msg;
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((min != null) && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+" should have atleast "+min+" characters.")
		alertErrorMsg="Value of "+disp+" should have atleast "+min+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((max != null) && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+"allows only "+max+" characters.")
		alertErrorMsg="Value of "+disp+"allows only "+max+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}

function isBlank(id,disp)
{
	if(trim($F(id)) == "")
	{
		alertErrorMsg="Please enter "+disp;
		$(id).focus();
		return false;
	}
	return true;
}
function isBlank_withoutfocus(id,disp)
{
	if(trim($F(id)) == "")
	{
		alertErrorMsg="Please enter "+disp;
		return false;
	}
	return true;
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function mobileIsValid(id,disp)
{
	return validatePhone(id,disp);
}
function faxIsValid(id,disp)
{
	return validatePhone(id,disp);
}

function percentageIsValid(id)
{
	var testresults;
	var filter = /^\d{1,2}(\.\d{1,2})?$/;
	var str=$F(id);
	if (!isBlank(id,"Percentage")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter Percentage.";
		return false;
	}
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid Percentage value!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return testresults;
}


function siteIsValid(id)
{
	var testresults;
	if (!isBlank(id,"E-mail Address")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter E-mail.";
		return false;
	}
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)\.((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	//var filter = /(\w+):\/\/([\w\.]+)\/([\w\/]+)/;
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid site address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

// Date Validation Javascript
// copyright 30th October 2004, by Stephen Chapman
// http://javascript.about.com

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function valDateFmt(datefmt) {myOption = -1;
for (i=0; i<datefmt.length; i++) {if (datefmt[i].checked) {myOption = i;}}
if (myOption == -1) {_alert("You must select a date format");return ' ';}
return datefmt[myOption].value;}
function valDateRng(daterng) {myOption = -1;
for (i=0; i<daterng.length; i++) {if (daterng[i].checked) {myOption = i;}}
if (myOption == -1) {_alert("You must select a date range");return ' ';}
return daterng[myOption].value;}
function stripBlanks(fld) {var result = "";for (i=0; i<fld.length; i++) {
if (fld.charAt(i) != " " || c > 0) {result += fld.charAt(i);
if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);}
var numb = '0123456789';
function isValid(parm,val) {if (parm == "") return true;
for (i=0; i<parm.length; i++) {if (val.indexOf(parm.charAt(i),0) == -1)
return false;}return true;}
function isNum(parm) {return isValid(parm,numb);}
var mth = new Array(' ','january','february','march','april','may','june','july','august','september','october','november','december');
var day = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
function validateDate(fld,fmt,rng)
{
	var dd, mm, yy;
	var today = new Date;
	var t = new Date;
	fld = stripBlanks(fld);
	if (fld == '') return false;
	var d1 = fld.split('\/');
	if (d1.length != 3) d1 = fld.split(' ');
	if (d1.length != 3) return false;
	if (fmt == 'u' || fmt == 'U')
	{
	 	dd = d1[1];
	 	mm = d1[0];
	 	yy = d1[2];
	 }
	else if (fmt == 'j' || fmt == 'J') {
	  dd = d1[2]; mm = d1[1]; yy = d1[0];}
	else if (fmt == 'w' || fmt == 'W'){
	  dd = d1[0]; mm = d1[1]; yy = d1[2];}
	else return false;
	var n = dd.lastIndexOf('st');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('nd');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('rd');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('th');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf(',');
	if (n > -1) dd = dd.substr(0,n);
	n = mm.lastIndexOf(',');
	if (n > -1) mm = mm.substr(0,n);
	if (!isNum(dd)) return false;
	if (!isNum(yy)) return false;
	if (!isNum(mm)) {
	  var nn = mm.toLowerCase();
	  for (var i=1; i < 13; i++) {
	    if (nn == mth[i] ||
	        nn == mth[i].substr(0,3)) {mm = i; i = 13;}
	  }
}
if (!isNum(mm)) return false;
dd = parseFloat(dd); mm = parseFloat(mm); yy = parseFloat(yy);
if (yy < 100) yy += 2000;
if (yy < 1582 || yy > 4881) return false;
if (mm == 2 && (yy%400 == 0 || (yy%4 == 0 && yy%100 != 0))) day[mm-1]++;
if (mm < 1 || mm > 12) return false;
if (dd < 1 || dd > day[mm-1]) return false;
t.setDate(dd); t.setMonth(mm-1); t.setFullYear(yy);
if (rng == 'p' || rng == 'P') {
if (t > today) return false;
}
else if (rng == 'f' || rng == 'F') {
if (t < today) return false;
}
else if (rng != 'a' && rng != 'A') return false;
return true;
}

/*Function to check phone validation in format 306-954-2548 or 3-306-954-2548 */
function validatePhone(id,disp)
{
	var title = '';
	if(trim(disp)!='')
		title = disp;
	else
		title = 'Phone';

	var decimalRE = /^\s*(\d{1}-\d{3}-\d{3}-\d{4}|\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;
	//var decimalRE = /^\s*(\d{1}-\d{3}-\d{3}-\d{4}|\(\d{1}\-\d{3}\) \d{3}-\d{4})\s*$/;
	if(trim($(id).value)=="")
		return true;
//	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	if(numTotal($(id).value)==0)
	{
		alertErrorMsg = title + " is not Valid.<br/>Please input in format like 306-954-2548 or 3-306-954-2548";
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		alertErrorMsg = title + " is not Valid.<br/>Please input in format like 306-954-2548 or 3-306-954-2548";
		return false;
	}
	return true;
}
	/*----------------------------------SUGGESTION EMAIL POPUP VALIDATION START--------------------------------- */
	var sugEmailPopup;
	function showSuggestionPopup()
	{	
		if($('emailPopupSuggestion'))
		{
			sugEmailPopup = createDialog('emailPopupSuggestion');		
			$('emailPopupSuggestion').style.display='block';
			if($('emailPopupSuggestion_c')) $('emailPopupSuggestion_c').style.zIndex='17';
			if($('emailPopupSuggestion_mask')) $('emailPopupSuggestion_mask').style.zIndex='16';
			if($('divContainerAdvanceSearch')) $('divContainerAdvanceSearch').style.zIndex='15';
			sugEmailPopup.show();			
			$('errEmailPro').innerHTML = '';
			$('txtComments').className = ''; $('txtComments').value = '';
			$('txtEmail').className = ''; $('txtEmail').value = '';
			$('txtName').className = ''; $('txtName').value = '';
			$('errEmailPro').innerHTML = '';
			$('sent').value = '0';

			//hide all related zindex specific div related to BUG# 10875
			if($("powerAdvSearch")) $("powerAdvSearch").style.display = "none";
			if($("divSaveSearch")) $("divSaveSearch").style.display = "none";
			if($("prpTyp")) $("prpTyp").style.display = "none";
			if($("prpStat")) $("prpStat").style.display = "none";
			if($("trSaleDate")) $("trSaleDate").style.display = "none";

			if(typeof(spl)!= "undefined")
			{	if(!spl)
				{
					hideMapList();	
					hidePwrsrchrel();
				}
			}
			
			//related to the bug specific to suggestion box;
			//Hide ProListing DIV
			if($('mapDiv') && $('mapDiv').style.display!='none')
			{
				if($("proListingDiv")){$("proListingDiv").style.display="none";}
			}
			//hide all related zindex specific div
		}
	}
	function sendSuggestion()
	{
		if($('sent').value == '0')
		{
			$('errEmailPro').innerHTML = '';
			$('txtComments').className = '';
			$('txtEmail').className = '';
			$('txtName').className = '';
			$('errEmailPro').innerHTML = '';			
			var sent = false;
			var comments = trim($('txtComments').value);
			var name = trim($('txtName').value);
			var email = trim($('txtEmail').value);
			var specialchars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?``";


			if(name)
			{
				var fName = name;
				for (var charNo = 0; charNo < fName.length; charNo++) 
				{
					if (specialchars.indexOf(fName.charAt(charNo)) != -1)
					{
						errorMsg = "Name should not contain special characters.";
						$('errEmailPro').innerHTML = errorMsg;
						$('txtName').className 	= "textboxRed";
						$('txtName').focus();
						return false ;	  				
					}
				}
			}
			
			if(email != '' && !emailIsValid("txtEmail"))
			{
				$('errEmailPro').innerHTML = "Please specify valid email.";
				$('txtEmail').focus();
				$('txtEmail').className="textboxRed";
				return false;
			}
			if(comments == '')
			{
				$('errEmailPro').innerHTML = "Please specify suggestions.";
				$('txtComments').focus();
				$('txtComments').className="textboxRed";
				return false;
			}
			if(comments)
			{			
				var specialchars = "#%^()+=[]\\\'/{}|\"<>``";
				for (var charNo = 0; charNo < comments.length; charNo++) 
				{
					if (specialchars.indexOf(comments.charAt(charNo)) != -1)
					{
						errorMsg = "Suggestions should not contain special characters.";
						$('errEmailPro').innerHTML = errorMsg;
						$('txtComments').className 	= "textboxRed";
						$('txtComments').focus();
						return false ;	  				
					}
				}
			}
			$('sent').value = '1';
			var url = "/app/listing/singlePropertyLandingNew.php";
			var qs = "action=suggestion&name="+name+"&email="+email+"&comments="+encodeURI(comments);
			ajaxRequest(url,qs,function(reqobj)
			{ 
				var varResponse = trim(reqobj.responseText);	
				if(varResponse == '1')
				{
					$('errEmailPro').innerHTML = "Your suggestions have been sent successfully.";
					$('txtComments').value = '';
					$('txtName').value = '';
					$('txtEmail').value = '';
					$('sent').value = '0';
				}
				else
				{
					$('errEmailPro').innerHTML = "Problem in email sending.";					
					$('sent').value = '0';
				}
				setTimeout('sugEmailPopup.hide();',800);
			});
		}
	}

	function atPropContactUs(fromPage, fromTitle, fromUrl)
	{
		var myQs = new Querystring();
		var frm = myQs.get("frm");
		var aid = myQs.get("aid");

		$('txtName').style.border="solid 1px #7F9DB9";
		$('txtFromEmail').style.border="solid 1px #7F9DB9";

		if(!isBlank('txtName','Full Name'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtName').style.border="solid 1px red";
			return false;
		}
		else if(!emailIsValid('txtFromEmail'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtFromEmail').style.border="solid 1px red";
			return false;
		}		
		if($F('txtPhone') != "")
		{
			var id = 'txtPhone';
			var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;			
			if(numTotal($(id).value)==0)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				return false;				
			}
			if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				return false;
			}				
		}

		if(agtContact != "")
			agtContact = "&agtContact="+agtContact;
		
		var qry = "name="+$('txtName').value+"&email="+$('txtFromEmail').value+"&phone="+$('txtPhone').value+"&comment="+escape($('txtComments').value)+"&sendMail=1"+agtContact;	

		if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
		{
			qry += "&aid="+aid;
		}
		try
		{
			var strSearchCriteria = getSearchCriteriaStringForEmail();
			qry = qry + "&searchCriteria="+escape(encodeURI(strSearchCriteria));
		}
		catch (ex)
		{
			// Do Nothing
		}

		if (fromPage != null && fromPage != 'undefined')
			qry += "&from_page="+fromPage;
		if (fromTitle != null && fromTitle != 'undefined')
			qry += "&from_title="+escape(fromTitle);
		if (fromUrl != null && fromUrl != 'undefined')
			qry += "&from_url="+escape(fromUrl);

		var url = "/help/atproperties/ContactUs.php";
		ajaxRequest(url,qry,function(reqobj)
		{ 
			var varResponse = trim(reqobj.responseText);	
			if(varResponse == '1')
			{
				alert("Your information have been sent successfully.");
				$('errPublish').innerHTML = "";
				$('txtFromEmail').value = "";
				$('txtName').value = "";
				$('txtPhone').value = "";
				$('txtComments').value = "";
				window.close();
			}
			else
				alert("Problem in email sending.");
		});		
	}
 /*----------------------------------SUGGESTION EMAIL POPUP VALIDATION END--------------------------------- */

	function illustratedContactUs(fromPage, fromTitle, fromUrl)
	{
		var myQs = new Querystring();
		var frm = myQs.get("frm");
		var aid = myQs.get("aid");

		if(!isBlank('txtName','Full Name'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtName').style.border="solid 1px red";
			return false;
		}
		else
		{
			$('txtName').style.border="";
			$('txtName').className = "ipboxes";
			$('errPublish').html = "";
		}
		
		if(!emailIsValid('txtFromEmail'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtFromEmail').style.border="solid 1px red";
			return false;
		}
		else
		{
			$('txtFromEmail').style.border="";
			$('txtFromEmail').className = "ipboxes";
			$('errPublish').html = "";
		}

		if($F('txtPhone') != "")
		{
			var id = 'txtPhone';
			var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;			
			if(numTotal($(id).value)==0)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				$('txtPhone').style.border="solid 1px red";
				return false;				
			}
			else if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				$('txtPhone').style.border="solid 1px red";
				return false;
			}	
			else
			{
				$('txtPhone').style.border="";
				$('txtPhone').className = "ipboxes";
				$('errPublish').html = "";
			}
		}
		else
		{
			$('txtPhone').style.border="";
			$('txtPhone').className = "ipboxes";
			$('errPublish').html = "";
		}

		if(agtContact != "")
			agtContact = "&agtContact="+agtContact;
		
		var qry = "name="+$('txtName').value+"&email="+$('txtFromEmail').value+"&phone="+$('txtPhone').value+"&comment="+escape($('txtComments').value)+"&sendMail=1"+agtContact;	

		if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
		{
			qry += "&aid="+aid;
		}

		try
		{
			var strSearchCriteria = getSearchCriteriaStringForEmail();
			qry = qry + "&searchCriteria="+escape(encodeURI(strSearchCriteria));
		}
		catch (ex)
		{
			// Do Nothing
		}

		if (fromPage != null && fromPage != 'undefined')
			qry += "&from_page="+fromPage;
		if (fromTitle != null && fromTitle != 'undefined')
			qry += "&from_title="+escape(fromTitle);
		if (fromUrl != null && fromUrl != 'undefined')
			qry += "&from_url="+escape(fromUrl);

		var url = "/help/illustrated/ContactUs.php";
		ajaxRequest(url,qry,function(reqobj)
		{ 
			var varResponse = trim(reqobj.responseText);	
			if(varResponse == '1')
			{
				alert("Your information has been sent successfully.");
				$('errPublish').innerHTML = "";
				$('txtFromEmail').value = "";
				$('txtName').value = "";
				$('txtPhone').value = "";
				$('txtComments').value = "";
				window.close();
			}
			else
				alert("Problem in email sending.");
		});		
	}

	function illustratedCarrier()
	{
		var myQs = new Querystring();
		var frm = myQs.get("frm");
		var aid = myQs.get("aid");

		if(!isBlank('txtName','Full Name'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtName').style.border="solid 1px red";
			return false;
		}
		else
		{
			$('txtName').style.border="";
			$('txtName').className = "ipboxes";
			$('errPublish').html = "";
		}
		
		if(!emailIsValid('txtFromEmail'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtFromEmail').style.border="solid 1px red";
			return false;
		}
		else
		{
			$('txtFromEmail').style.border="";
			$('txtFromEmail').className = "ipboxes";
			$('errPublish').html = "";
		}

		if(!isBlank('txtPhone','Phone'))
		{
			$('errPublish').innerHTML = alertErrorMsg;
			$('txtPhone').style.border="solid 1px red";
			return false;
		}
		else if($F('txtPhone') != "")
		{
			var id = 'txtPhone';
			var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;			
			if(numTotal($(id).value)==0)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				$('txtPhone').style.border="solid 1px red";
				return false;				
			}
			else if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
			{
				alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
				$('errPublish').innerHTML = alertErrorMsg;
				$('txtPhone').style.border="solid 1px red";
				return false;
			}	
			else
			{
				$('txtPhone').style.border="";
				$('txtPhone').className = "ipboxes";
				$('errPublish').html = "";
			}
		}
		else
		{
			$('txtPhone').style.border="";
			$('txtPhone').className = "ipboxes";
			$('errPublish').html = "";
		}

		if(agtContact != "")
			agtContact = "&agtContact="+agtContact;
		
		var qry = "name="+$('txtName').value+"&email="+$('txtFromEmail').value+"&phone="+$('txtPhone').value+"&comment="+escape($('txtComments').value)+"&sendMail=1"+agtContact;	

		if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
		{
			qry += "&aid="+aid;
		}

		var url = "/help/illustrated/carrier.php";
		ajaxRequest(url,qry,function(reqobj)
		{ 
			var varResponse = trim(reqobj.responseText);	
			if(varResponse == '1')
			{
				alert("Your information has been sent successfully.");
				$('errPublish').innerHTML = "";
				$('txtFromEmail').value = "";
				$('txtName').value = "";
				$('txtPhone').value = "";
				$('txtComments').value = "";
				window.close();
			}
			else
				alert("Problem in email sending.");
		});		
	}

/* function for home valuation */
function isValidNumber(val){
	  if(val==null){return false;}
	  if (val.length==0){return false;}
	  var DecimalFound = false;
	  for (var i = 0; i < val.length; i++) {
			var ch = val.charAt(i);
			if (i == 0 && ch == "-") {
				  continue;
			}
			if (ch == "." && !DecimalFound) {
				  DecimalFound = true;
				  continue;
			}
			if (ch < "0" || ch > "9") {
				  return false;
			}
	  }
	  return true;
}

function addLeadFrmHomeValuation()
{
	$('errLeadProSelect').innerHTML = "";	
	$('txtConsEmailSelect').className = "";
	$('txtConsPhoneSelect').className = "";
	$('txtConsAddressSelect').className = "";
	$('txtConsCitySelect').className = "";
	$('txtConsStateSelect').className = "";
	$('txtConsZipSelect').className = "";

	$('txtConsBedsSelect').className = "";
	$('txtConsBathsSelect').className = "";
	$('txtConsSqftSelect').className = "";
	$('txtConsYearbuiltSelect').className = "";

	if(trim($('txtConsEmailSelect').value) == '')
	{
		errorMsg = "Please Enter Email.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsEmailSelect').className 	= "textboxRed";
		$('txtConsEmailSelect').focus();
		return false;
	}

	if(trim($('txtConsPhoneSelect').value) != '')
	{
		if(!validatePhone("txtConsPhoneSelect"))
		{
		    errorMsg = "Phone is not Valid.<br/>Please input in format like 306-954-2548.";
			$('errLeadProSelect').innerHTML =  errorMsg;
			$('txtConsPhoneSelect').className = "textboxRed";
			$('txtConsPhoneSelect').focus();
			return false;
		}
	}

	if(!emailIsValid("txtConsEmailSelect"))
	{
		errorMsg = "Please Enter Valid Email.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsEmailSelect').className 	= "textboxRed";
		$('txtConsEmailSelect').focus();
		
		return false;
	}

	if(trim($('txtConsAddressSelect').value)== "")
	{
		errorMsg = "Please Enter Address.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsAddressSelect').className = "textboxRed";
		$('txtConsAddressSelect').focus();
		return false;
	
	}

	if(trim($('txtConsCitySelect').value)== "")
	{
		errorMsg = "Please Enter City.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsCitySelect').className = "textboxRed";
		$('txtConsCitySelect').focus();
		return false;
	
	}

	if(trim($('txtConsStateSelect').value)== "")
	{
		errorMsg = "Please Enter State.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsStateSelect').className = "textboxRed";
		$('txtConsStateSelect').focus();
		return false;
	
	}

	if(trim($('txtConsZipSelect').value)== "")
	{
		errorMsg = "Please Enter Zip.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsZipSelect').className = "textboxRed";
		$('txtConsZipSelect').focus();
		return false;
	
	}
	if(!isNumeric($('txtConsZipSelect').value))
	{
		errorMsg = "Please Enter Valid Zip.";
		$('errLeadProSelect').innerHTML = errorMsg;
		$('txtConsZipSelect').className = "textboxRed";
		$('txtConsZipSelect').focus();
		return false;
	}

	if($("txtConsBedsSelect").value != "" && !isValidNumber($("txtConsBedsSelect").value))
	{
		$('errLeadProSelect').innerHTML = 'Please enter valid numeric value for Bedroom.';
		$('txtConsBedsSelect').className = "textboxRed";
		$('txtConsBedsSelect').focus();
		return false;
	}
	if($("txtConsBathsSelect").value != "" && !isValidNumber($("txtConsBathsSelect").value))
	{
		$('errLeadProSelect').innerHTML = 'Please enter valid numeric value for Bathroom.';
		$('txtConsBathsSelect').className = "textboxRed";
		$('txtConsBathsSelect').focus();
		return false;
	}
	if($("txtConsSqftSelect").value != "" && !isValidNumber($("txtConsSqftSelect").value))
	{
		$('errLeadProSelect').innerHTML = 'Please enter valid numeric value for Sq. Ft.'; 
		$('txtConsSqftSelect').className = "textboxRed";
		$('txtConsSqftSelect').focus();
		return false;
	}
	if($("txtConsYearbuiltSelect").value != "" && !isNumeric($("txtConsYearbuiltSelect").value))
	{
		$('errLeadProSelect').innerHTML = 'Please enter valid numeric value for Year Built.'; 
		$('txtConsYearbuiltSelect').className = "textboxRed";
		$('txtConsYearbuiltSelect').focus();
		return false;
	}

	var queryString="";
	var userType;
	queryString = "" ;
	
	if(trim($('txtConsNameSelect').value) != "")
		{queryString += "&name="+trim($('txtConsNameSelect').value);}

	if(trim($('txtConsPhoneSelect').value) != "")
		{queryString += "&phone="+trim($('txtConsPhoneSelect').value)}

	queryString +="&email="+trim($('txtConsEmailSelect').value)+"&address="+escape(encodeURI(trim($("txtConsAddressSelect").value)))+"&city="+trim($("txtConsCitySelect").value)+"&state="+trim($("txtConsStateSelect").value)+"&zip="+trim($("txtConsZipSelect").value);

	if(trim($("txtConsCommentsSelect").value) != "")
		{queryString += "&comments="+trim(escape($("txtConsCommentsSelect").value));}

	queryString+="&leadStatus=N";
	
	queryString += "&beds="+trim($('txtConsBedsSelect').value);
	queryString += "&baths="+trim($('txtConsBathsSelect').value);
	queryString += "&sqft="+trim($('txtConsSqftSelect').value);
	queryString += "&yearbuilt="+trim($('txtConsYearbuiltSelect').value);
	
	var objQs = new Querystring();
	var ouid = objQs.get('ouid');	
	var aid = objQs.get('aid');	
	if(aid!=null && trim(aid)!= '')
	{
		queryString = queryString+ "&frm=agt";
		queryString = queryString+ "&aid="+aid;
	}
	else if(ouid!=null && trim(ouid)!= '')
	{
		queryString = queryString+ "&frm=frch";
		queryString = queryString+ "&ouid="+ouid;
	}
	else
		queryString = queryString+ "&frm=bk";

	if($('propType'))
	{
		if($('propType').selectedIndex == 0)
			queryString+= "&propType=";
		else
			queryString+= "&propType="+$('propType').value.replace (/\'/g, '');
	}
	else
		queryString+= "&propType=";

	queryString+= "&sendMail=1";

	var url = "/help/illustrated/valueMyHome.php";

	ajaxRequest(url,queryString,function(originalResponse){
		var res = 	 originalResponse.responseText;
		if(res == '1')
		{
			alert('Your request has been submitted successfully.');
			$('txtConsNameSelect').value = "";
			$('txtConsEmailSelect').value = "";
			$('txtConsPhoneSelect').value = "";
			$('txtConsAddressSelect').value = "";
			$('txtConsCitySelect').value = "";
			$('txtConsStateSelect').value = "";
			$('txtConsZipSelect').value = "";
			$('txtConsBedsSelect').value = "";
			$('txtConsBathsSelect').value = "";
			$('txtConsSqftSelect').value = "";
			$('txtConsYearbuiltSelect').value = "";
			$('txtConsCommentsSelect').value = "";
			$('propType').selectedIndex = 0;
		}
		else
		{
			alert('There is an error while submitting your request.!!');
			return false;
		}		
	});
}

/*cookieFun.js*/

var YAHOO;
var isIE = document.all?1:0;
var isIE6 = (window.XMLHttpRequest)?0:1;
var usrAgt = navigator.userAgent.toLowerCase();
var isFF = (usrAgt.indexOf('firefox')!=-1)?1:0;
var isOpera = (usrAgt.indexOf('opera')!=-1)?1:0;
var isSafari = ((usrAgt.indexOf('safari')!=-1)&&(usrAgt.indexOf('mac')!=-1))?1:0;
var savedSearch="";


if(typeof(document.getElementsByClassName)!="function")
{
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++)
{
var classes = elem[i].className;
if (myclass.test(classes))
retnode.push(elem[i]);
}
return retnode;
};
}

/**
 * Function that sets the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} value of the cookie
 * @param {String} expires expiry time for the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @param {String} secure Secure cookie (SSL)
 */
function setCookie(name, value, expires, path, domain, secure)
{
	//alert(name+" "+value);
	if (name == "msgboxCK" || name == "msgboxCKSignin" || name == "msgboxtutorialcook" || name == "rememberIdPassword" || name == "Cpanel_rememberIdPassword" || name == "pv" || name == "strWidgetCookie")
	{
		if (expires)
		{
			expires = expires.toGMTString();
		}
	}
	else
		expires = null;

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "; path=/") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
};

/**
 * Function that gets the cookie value for given name.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @return (String) returns the value for the given cookie name.
 */
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} 
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	var returnCookie = unescape(dc.substring(begin + prefix.length, end));
	if((returnCookie == null) || (returnCookie == 'null'))
	{
		returnCookie = "";
	}

	return returnCookie;
	
};

/**
 * Function that deletes the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @return (void)
 */
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" + ((path) ? "; path=" + path : "path=/") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


function setShareBtnStyle()
{
        if(!document.getElementsByClassName('stbuttontext')[0] || !document.getElementsByClassName('stbutton')[0])
			setTimeout('setShareBtnStyle',5000);
        else
        {
                if(document.getElementsByClassName('stbuttontext'))
				{
					document.getElementsByClassName('stbuttontext')[0].style.top="-1";
					document.getElementsByClassName('stbuttontext')[0].style.left="-3";
					document.getElementsByClassName('stbuttontext')[0].style.fontWeight="bold";
				}
				if(document.getElementsByClassName('stbutton'))
				{
					document.getElementsByClassName('stbutton')[0].style.textDecoration="none";
				}
        }
}