var zXml={useActiveX:(typeof ActiveXObject!="undefined"),useDom:document.implementation&&document.implementation.createDocument,useXmlHttp:(typeof XMLHttpRequest!="undefined")};zXml.ARR_XMLHTTP_VERS=["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp","Microsoft.XmlHttp"];zXml.ARR_DOM_VERS=["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"];;function zXmlHttp(){}zXmlHttp.createRequest=function(){if(zXml.useXmlHttp){return new XMLHttpRequest();}else if(zXml.useActiveX){if(!zXml.XMLHTTP_VER){for(var i=0;i<zXml.ARR_XMLHTTP_VERS.length;i++){try{new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);zXml.XMLHTTP_VER=zXml.ARR_XMLHTTP_VERS[i];break;}catch(oError){;}}}if(zXml.XMLHTTP_VER){return new ActiveXObject(zXml.XMLHTTP_VER);}else{throw new Error("Could not create XML HTTP Request.");}}else{throw new Error("Your browser doesn't support an XML HTTP Request.");}};zXmlHttp.isSupported=function(){return zXml.useXmlHttp||zXml.useActiveX;};function zXmlDom(){}zXmlDom.createDocument=function(){if(zXml.useDom){var oXmlDom=document.implementation.createDocument("","",null);oXmlDom.parseError={valueOf:function(){return this.errorCode;},toString:function(){return this.errorCode.toString()}};oXmlDom.__initError__();oXmlDom.addEventListener("load",function(){this.__checkForErrors__();this.__changeReadyState__(4);},false);return oXmlDom;;}else if(zXml.useActiveX){if(!zXml.DOM_VER){for(var i=0;i<zXml.ARR_DOM_VERS.length;i++){try{new ActiveXObject(zXml.ARR_DOM_VERS[i]);zXml.DOM_VER=zXml.ARR_DOM_VERS[i];break;}catch(oError){;}}}if(zXml.DOM_VER){return new ActiveXObject(zXml.DOM_VER);}else{throw new Error("Could not create XML DOM document.");}}else{throw new Error("Your browser doesn't support an XML DOM document.");}};zXmlDom.isSupported=function(){return zXml.useDom||zXml.useActiveX;};var oMozDocument=null;if(typeof XMLDocument!="undefined"){oMozDocument=XMLDocument;}else if(typeof Document!="undefined"){oMozDocument=Document;}if(oMozDocument&&!window.opera){oMozDocument.prototype.readyState=0;oMozDocument.prototype.onreadystatechange=null;oMozDocument.prototype.__changeReadyState__=function(iReadyState){this.readyState=iReadyState;if(typeof this.onreadystatechange=="function"){this.onreadystatechange();}};oMozDocument.prototype.__initError__=function(){this.parseError.errorCode=0;this.parseError.filepos=-1;this.parseError.line=-1;this.parseError.linepos=-1;this.parseError.reason=null;this.parseError.srcText=null;this.parseError.url=null;};oMozDocument.prototype.__checkForErrors__=function(){if(this.documentElement.tagName=="parsererror"){var reError=/>([\s\S]*?)Location:([\s\S]*?)Line Number(\d+),Column(\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;reError.test(this.xml);this.parseError.errorCode=-999999;this.parseError.reason=RegExp.$1;this.parseError.url=RegExp.$2;this.parseError.line=parseInt(RegExp.$3);this.parseError.linepos=parseInt(RegExp.$4);this.parseError.srcText=RegExp.$5;}};oMozDocument.prototype.loadXML=function(sXml){this.__initError__();this.__changeReadyState__(1);var oParser=new DOMParser();var oXmlDom=oParser.parseFromString(sXml,"text/xml");while(this.firstChild){this.removeChild(this.firstChild);}for(var i=0;i<oXmlDom.childNodes.length;i++){var oNewNode=this.importNode(oXmlDom.childNodes[i],true);this.appendChild(oNewNode);}this.__checkForErrors__();this.__changeReadyState__(4);};oMozDocument.prototype.__load__=oMozDocument.prototype.load;oMozDocument.prototype.load=function(sURL){this.__initError__();this.__changeReadyState__(1);this.__load__(sURL);};Node.prototype.__defineGetter__("xml",function(){var oSerializer=new XMLSerializer();return oSerializer.serializeToString(this,"text/xml");});Node.prototype.__defineGetter__("text",function(){var sText="";for(var i=0;i<this.childNodes.length;i++){if(this.childNodes[i].hasChildNodes()){sText+=this.childNodes[i].text;}else{sText+=this.childNodes[i].nodeValue;}}return sText;});}function zXslt(){}zXslt.transformToText=function(oXml,oXslt){if(typeof XSLTProcessor!="undefined"){var oProcessor=new XSLTProcessor();oProcessor.importStylesheet(oXslt);var oResultDom=oProcessor.transformToDocument(oXml);var sResult=oResultDom.xml;if(sResult.indexOf("<transformiix:result")>-1){sResult=sResult.substring(sResult.indexOf(">")+1,sResult.lastIndexOf("<"));}return sResult;;}else if(zXml.useActiveX){return oXml.transformNode(oXslt);}else{throw new Error("No XSLT engine found.");}};function zXPath(){}zXPath.selectNodes=function(oRefNode,sXPath,sXmlNs){if(typeof XPathEvaluator!="undefined"){oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var aNodes=new Array;if(oResult!=null){var oElement=oResult.iterateNext();while(oElement){aNodes.push(oElement);oElement=oResult.iterateNext();}}return aNodes;}else if(zXml.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectNodes(sXPath);}else{throw new Error("No XPath engine found.");}};zXPath.selectSingleNode=function(oRefNode,sXPath,oXmlNs){if(typeof XPathEvaluator!="undefined"){;oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(oResult!=null){return oResult.singleNodeValue;}else{return null;};}else if(zXML.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectSingleNode(sXPath);}else{throw new Error("No XPath engine found.");}};function zXMLSerializer(){}zXMLSerializer.prototype.serializeToString=function(oNode){var sXml="";switch(oNode.nodeType){case 1:sXml="<"+oNode.tagName;for(var i=0;i<oNode.attributes.length;i++){sXml+=" "+oNode.attributes[i].name+"=\""+oNode.attributes[i].value+"\"";}sXml+=">";for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}sXml+="</"+oNode.tagName+">";break;case 3:sXml=oNode.nodeValue;break;case 4:sXml="<![CDATA["+oNode.nodeValue+"]]>";break;case 7:sXml="<?"+oNode.nodevalue+"?>";break;case 8:sXml="<!--"+oNode.nodevalue+"-->";break;case 9:for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}break;};return sXml;};
var ns = (navigator.appName.indexOf("Netscape") != -1);
var reEmail = /(^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$)|(^$)/;
var rePhone = /^[0-9]{10}$/;
var reZip = /^[0-9]{5}$/;
var myImage = 0;
var thisID = 0;
var uid = 0;

