
	function openbox(){
		var url = 'http://www.thehousingpages.com/thp-ajax/popup.asp'
		var popup = document.getElementById('popup')
		var outer = document.getElementById('wrap')
		
		var oRequest = new XMLHttpRequest();
		oRequest.open("GET",url,false);
		oRequest.setRequestHeader("User-Agent",navigator.userAgent);
		oRequest.send(null)
		if (oRequest.status==200) popup.innerHTML = '<div id="frm">' + oRequest.responseText + '</div>'
		else alert("Error executing XMLHttpRequest call!");
		
		popup.style.zIndex = '100'
		popup.style.background = 'url(thp-ajax/images/thp-ajax_shd_sliver.png)'
		outer.style.zIndex = '-1'		
	}
	function closepopup(){
		var outer = document.getElementById('wrap')
		var popup = document.getElementById('popup')

		if (popup.innerHTML != ''){
			popup.innerHTML = ''
			popup.style.zIndex = '-1'
			popup.style.background = 'none'
			outer.style.zIndex = '100'
		} 
	}
	function togglediv(id){
		var div = document.getElementById(id).style
		if(div.display == 'block'){
			div.display = 'none'
		}
		else{
			div.display = 'block'
			var zip = document.getElementById("zip")	
			if(zip != null){
				if(zip != ""){
					document.getElementById("x_fromzip").value = zip.value
				}
			}
		}
	}
	function ChecknGo(){
		var city = document.getElementById('city') 
		var state = document.getElementById('state')
		if(city == null && state == null){
			alert("Please enter a value for city and state.")			
			return false
		}
		else{
			if(CCheck() == false){
				openbox();
				var link = "content/findapt.asp?usemap=" + document.getElementById('UseMap').value + "&city=" + city.value + "&state=" + state.value
				document.getElementById('listings').href = link
				document.getElementById('mlink').value = link
				return false
			}
		}
		
	}	
	function GoFind(lk,linkid){
		if(CCheck() == false){
			openbox()
			var link = document.getElementById(linkid)
			if(link != null){
				link.href = lk.href
				document.getElementById('mlink').value = lk.href
			}
		}
	}
	function GoToLink(lk,linkid){
		if(CCheck() == false){
			openbox()
			var link = document.getElementById(linkid)
			if(link != null){
				var a = new Array()
				a = lk.href.split('=')
				var newlink  = 'searchhomes.asp?hfsub=submit&state=' + a[1]
				link.target = '_blank'
				link.href = newlink
				document.getElementById('mlink').value = newlink
			}
		}
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	function CCheck(){
		if(readCookie('thpnonpop') == null){return false}
		return true
	}
	

