// Empty field.
//======================================================================================
function emptyField(f) {
	
	if (f.value == "Enter Keyword(s)") {
		f.value="";
		}
	
	}


//Popup window
//======================================================================================
function popUp(URL,SCROLLBARS,MENUBAR,TOOLBAR,STATUS,RESIZABLE,WIDTH,HEIGHT) {
	
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'scrollbars=" + SCROLLBARS + ",menubar=" + MENUBAR + ",toolbar=" + TOOLBAR + ",status=" + STATUS + ",resizable=" + RESIZABLE + ",width=" + WIDTH + ",height=" + HEIGHT + "');");
	
	}
	
	
function DoPop(URL)	{

	w=420;
	h=460;

	window.open(URL,"", "resizable=yes,scrollbars=no,top=200,left=200,width="+w+",height="+h);
	return false;
	
	}	
	
	
//Show & Hide	
//======================================================================================

var g_nExpando=0;

function putItemInState(n,bState) {
    
    var oItem, oGif;
    eval('oItem=document.all.descr'+n);
    eval('oGif=document.all.expandoGif'+n);

    if (bState=='toggle') bState = (oItem.style.display == 'block');

    if(bState) {
        oItem.style.display = 'none';
        oGif.src = 'images/Close.gif';
	    }
    else {
        oItem.style.display = 'block';
        oGif.src = 'images/open.gif';
	    }
	    
	}

function expand(nItem) {

    putItemInState(nItem,'toggle');  //toggle the nth item
    
	}	
	
	
//Draggable Layer Popup
//======================================================================================

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e) {

	topDog=isIE ? "BODY" : "HTML";
	whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
	hotDog=isIE ? event.srcElement : e.target;  
	
	while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
		hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
		}  
		
	if (hotDog.id=="titleBar") {
		offsetx=isIE ? event.clientX : e.clientX;
		offsety=isIE ? event.clientY : e.clientY;
		nowX=parseInt(whichDog.style.left);
		nowY=parseInt(whichDog.style.top);
		ddEnabled=true;
		document.onmousemove=dd;
		}
	
	}

function dd(e){

	if (!ddEnabled) return;
	whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
	whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
	return false;  
	
	}

function ddN4(whatDog) {

	if (!isN4) return;
	
	N4=eval(whatDog);
	N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	N4.onmousedown=function(e) {
		N4.captureEvents(Event.MOUSEMOVE);
		N4x=e.x;
		N4y=e.y;
		}
	N4.onmousemove=function(e) {
		if (isHot) {
			N4.moveBy(e.x-N4x,e.y-N4y);
			return false;
			}
		}
	N4.onmouseup=function(){
		N4.releaseEvents(Event.MOUSEMOVE);
		}
	}

function hideMe() {

	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.theLayer.visibility="hide";
	
	}

function showMe() {

	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.theLayer.visibility="show";
	
	}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");


//Dynamically change Buy/Rent Dropdown menus
//======================================================================================

function setOptionsBuy() {
	
	}