function cleanPhone(str) {
	return str.replace(/\(/g,"").replace(/\)/g,"").replace(/-/g,"").replace(/\ /g,"").replace(/\./,"");
}

function OpenLink(URL,popW,popH) {
	if (ns) {
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	} else {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	//var popW = 750, popH = 600;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	var win = null;
	win = window.open(URL, 'PopUp', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	win.focus();
}

function encodeMyHtml(str) {
	encodedHtml = escape(str);
	encodedHtml = encodedHtml.replace(/\//g,"%2F");
	encodedHtml = encodedHtml.replace(/\?/g,"%3F");
	encodedHtml = encodedHtml.replace(/=/g,"%3D");
	encodedHtml = encodedHtml.replace(/&/g,"%26");
	encodedHtml = encodedHtml.replace(/@/g,"%40");
	return (encodedHtml);
}

function LogImpression() {
	bug = new Image(); 
	bug.src = '/ajax.asp?Action=LogImpression&ImpressionURL=' + encodeMyHtml(window.location) + '&Referrer=' + encodeMyHtml(document.referrer) + '&UID=' + uid + '&' + Math.random();
}

function LogADClick(ADID) {
	bug = new Image(); 
	bug.src = '/ajax.asp?Action=LogADClick&ImpressionURL=' + encodeMyHtml(window.location) + '&Referrer=' + encodeMyHtml(document.referrer) + '&ADID=' + ADID + '&UID=' + uid + '&' + Math.random();
}

function SetCookie(cookieName,cookieValue) {
	var today = new Date();
	var expires_date = new Date(today.getTime() + 2592000000); //86400000 = 24h
	document.cookie = cookieName + "=" + cookieValue + "; expires=" + expires_date.toGMTString() + "; path=/;";
}

function GetCookie(cookieName) {
	var start = document.cookie.indexOf( cookieName + "=" );
	var len = start + cookieName.length + 1;
	if ( ( !start ) && ( cookieName != document.cookie.substring( 0, cookieName.length ) ) ) { return null; }
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function KillCookie(cookieName) {
	var kill_date = new Date("1 January, 1970");
	document.cookie = cookieName + "=;expire= "+ kill_date.toGMTString();
}

function getFeaturedListings(Page,Location,Distance,add2Map,style){
	var resObj = document.getElementById("FeaturedListings");
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/FeaturedListings.asp?Page=" + escape(Page) + "&Location=" + escape(Location) + "&Distance=" + escape(Distance) + "&add2Map=" + escape(add2Map) + "&style=" + escape(style) + "&" + Math.random(), true);
        oHttp.onreadystatechange = function () {
            if (oHttp.readyState == 4) {
                if(oHttp.responseText != '') {
					resObj.innerHTML=oHttp.responseText;
					if(document.getElementById("newMapPoints").innerHTML != '' && add2Map){
						document.getElementById("MapiFrame").src="/map.asp?initMap=" + document.getElementById("initMap").innerHTML + "&MapPoints=" + escape(document.getElementById("MapPoints").innerHTML) + "&newMapPoints=" + escape(document.getElementById("newMapPoints").innerHTML) + "&" + Math.random();
					}
				}
            }
        };
        oHttp.send("");
}
var currentSuggest = 0;
var MaxSuggest = 0;
function suggest(obj,e){
	var resObj = document.getElementById("ajaxResults");
	if (obj.value != '' && e.keyCode != 38 && e.keyCode != 40){
		resObj.innerHTML="";
		var oHttp = zXmlHttp.createRequest();
		oHttp.open("get", "/ajax.asp?Action=" + obj.id + "&Keyword=" + escape(obj.value) + "&" + Math.random(), true);
		oHttp.onreadystatechange = function () {
									if (oHttp.readyState == 4) {
								    	if(oHttp.responseText != '') {
											resObj.innerHTML=""; //clear contents of the layer
											currentSuggest = -1;
								        	var Suggestions = eval(oHttp.responseText);
											MaxSuggest = Suggestions.length;
											var what = obj.value.split(" ");
											var matches = new Array();
								        	for (var i = 0; i < Suggestions.length; i++) {
												//Play with the Suggestion to highlight the words that macth words in our array splitting on spaces.
												matches[0]=[0];
												matches[1]=[0];
												Suggestion = Suggestions[i].toString().split(" ");
												for (var j=0; j < what.length; j++) {
													for (var k=0; k < Suggestion.length; k++) {
														if (what[j] != "" && what[j].toLowerCase() == Suggestion[k].toLowerCase().substring(0,what[j].length) && Suggestion[k] != ""){
															matches[0][k] = 1;
															matches[1][k] = what[j].length;
														}
													}
												}
												var myhtml = "";
												for (var k=0; k < Suggestion.length; k++) {
													if (matches[0][k] == 1){
														myhtml += "<font style='color:#FF0000;FONT-WEIGHT:bold;'>" + Suggestion[k].substring(0,matches[1][k]) + "</font>" + Suggestion[k].substring(matches[1][k],Suggestion[k].length) + " ";
													} else {
														if (k==Suggestion.length - 1) {
															myhtml += Suggestion[k]; 
														} else {
															myhtml += Suggestion[k] + " ";  
														}
													}
												}
												if(myhtml == "") { myhtml = Suggestions[i]; }
												//output div
								                var divTag = document.createElement("div");
										        divTag.onmouseover=function (){this.className = "current";}
												divTag.onmouseout=function (){this.className = "";}
										        divTag.setAttribute("RealVal", Suggestions[i]);
												divTag.setAttribute("id", "suggestRes" + i);
												divTag.style.borderBottom = '1px dotted Black';
												divTag.style.paddingTop = '4px';
												divTag.style.paddingBottom = '4px';
												divTag.onclick=function (){obj.value = this.getAttribute("RealVal"); hide();}
												divTag.innerHTML = myhtml;
												resObj.appendChild(divTag);
								            }
											resObj.style.top=document.getElementById(obj.id + "Link").offsetTop + "px";
											resObj.style.left=document.getElementById(obj.id + "Link").offsetLeft + "px";
											resObj.style.width=obj.offsetWidth + "px";
											resObj.style.display="block";
										}
									}
								};
               oHttp.send("");
	} else if ((e.keyCode == 38 || e.keyCode == 40) && resObj.style.display=="block" && resObj.innerHTML != ""){
	
		var h = resObj.scrollHeight; // height of div scroll
		var y = resObj.scrollTop; // vertical scroll offset from top (of scrollHeight)
		var c = resObj.clientHeight; // scroll bar height
		var scrollBottom = h - (y + c); // offset of scroll from bottom

		if(e.keyCode == 38) {
			//up arrow
			if(currentSuggest > 0){
				document.getElementById("suggestRes" + currentSuggest).className = "";
				currentSuggest--
				document.getElementById("suggestRes" + currentSuggest).className = "current";
				resObj.scrollTop=(MaxSuggest / 3.3) * currentSuggest;
				obj.value = document.getElementById("suggestRes" + currentSuggest).getAttribute("RealVal");
			}
		} else if(e.keyCode == 40) {
			//down arrow
			if(currentSuggest >= -1 && currentSuggest < MaxSuggest -1){
				if(currentSuggest >= 0){
					document.getElementById("suggestRes" + currentSuggest).className = "";
				}
				currentSuggest++
				document.getElementById("suggestRes" + currentSuggest).className = "current";
				resObj.scrollTop=(MaxSuggest / 3.3) * currentSuggest;
				obj.value = document.getElementById("suggestRes" + currentSuggest).getAttribute("RealVal");
			}
		}
	} else {
	    hide();
	}
}

function hide(){
	var resObj = document.getElementById("ajaxResults");
        resObj.innerHTML="";
		resObj.style.display="none";
}

function centerDivPopUp(){
	var resObj = document.getElementById("divbox");
	if (document.getElementById && !document.all){
		var IpopTop = ((window.innerHeight - resObj.offsetHeight)/2) + window.pageYOffset;
		var IpopLeft = ((window.innerWidth - resObj.offsetWidth)/2) + window.pageXOffset;
	} else {
		var IpopTop = ((document.body.clientHeight - resObj.offsetHeight)/2) + document.body.scrollTop;
		var IpopLeft = ((document.body.clientWidth - resObj.offsetWidth)/2) + document.body.scrollLeft;
	}
	if(IpopTop - 40 > 5){IpopTop=IpopTop-40;}else{IpopTop=5;}
	resObj.style.top=IpopTop + "px";
	resObj.style.left=IpopLeft + "px";
}

function showImage(RCFEID,imageTypeID,direction,maxCnt,img){
	if(direction == 'previous'){
		if(myImage > 0){
			myImage--
		} else {
			myImage = maxCnt;
		}
	} else if(direction == 'next'){
		if(myImage < maxCnt){
			myImage++
		} else {
			myImage = 0;
		}
	}
	if(imageTypeID == 3){
		document.getElementById("largerImageDiv").innerHTML='<p align="center"><br><br><br><br><img src="/images/loading_blue_big.gif" alt="" border=0 name="largeFacilityImage"></p>';
	}
	var preLoadImage = new Image();
	preLoadImage.onload = function() {
										if(imageTypeID == 3){
											largerImageDiv.innerHTML='<img src="/image.asp?ID='+RCFEID+'&imageTypeID=3&Image='+myImage+'" alt="" border=0 name="largeFacilityImage">';
											getImageText(RCFEID,myImage,maxCnt,preLoadImage.height,1);
										}
									};
	preLoadImage.src = "/image.asp?ID=" + RCFEID + "&imageTypeID=" + imageTypeID + "&Image=" + myImage;
	document[img].src=preLoadImage.src;
}

function viewLargerImage(RCFEID,maxCnt){
	popupDiv('viewLargerImage');
	thisHtml = '<div align="center" style="height:25px;">';
	thisHtml += '<a href="#" onclick="showImage('+RCFEID+',\'3\',\'previous\','+maxCnt+',\'largeFacilityImage\');return false;"><img src="/images/previous.gif" alt="" border="0"></a>';
	thisHtml += '&nbsp;&nbsp;&nbsp;&nbsp;';
	thisHtml += '<span id="largerImagePositionSpan"></span>';
	thisHtml += '&nbsp;&nbsp;&nbsp;&nbsp;';
	thisHtml += '<a href="#" onclick="showImage('+RCFEID+',\'3\',\'next\','+maxCnt+',\'largeFacilityImage\');return false;"><img src="/images/next.gif" alt="" border="0"></a>';
	thisHtml += '</div>';
	thisHtml += '<div align="center" id="largerImageDiv" style="height:360px;">';
	thisHtml += '<img src="/image.asp?ID='+RCFEID+'&imageTypeID=3&Image='+myImage+'" alt="" border=0 name="largeFacilityImage">';
	thisHtml += '</div>';
	thisHtml += '<div align="center" style="height:25px;" id="ImageText"></div>';
	document.getElementById("popupContent").innerHTML=thisHtml;
	getImageText(RCFEID,myImage,maxCnt,document['largeFacilityImage'].height,0);
}

function getImageText(RCFEID,myImage,maxCnt,imgHeight,reSize){
	document.getElementById("ImageText").innerHTML="";
	document.getElementById("largerImagePositionSpan").innerHTML=(parseInt(myImage)+1) + ' of ' + (parseInt(maxCnt)+1);
	if(reSize){
		document.getElementById("largerImageDiv").style.height=(imgHeight + 20) + "px";
		document.getElementById("cashboxnew").style.height=(imgHeight + 150) + "px";
	}
	document['facilityImage'].src="/image.asp?ID=" + RCFEID + "&imageTypeID=2&Image=" + myImage;
	
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?ID="+RCFEID+"&Image="+myImage+"&Action=GetImageInfo&" + Math.random(), true);
        oHttp.onreadystatechange = function () {
            if (oHttp.readyState == 4) {
                if(oHttp.responseText != '') {
					document.getElementById("ImageText").innerHTML=oHttp.responseText;
				}
            }
        };
        oHttp.send("");
}

function login(){
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?Action=login&eMail=" + escape(document.getElementById("email").value) + "&Password=" + escape(document.getElementById("password").value) + "&" + Math.random(), true);
        oHttp.onreadystatechange = function () {
            if (oHttp.readyState == 4) {
                if(oHttp.responseText > 0){
					SetCookie("GetInfo",oHttp.responseText);
					checkLogin();
					document.getElementById("logInError").style.display="none";
					document.getElementById("logInError").innerHTML='';
					window.location.href="/myaccount.asp";
				} else {
					document.getElementById("logInError").style.display="block";
					document.getElementById("logInError").innerHTML='<b>Wrong username or password.</b><br>Please try again.';
				}
            }
        };
        oHttp.send("");
}

function closeError(){
	document.getElementById("PopupError").style.display="none";
	document.getElementById("PopupError").innerHTML='';
}

function validateForm(type){
	var run = 1;
	closeError();
	if(type == 1){
		if(document.getElementById("name").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Full Name must be filled out';
		} else if(document.getElementById("eMail").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address must be filled out';
		} else if(!document.getElementById("eMail").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email is not valid, please try again';
		} else if(document.getElementById("phone").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number must be filled out';
		} else if(!cleanPhone(document.getElementById("phone").value).match(rePhone)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number is not valid, please try again';
		}
	} else if(type == 2){
		if(document.getElementById("name").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Full Name must be filled out';
		} else if(document.getElementById("eMail").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address must be filled out';
		} else if(!document.getElementById("eMail").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email is not valid, please try again';
		} else if(document.getElementById("familyEmail").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Family Email address must be filled out';
		} else if(!document.getElementById("familyEmail").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Family Email is not valid, please try again';
		}
	} else if(type == 3){
		if(document.getElementById("eMail").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='eMail must not be blank';
		} else if(!document.getElementById("eMail").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address must be filled out';
		} else if(document.getElementById("password").value != document.getElementById("confrimPassword").value){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Your Password does not match the Confirm Password';
		} else if(document.getElementById("name").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Full Name must be filled out';
		} else if(document.getElementById("phone").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='phone must not be blank';
		} else if(!cleanPhone(document.getElementById("phone").value).match(rePhone)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number is not valid, please try again';
		} else if(document.getElementById("zip").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Zip Code must be filled out';
		} else if(!document.getElementById("zip").value.match(reZip)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Zip Code is not valid, please try again';
		} else if(document.getElementById("regAccept").checked == false){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='You must agree to the Terms of Use';
		}
	} else if(type == 4){
		if(document.getElementById("forgotPasswordEmail").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address must be filled out';
		} else if(!document.getElementById("forgotPasswordEmail").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address is not valid, please try again';
		}
	} else if(type == 5){
		if(document.getElementById("fullname").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Full Name must be filled out';
		} else if(document.getElementById("email").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email address must be filled out';
		} else if(!document.getElementById("email").value.match(reEmail)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Email is not valid, please try again';
		} else if(document.getElementById("phone").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number must be filled out';
		} else if(!cleanPhone(document.getElementById("phone").value).match(rePhone)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number is not valid, please try again';
		}
	} else if(type == 6){
		if(document.getElementById("Administrator").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Full Name must be filled out';
		} else if(document.getElementById("BestPhone").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number must be filled out';
		} else if(!cleanPhone(document.getElementById("BestPhone").value).match(rePhone)){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='Phone number is not valid, please try again';
		}
	} else if(type == 7){
		if(document.getElementById("combined_location_field").value == '' || document.getElementById("combined_location_field").value == '<img src=/images/spacer.gif width=25 height=1>Enter your City or Zip Code<img src=/images/spacer.gif width=10 height=1>'){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1>Enter your City or Zip Code<img src=/images/spacer.gif width=10 height=1>';
		} else if(document.getElementById("email").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1>Email address must be filled out<img src=/images/spacer.gif width=10 height=1>';
		} else if(document.getElementById("area_code").value == '' || document.getElementById("phone_one").value == '' || document.getElementById("phone_two").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1>Phone number must be filled out<img src=/images/spacer.gif width=10 height=1>';
		} else if(document.getElementById("name").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1>Your Name must not be blank<img src=/images/spacer.gif width=10 height=1>';
		} else if(document.getElementById("password").value == ''){
			run = 0;
			document.getElementById("PopupError").style.display="block";
			document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1>Password must not be blank<img src=/images/spacer.gif width=10 height=1>';
		}
	}

	if(run){
		return true;
	} else {
		return false;
	}
}

function saveInfo(action){
	if(action == 'login'){
		var oHttp = zXmlHttp.createRequest();
	        oHttp.open("get", "/ajax.asp?Action=login&eMail=" + escape(document.getElementById("loginEMail").value) + "&Password=" + escape(document.getElementById("loginPassword").value) + "&" + Math.random(), true);
	        oHttp.onreadystatechange = function () {
	            if (oHttp.readyState == 4) {
	                if(oHttp.responseText > 0){
						SetCookie("GetInfo",oHttp.responseText);
						popupDiv("hidden");
						checkLogin();
						checkFavorites(thisID,oHttp.responseText);
					} else {
						document.getElementById("logInPopupError").style.display="block";
						document.getElementById("logInPopupError").innerHTML='<strong>Wrong username or password.</strong><br> Please try again.<br>';
					}
	            }
	        };
	        oHttp.send("");
	} else if(action == 'reg'){
		var run = 1;
		if(document.getElementById("regEMail").value == '' || document.getElementById("regPassword").value == '' || document.getElementById("regFullName").value == '' || document.getElementById("regResidentName").value == '' || document.getElementById("regPhone").value == ''){
			run = 0;
			document.getElementById("regPopupError").style.display="block";
			document.getElementById("regPopupError").innerHTML='Please fill out all fields';
		} else if(!document.getElementById("regEMail").value.match(reEmail)){
			run = 0;
			document.getElementById("regPopupError").style.display="block";
			document.getElementById("regPopupError").innerHTML='The email address is not valid';
		} else if(!cleanPhone(document.getElementById("regPhone").value).match(rePhone)){
			run = 0;
			document.getElementById("regPopupError").style.display="block";
			document.getElementById("regPopupError").innerHTML='The phone number is not valid';
		} else if(document.getElementById("regAccept").checked == false){
			run = 0;
			document.getElementById("regPopupError").style.display="block";
			document.getElementById("regPopupError").innerHTML='You must agree to the Terms of Use';
		}
		
		if(run){
			var oHttp = zXmlHttp.createRequest();
		        oHttp.open("get", "/ajax.asp?Action=reg&eMail=" + escape(document.getElementById("regEMail").value) + "&Password=" + escape(document.getElementById("regPassword").value) + "&FullName=" + escape(document.getElementById("regFullName").value) + "&ResidentName=" + escape(document.getElementById("regResidentName").value) + "&Phone=" + escape(cleanPhone(document.getElementById("regPhone").value)) + "&" + Math.random(), true);
		        oHttp.onreadystatechange = function () {
		            if (oHttp.readyState == 4) {
		                if(oHttp.responseText != '') {
							if(parseInt(oHttp.responseText) > 0){
								SetCookie("GetInfo",oHttp.responseText);
								popupDiv("hidden");
								checkLogin();
								checkFavorites(thisID,oHttp.responseText);
								if(document.getElementById("eMailUsed") != null){
									document.getElementById("eMailUsed").style.display="none";
								}
							} else {
								if(document.getElementById("eMailUsed") != null){
									document.getElementById("eMailUsed").style.display="block";
								}
							}
						} else {
							document.getElementById("regPopupError").style.display="block";
							document.getElementById("regPopupError").innerHTML='Bad request';
						}
		            }
		        };
		        oHttp.send("");
		}
	}
}

function logOut(){
	uid=0;
	SetCookie("GetInfo","");
	checkLogin();
	window.location.href="/";
}

function checkLogin(){
	if(GetCookie('GetInfo') != null && GetCookie('GetInfo') != ""){
		uid=GetCookie('GetInfo');
		var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?Action=GetUserEmail&UID=" + uid + "&" + Math.random(), true);
        oHttp.onreadystatechange = function () {
            if (oHttp.readyState == 4) {
				document.getElementById("menu").innerHTML='<strong>Welcome,</strong>  ' + oHttp.responseText + ' <a href="#" onclick="logOut();return false;" rel="nofollow" style="font-size:10px;"> (Sign out)</a> <strong>|</strong> <img src="/images/icon_my_account.gif" border="0" alt="" align="bottom"  style="vertical-align:-30%;"><a href="/myaccount.asp?Action=profile" rel="nofollow"> My Account</a>';
            }
        };
        oHttp.send("");
	} else {
		uid=0;
		document.getElementById("menu").innerHTML='<strong>Welcome!</strong> <strong>|</strong> Already registered? <a href="/login.asp" rel="nofollow"> Sign in</a>';
	}
}

function checkFavorites(RCFEID,UID){
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?Action=checkFavorites&RCFEID=" + RCFEID + "&UID=" + UID + "&" + Math.random(), true);
        oHttp.onreadystatechange = function () {
            if (oHttp.readyState == 4) {
                if(oHttp.responseText != '') {
					document.getElementById("FavoritesTD").innerHTML='<img src="/images/icon_favorites_green.gif" width="17" height="16" alt="" border="0" align="bottom" style="vertical-align:-20%;">&nbsp;' + oHttp.responseText;
					document.getElementById("FavoritesTD2").innerHTML='<img src="/images/icon_favorites_green.gif" width="17" height="16" alt="" border="0" align="bottom" style="vertical-align:-20%;">&nbsp;' + oHttp.responseText;
				} else {
					document.getElementById("FavoritesTD").innerHTML='<img src="/images/icon_favorites_green.gif" width="17" height="16" alt="" border="0" align="bottom" style="vertical-align:-20%;">&nbsp;<a href="#" onclick="pageTracker._trackEvent(\'Favorites\', \'Save To Favorites\', \'Favorites on Detail Page\');saveToFavorites(thisID,uid);return false;" style="text-decoration:underline;">&nbsp;Save To Favorites&nbsp;</a>';
					document.getElementById("FavoritesTD2").innerHTML='<img src="/images/icon_favorites_green.gif" width="17" height="16" alt="" border="0" align="bottom" style="vertical-align:-20%;">&nbsp;<a href="#" onclick="pageTracker._trackEvent(\'Favorites\', \'Save To Favorites\', \'Favorites on Detail Page\');saveToFavorites(thisID,uid);return false;" style="text-decoration:underline;">&nbsp;Save To Favorites&nbsp;</a>';
				}
            }
        };
        oHttp.send("");
}

function saveToFavorites(RCFEID,UID){
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?Action=SaveToFavorites&RCFEID=" + RCFEID + "&UID=" + UID + "&" + Math.random(), true);
        oHttp.send("");
		checkFavorites(RCFEID,UID);
}

function delFavorites(RCFEID,UID){
	var oHttp = zXmlHttp.createRequest();
        oHttp.open("get", "/ajax.asp?Action=delFavorites&RCFEID=" + RCFEID + "&UID=" + UID + "&" + Math.random(), true);
        oHttp.send("");
		window.location.reload();
}

function popupDiv(action){
	var resObj = document.getElementById("divbox");
	if(document.getElementById("cashboxnew") != null){
			document.getElementById("cashboxnew").style.width="530px";
		}
	if(action == "hidden"){
		document.body.style.overflow="auto";
		document.getElementById("BackgroundFilter").style.display="none";
		resObj.style.visibility="hidden";
		if(document.getElementById("popupContent")){document.getElementById("popupContent").innerHTML="";}
	} else if(action == "close"){
		document.body.style.overflow="auto";
		document.getElementById("BackgroundFilter").style.display="none";
		resObj.style.visibility="hidden";
		document.getElementById("popupContent").innerHTML="";
		if(GetCookie('GetInfo') == null || GetCookie('GetInfo') == ""){
			if(window.location.href.indexOf("NoLogin") == -1){
				history.back(-1);
			}
		}
	} else {
		if(action == "GetInfo"){
			if(GetCookie('GetInfo') != null && GetCookie('GetInfo') != ""){
				checkLogin();
				return
			} else {
				if(document.getElementById("cashboxnew") != null){
					document.getElementById("cashboxnew").style.width="615px";
					document.getElementById("cashboxnew").style.height="550px";
				}
				var oHttp = zXmlHttp.createRequest();
		        oHttp.open("get", "/getInfo.asp?" + Math.random(), true);
		        oHttp.onreadystatechange = function () {
		            if (oHttp.readyState == 4) {
		                if(oHttp.responseText != '') {
							document.getElementById("popupContent").innerHTML=oHttp.responseText;
							document.getElementById('loginEMail').focus();
							//document.getElementById('logInPopupRegForm').style.display="none";
						}
		            }
		        };
		        oHttp.send("");
			}
		} else if(action == "forgotPassword"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/forgotpassword.asp?" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		} else if(action == "privacyPolicy"){
			document.getElementById("popupContent").innerHTML="Privacy Policy";
		} else if(action == "Availability"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/availability.asp?UID=" + uid + "&RCFEID=" + thisID + "&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		} else if(action == "sendToFamily"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/sendToFamily.asp?UID=" + uid + "&RCFEID=" + thisID + "&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		} else if(action == "watchVideo"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/watchVideo.asp?UID=" + uid + "&RCFEID=" + thisID + "&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		} else if(action == "watchListingVideo"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/watchVideo.asp?watchListingVideo=1&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		} else if(action == "watchFAQVideo"){
			document.getElementById("popupContent").innerHTML="<iframe src='\/watchVideo.asp?watchFAQVideo=1&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
		}
		centerDivPopUp();
		document.body.style.overflow="hidden";
		document.getElementById("BackgroundFilter").style.display="block";
		document.getElementById("BackgroundFilter").style.width=document.body.clientWidth + "0px";
		document.getElementById("BackgroundFilter").style.height=document.body.clientHeight + "0px";
		resObj.style.visibility="visible";
	}
}

function newTestimonials(){
	popupDiv('newTestimonials');
	document.getElementById("popupContent").innerHTML="<iframe src='\/detail-testimonial.asp?UID=" + uid + "&RCFEID=" + thisID + "&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
}

function siTestimonials(){
	popupDiv('siTestimonials');
	document.getElementById("popupContent").innerHTML="<iframe src='\/si-testimonial.asp?UID=" + uid + "&" + Math.random() + "' width='510' height='380' marginwidth='0' marginheight='0' align='top' frameborder='0'><\/iframe>";
}

function toggleMap(){
	var MapObj = document.getElementById("mapDirections");
	if(MapObj.style.display == "block") {
		MapObj.style.display="none";
		document.getElementById("MapiFrame").src="about:blank";
	} else {
		MapObj.style.display="block";
		document.getElementById("MapiFrame").src="/map.asp?initMap=" + document.getElementById("initMap").innerHTML + "&MapPoints=" + escape(document.getElementById("MapPoints").innerHTML) + "&" + Math.random();
	}
}

function setCheckboxCount(action){
	var CookieList = "Amenities,Pets,Ambulation,Care_Needed";
		var Cookies = CookieList.split(",");
		var display = false;
		for (var i = 0; i < Cookies.length; i++) {
			if(GetCookie(Cookies[i]) != null && GetCookie(Cookies[i]) != ""){
				if(document.getElementById(Cookies[i] + 'Selected') != null){
					display = true;
					document.getElementById(Cookies[i] + 'Selected').innerHTML=" (" + GetCookie(Cookies[i]).split("|").length + ")";
					document.getElementById(Cookies[i] + 'Selected').style.display="inline";
				}
			} else {
				if(document.getElementById(Cookies[i] + 'Selected') != null){
					document.getElementById(Cookies[i] + 'Selected').style.display="none";
				}
			}
		}
		if(document.getElementById("facilityNameField").value != ''){
			display = true;
		}
		if(display && action != 'main'){
			document.getElementById("toggleExpandedImg").src="/images/button_less_options.gif";
			document.getElementById("RefineSearch").style.display="block";
		}
}

function toggleRefineSearch(action,e){
	var popupObj = document.getElementById("uni_search_popup");
	var popupValueObj = document.getElementById("valignBot2");
	document.getElementById("uni_search_popup_Title").innerHTML=action.replace('_',' ');

	var checkboxValues = "";
	
	if(action == 'main'){
		var imgObj = document.getElementById("toggleExpandedImg");
		var RefineSearchObj = document.getElementById("RefineSearch");
		
		setCheckboxCount(action);
		
		if(RefineSearchObj.style.display == "block") {
			imgObj.src="/images/button_more_options.gif";
			RefineSearchObj.style.display="none";
			popupObj.style.display="none";
			popupValueObj.innerHTML="";
		} else {
			imgObj.src="/images/button_less_options.gif";
			RefineSearchObj.style.display="block";
		}
		
	} else if(action == 'Amenities'){
		checkboxValues = "24hr controlled access,24hr up and waske staff,Air Conditioning,Cable/Satellite Hookup,Computer/Internet Access,In-room call system,Parking,Transportation,Wander Guard";
	} else if(action == 'Pets'){
		checkboxValues = "No Pets,Dogs,Cats,Birds,Call Facility";
	} else if(action == 'Ambulation'){
		checkboxValues = "Front Wheel Walker,Full Lift,Some Assistance,Stand By Assist,Wheelchair";
	} else if(action == 'Care_Needed'){
		checkboxValues = "Activities of Daily Living,Catheter Mangement,Colostomy Care,Feeding,Foot Care,Incontince Care,Medication Management,Toileting";
	} else if(action == 'close'){
		checkboxValues = "";
	} else if(action == 'save'){
		popupObj.style.display="none";
		
		var inputs = document.getElementsByTagName('INPUT');
		var KillThisCookie = 1;
		    for (var i = 0; i < inputs.length; i++) {
		        if(inputs[i].type == 'checkbox' && inputs[i].id != '') {
					mySplitResult = inputs[i].id.split(':-:');
					if(KillThisCookie){
						KillCookie(mySplitResult[0]);
						KillThisCookie = 0;
					}
					if(inputs[i].checked){
						var oldValue = GetCookie(mySplitResult[0]);
							if(oldValue != null && oldValue != ""){
								oldValue += "|";
							} else {
								oldValue = "";
							}
						SetCookie(mySplitResult[0],oldValue + mySplitResult[1]);
		            }
		        }
		    }
		
		if(GetCookie(mySplitResult[0]) != null && GetCookie(mySplitResult[0]) != ""){
			document.getElementById(mySplitResult[0] + 'Selected').innerHTML=" (" + GetCookie(mySplitResult[0]).split("|").length + ")";
			document.getElementById(mySplitResult[0] + 'Selected').style.display="inline";
		} else {
			document.getElementById(mySplitResult[0] + 'Selected').style.display="none";
		}
		checkboxValues = "";
	}
	
	if(checkboxValues != ""){
		var checkboxValueList = checkboxValues.split(",");
		var checkboxValuesHTML = '';
			for (var i = 0; i < checkboxValueList.length; i++) {
				checkboxValuesHTML += '<input class="valignBot" waschecked="no" type="checkbox" value="1" id="' + action + ':-:' + checkboxValueList[i] + '"> ' + checkboxValueList[i] + '<br />';
			}
		popupValueObj.innerHTML=checkboxValuesHTML;
		
		if(GetCookie(action) != null && GetCookie(action) != ""){
		var checkedList = GetCookie(action).split("|");
			for (var i = 0; i < checkedList.length; i++) {
				document.getElementById(action+':-:'+checkedList[i]).checked = true;
			}
		}
		popupObj.style.top=(document.getElementById("header"+action+"Link").offsetTop + 6) + "px";
		popupObj.style.left=(document.getElementById("header"+action+"Link").offsetLeft + 5) + "px";
		popupObj.style.display="block";
	} else {
		popupObj.style.display="none";
		popupValueObj.innerHTML="";
	}
}

function GetData(marker,ID) {
	GDownloadUrl('/ajax.asp?Action=GetThisData&ID=' + ID + '&' + Math.random(),
	    function (data,responseCode) { 
	        marker.openInfoWindowHtml(data) 
        }
    )
}

function showTab(div){
	var tabList = "generalAmenities,roomAmenities,security,transportation,dining,pets,ambulation,assistance,careNeeded";
		tabList = tabList.split(",");
		for (var i = 0; i < tabList.length; i++) {
			document.getElementById(tabList[i]).style.display="none";
			if(document.getElementById(tabList[i] + '_TD') != null){
				document.getElementById(tabList[i] + '_TD').className='menu_off';
			}
		}
	var divObj = document.getElementById(div);
		document.getElementById(div + '_TD').className='menu_on';
		divObj.style.display="block";
}

function changeTab(div){
	var tabList = "facilityDetails,mapDirections,photosFloorplan,testimonials";
		tabList = tabList.split(",");
		for (var i = 0; i < tabList.length; i++) {
			document.getElementById(tabList[i]).style.display="none";
			document.getElementById(tabList[i] + '_A').className='DetailTab_off';
		}
	var divObj = document.getElementById(div);
		document.getElementById(div + '_A').className='DetailTab_on';
		divObj.style.display="block";
		if(div == "mapDirections"){
			document.getElementById("MapiFrame").src="/map.asp?initMap=" + document.getElementById("initMap").innerHTML + "&ID=" + thisID + "&MapPoints=" + escape(document.getElementById("MapPoints").innerHTML) + "&" + Math.random();
		}
}

function changeTabState(obj,onOff){
	var tabList = "facilityDetails,mapDirections,photosFloorplan,testimonials";
		tabList = tabList.split(",");

	for (var i = 0; i < tabList.length; i++) {
		document.getElementById(tabList[i] + '_A').className = "DetailTab_off";
	}

	if(onOff == 'on'){ 
		obj.className = "DetailTab_on";
	} else {
		for (var i = 0; i < tabList.length; i++) {
			if(document.getElementById(tabList[i]).style.display == "block"){
				document.getElementById(tabList[i] + '_A').className = "DetailTab_on";
			}
		}
	}
}

function hResize(){
	document.getElementById("ajaxResults").style.top=document.getElementById("combined_location_fieldLink").offsetTop + "px";
	document.getElementById("ajaxResults").style.left=document.getElementById("combined_location_fieldLink").offsetLeft + "px";
}

function dResize(){
	centerDivPopUp();
}

function mResize(){
	centerDivPopUp();
}

function alResize(){
	var popupObj = document.getElementById("uni_search_popup");
		if(popupObj.style.display="block"){
			popupObj.style.display="none";
		}
	centerDivPopUp();
}

function logInPopupFormReg(){
	document.getElementById("logInPopupError").style.display="none";
	document.getElementById('logInPopupForm').style.display="none";
	document.getElementById('logInPopupRegForm').style.display="block";
	document.getElementById('regEMail').focus();
}

function checkContactFacilitiesTable(){
document.getElementById("contactFacilitiesTable").style.display="none";
	var inputs = document.getElementById("ContactRS").getElementsByTagName('INPUT');
	    for (var i = 0; i < inputs.length; i++){
	        if(inputs[i].type == 'checkbox' && inputs[i].id.indexOf('mailbrochure') != -1){
	             if(inputs[i].checked == true){
				 	document.getElementById("contactFacilitiesTable").style.display="block";
				}
			}
		}
}

function verfyWidth(p) {
    var ratingstar = document.getElementById("RatingDiv").style.width;
    if (ratingstar >= p){
        document.getElementById("RatingDiv").style.width = p;
    }
}

function SetRating(p) {
    document.getElementById("Rating").value = p;
    document.getElementById("RatingDiv").style.width = (p * 20) + '%' ;
}

function checkAll(thisBox) {
	var inputs = document.getElementsByTagName('INPUT');
    for (var i = 0; i < inputs.length; i++){
        if(inputs[i].type == 'checkbox'){
           inputs[i].checked = thisBox.checked;
		}
	}
}

function checkEmail(email){
	if(email.value != ''){
	var oHttp = zXmlHttp.createRequest();
	        oHttp.open("get", "/ajax.asp?Action=checkEmail&eMail=" + escape(email.value) + "&" + Math.random(), true);
	        oHttp.onreadystatechange = function () {
	            if (oHttp.readyState == 4) {
	                if(oHttp.responseText == 0){
						closeError();
					} else {
						document.getElementById("PopupError").style.display="block";
						document.getElementById("PopupError").innerHTML='<img src=/images/spacer.gif width=25 height=1><strong>Email address (' + email.value + ') is being used.</strong>';
						document.getElementById(email.id).value = '';
						document.getElementById(email.id).focus();
					}
	            }
	        };
	        oHttp.send("");
	}
}