function setOptions() {

	if (document.SideIncludeSearchForm.cs_buyrent.options[document.SideIncludeSearchForm.cs_buyrent.selectedIndex].value == "Null") {
		
		document.getElementById("cs_min").disabled=true;
		document.getElementById("cs_max").disabled=true;
		document.getElementById("cs_area").disabled=true;
		document.getElementById("cs_type").disabled=true;
		document.getElementById("cs_bedrooms").disabled=true;
		document.getElementById("cs_bathrooms").disabled=true;										
		document.getElementById("submit_custom").disabled=true;			
		
		}
		
	if (document.SideIncludeSearchForm.cs_buyrent.options[document.SideIncludeSearchForm.cs_buyrent.selectedIndex].value == "Buy") {

		document.getElementById("cs_min").disabled=false;
		document.getElementById("cs_max").disabled=false;
		document.getElementById("cs_area").disabled=false;
		document.getElementById("cs_type").disabled=false;
		document.getElementById("cs_bedrooms").disabled=false;
		document.getElementById("cs_bathrooms").disabled=false;	
		document.getElementById("submit_custom").disabled=false;				
		
		var selbox = document.SideIncludeSearchForm.cs_min;
	 	selbox.options.length = 0;

		selbox.options[selbox.options.length] = new Option('Any minimum','Null');
		selbox.options[selbox.options.length] = new Option('-------------------','Null');		
		selbox.options[selbox.options.length] = new Option('R 150,000','150000');
		selbox.options[selbox.options.length] = new Option('R 300,000','300000');
		selbox.options[selbox.options.length] = new Option('R 500,000','500000');
		selbox.options[selbox.options.length] = new Option('R 800,000','800000');
		selbox.options[selbox.options.length] = new Option('R 1,200,000','1200000');
		selbox.options[selbox.options.length] = new Option('R 1,500,000','1500000');
		selbox.options[selbox.options.length] = new Option('R 2,000,000','2000000');
		selbox.options[selbox.options.length] = new Option('R 3,500,000','3500000');              
	
		var selbox = document.SideIncludeSearchForm.cs_max;
	 	selbox.options.length = 0;

		selbox.options[selbox.options.length] = new Option('Any maximum','Null');	
		selbox.options[selbox.options.length] = new Option('-------------------','Null');				
		selbox.options[selbox.options.length] = new Option('R 300,000','300000');
		selbox.options[selbox.options.length] = new Option('R 500,000','500000');
		selbox.options[selbox.options.length] = new Option('R 800,000','800000');
		selbox.options[selbox.options.length] = new Option('R 1,200,000','1200000');
		selbox.options[selbox.options.length] = new Option('R 1,500,000','1500000');
		selbox.options[selbox.options.length] = new Option('R 2,000,000','2000000');
		selbox.options[selbox.options.length] = new Option('R 3,500,000','3500000');  
		selbox.options[selbox.options.length] = new Option('R 5,000,000','5000000');	
		
		}

	if (document.SideIncludeSearchForm.cs_buyrent.options[document.SideIncludeSearchForm.cs_buyrent.selectedIndex].value == "Rent") {

		document.getElementById("cs_min").disabled=false;
		document.getElementById("cs_max").disabled=false;
		document.getElementById("cs_area").disabled=false;
		document.getElementById("cs_type").disabled=false;
		document.getElementById("cs_bedrooms").disabled=false;
		document.getElementById("cs_bathrooms").disabled=false;	
		document.getElementById("submit_custom").disabled=false;			
		
		var selbox = document.SideIncludeSearchForm.cs_min;
	 	selbox.options.length = 0;
	
		selbox.options[selbox.options.length] = new Option('Any minimum','Null');	
		selbox.options[selbox.options.length] = new Option('-------------------','Null');				
		selbox.options[selbox.options.length] = new Option('R 1,500','1500');
		selbox.options[selbox.options.length] = new Option('R 3,000','3000');
		selbox.options[selbox.options.length] = new Option('R 5,000','5000');
		selbox.options[selbox.options.length] = new Option('R 8,000','8000');
	
		var selbox = document.SideIncludeSearchForm.cs_max;
	 	selbox.options.length = 0;

		selbox.options[selbox.options.length] = new Option('Any maximum','Null');	
		selbox.options[selbox.options.length] = new Option('-------------------','Null');				
		selbox.options[selbox.options.length] = new Option('R 3,000','3000');
		selbox.options[selbox.options.length] = new Option('R 5,000','5000');
		selbox.options[selbox.options.length] = new Option('R 8,000','8000');
		selbox.options[selbox.options.length] = new Option('R 10,000','10000');
		
		}		

	}	
	

//Determine the screen resolution
//======================================================================================
	
function writeCookie() {

	var today = new Date();
	var the_date = new Date("December 31, 2023");
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = "users_resolution2="+ screen.width +"x"+ screen.height;
	var the_cookie = the_cookie + ";expires=" + the_cookie_date;
	document.cookie=the_cookie
	 
	location = 'main_property_information.php';
	
	}	
	
	
function get_screen_resolution() {

	return screen.width +"x"+ screen.height;
	
	}


//Set the page title
//======================================================================================
	
function windowTitle(mytitle) { 

	parent.document.title = mytitle; 
	
	}	
	

//How do I get the absolute position of a non-positioned element ?
//======================================================================================

function getDim(el) {

	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
		
	return {x:lx,y:ly}
	
	}

//Example usage:

//<table><tr><td>
//<span id=MySpan><img src="something" id=MyImage></span>
//</td></tr></table>

//<script>

//mySpanDim = getDim(document.getElementById("MySpan"))
//alert("x:" + mySpanDim.x + ", y:" + mySpanDim.y)

//myImgDim = getDim(document.images.MyImage)
//alert("x:" + myImgDim.x + ", y:" + myImgDim.y)

//</script>


//Activating ActiveX Controls
//======================================================================================

function CreateSlideShow_Property(property_idno) {

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="519" id="pxclient_slideshow_files" align="middle">');
	document.write("<param name='FlashVars' value='xmlfile=xml_slideshow_property.php?property_idno=" + property_idno + "' />");
	document.write("<embed FlashVars='xmlfile=xml_slideshow_property.php?property_idno=" + property_idno + "' />");
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="slideshow_property.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="slideshow_property.swf" quality="high" bgcolor="#ffffff" width="600" height="519" name="pxclient_slideshow_files" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');	

	}
	
function CreateSlideShow_Index(property_idno) {

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="214" height="161" id="index_show" align="middle">');
	document.write("<param name='FlashVars' value='xmlfile=xml_slideshow_index.php?property_idno=" + property_idno + "' />");
	document.write("<embed FlashVars='xmlfile=xml_slideshow_index.php?property_idno=" + property_idno + "' />");
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="slideshow_index.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="slideshow_index.swf" quality="high" bgcolor="#ffffff" width="400" height="306" name="index_show" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');	

	}	
	
