
function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;  
  this.numberofmenuitems = 6;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}

function subdesc(allitems,thisitem,startstate){ 
  callname= "sd"+thisitem;
  divname="subdesc"+thisitem;  
  this.numberofmenuitems = 24;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
for (var i=1; i<= 24; i++){
    var shutdiv = "subdescitem"+i+".thediv";

	if (navigator.userAgent.indexOf("MSIE") > -1){
		sError =0;	
		while (sError < 20){
	  		if (document.readyState == "complete"){
				shutdiv = eval(shutdiv);
      			shutdiv.style.visibility="hidden";
				sError = 20;
			}	
			else
			{
			sError = sError + 1;
			}
		}
	}
	else
	{
		shutdiv = eval(shutdiv);
      	shutdiv.style.visibility="hidden";
	}
}

for (var i=1; i<= 6; i++){
	var shutdiv = "menuitem"+i+".thediv";
	
	if (navigator.userAgent.indexOf("MSIE") > -1){
		sError =0;	
		while (sError < 20){
	  		if (document.readyState == "complete"){
				shutdiv = eval(shutdiv);
      			shutdiv.style.visibility="hidden";
				sError = 20;
			}	
			else
			{
			sError = sError + 1;
			}
		}
	}
	else
	{
		shutdiv = eval(shutdiv);
      	shutdiv.style.visibility="hidden";
	}
}
  
  	if (navigator.userAgent.indexOf("MSIE") > -1){
	sError =0;	
		while (sError < 20){
	  		if (document.readyState == "complete"){
				theobj = eval(theobj);
  				theobj.thediv.style.visibility="visible";
				sError = 20;
			}	else {
				sError = sError + 1;
			}
	  }
	}else
	{
		theobj = eval(theobj);
  		theobj.thediv.style.visibility="visible";
	}
  
 // alert(theobj.numberofmenuitems);		

}

function HomeClear(){
sError =0;
for (var i=1; i<= 24; i++){
    var shutdiv = "subdescitem"+i+".thediv";
	if (navigator.userAgent.indexOf("MSIE") > -1){
	  if (document.readyState == "complete"){
		shutdiv = eval(shutdiv);
    	shutdiv.style.visibility="hidden";
	  }
	 // while (document.readyState == "complete" && sError <= 20){
	 // 	shutdiv = eval(shutdiv);
    	//shutdiv.style.visibility="hidden";
		//sError = sError + 1
	 // }
	}
	else
	{
	  shutdiv = eval(shutdiv);
      shutdiv.style.visibility="hidden";
	}
  }
  for (var i=1; i<= 6; i++){
    var shutdiv = "menuitem"+i+".thediv";
	if (navigator.userAgent.indexOf("MSIE") > -1){
	  if (document.readyState == "complete"){
		shutdiv = eval(shutdiv);
    	shutdiv.style.visibility="hidden";
	  }
	}
	else
	{
	  shutdiv = eval(shutdiv);
      shutdiv.style.visibility="hidden";
	}
  }
}

function edeschandler(event,theobj){
//alert("edeschandler");	
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "subdescitem"+i+".thediv");
    shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
}
				
function closesubnav(event){
//alert("closesubnav");	
//if ((typeof(document.menuitem1) != 'undefined') && (typeof(document.subdescitem1) != 'undefined'))
  if ((event.clientY <4)||(event.clientY > 170)){

	for (var i=1; i<= 6; i++){
     var shutdiv ='menuitem'+i+'.thediv';
		if (navigator.userAgent.indexOf("MSIE") > -1){
		sError =0;	
		while (sError < 20){
	  		if (document.readyState == "complete"){
				shutdiv = eval(shutdiv);
      			shutdiv.style.visibility='hidden';
				sError = 20;
			} //end if
			else {
				sError = sError + 1;
			}//end else
	  }//end while
	}//end big if
	else
	{
		shutdiv = eval(shutdiv);
      	shutdiv.style.visibility='hidden';
	}  

	}
	
	for (var i=1; i<= 24; i++){
      var shutdiv2 ='subdescitem'+i+'.thediv';
	  if (navigator.userAgent.indexOf("MSIE") > -1){
		sError =0;	
		while (sError < 20){
	  		if (document.readyState == "complete"){
      			shutdiv2 = eval(shutdiv2);
				shutdiv2.style.visibility='hidden';
				sError = 20;
			}	else {
				sError = sError + 1;
			}
	  }
	}else
	{
		shutdiv2 = eval(shutdiv2);
      	shutdiv2.style.visibility='hidden';
	}  
      
    }
  }
}

function returnOrigImg(event){
//alert(document.images[Imgnam].src);	
	if ((event.clientY <4)||(event.clientY > 170)){
		if (document.images[Imgnam].src.indexOf(Osourc) >= 0){ 
  			document.images[Imgnam].src = sourc;
		}
	}
} 

function swapImgRestore() {		
//alert("swapimagerestore");
  var i,x,a=document.sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
  	x.src=x.oSrc;
}

function preloadImages() {
//alert("preloadImages");	
  var d=document; 
  if(d.images){
	  if(!d.p) 
	  	d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; 
	for(i=0; i<a.length; i++)
   	if (a[i].indexOf("#")!=0){ 
			d.p[j]=new Image; 
			d.p[j++].src=a[i];
		}
  }
}

function findObj(n, d) {
  var p,i,x;  
  if(!d) 
  	d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
  	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
  	x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
  	x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
  	x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
  	x=d.getElementById(n); 
  return x;
}

function swapImage() {

	var i,j=0,x,a=swapImage.arguments;

	if (document.images["imgHome"].src.indexOf("SBSAimages/btnHomeOver.gif") >= 0)
	    {
		    document.images["imgHome"].src = "SBSAimages/btnHome.gif";
		}
	else 
	    {
	        if (document.images["imgHome"].src.indexOf("images/btnHomeOver.gif") >= 0) {
	            document.images["imgHome"].src = "images/btnHome.gif";
	        }
	    }


	    if (document.images["imgBuying"].src.indexOf("SBSAimages/btnBuyingOver.gif") >= 0) {
	        document.images["imgBuying"].src = "SBSAimages/btnBuying.gif";
	    }
			else if (document.images["imgBuying"].src.indexOf("ABSAimages/btnBuyingOver.gif") >= 0) {
	        document.images["imgBuying"].src = "ABSAimages/btnBuying.gif";
	    }
	    else {
	        if (document.images["imgBuying"].src.indexOf("images/btnBuyingOver.gif") >= 0) {
	            document.images["imgBuying"].src = "images/btnBuying.gif";
	        }
	    }


	    if (document.images["imgSelling"].src.indexOf("SBSAimages/btnSellingOver.gif") >= 0) {
	        document.images["imgSelling"].src = "SBSAimages/btnSelling.gif";
	    }
	    else {
	        if (document.images["imgSelling"].src.indexOf("images/btnSellingOver.gif") >= 0) {
	            document.images["imgSelling"].src = "images/btnSelling.gif";
	        } 
	    }


	    if (document.images["imgRenting"].src.indexOf("SBSAimages/btnRentingOver.gif") >= 0) {
	        document.images["imgRenting"].src = "SBSAimages/btnRenting.gif";
	    }
	    else {
	        if (document.images["imgRenting"].src.indexOf("images/btnRentingOver.gif") >= 0) {
	            document.images["imgRenting"].src = "images/btnRenting.gif";
	        } 
	    }

	    if (document.images["imgLetting"].src.indexOf("SBSAimages/btnLettingOver.gif") >= 0) {
	        document.images["imgLetting"].src = "SBSAimages/btnLetting.gif";
	    }
	    else {
	        if (document.images["imgLetting"].src.indexOf("images/btnLettingOver.gif") >= 0) {
	            document.images["imgLetting"].src = "images/btnLetting.gif";
	        } 
	    }

	    if (document.images["imgHowWork"].src.indexOf("SBSAimages/btnHowWorkOver.gif") >= 0) {
	        document.images["imgHowWork"].src = "SBSAimages/btnHowWork.gif";
	    }
	    else {
	        if (document.images["imgHowWork"].src.indexOf("images/btnHowWorkOver.gif") >= 0) {
	            document.images["imgHowWork"].src = "images/btnHowWork.gif";
	        } 
	    }

	    if (document.images["imgProfile"].src.indexOf("SBSAimages/btnProfileOver.gif") >= 0) {
	        document.images["imgProfile"].src = "SBSAimages/btnProfile.gif";
	    } else {
	        if (document.images["imgProfile"].src.indexOf("images/btnProfileOver.gif") >= 0) {
	            document.images["imgProfile"].src = "images/btnProfile.gif";
	        } 
	    }
	
	


document.sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
  	if ((x=findObj(a[i]))!=null){
		document.sr[j++]=x; 
		if(!x.oSrc) 
			x.oSrc=x.src; 
			x.src=a[i+2];
		}
//alert("swapImage");	
}

//Sterre - overStar(StarNumber,PropertyRef), clearStars(PropertyRef), clickStar(StarNumber,PropertyRef)
function overStar(StarNumber,PropertyRef){
var StarName = '';
var hidSaved = '';

hidSaved = "hdn_" + PropertyRef + "_Saved";

	if (document.form1[hidSaved].value == ""){
		for (var i=1; i<= StarNumber; i++){
			StarName = PropertyRef + "_imgStar" + i;
			document.images[StarName].src = "images/starRed.gif";
		}	
	}
}

function clearStars(PropertyRef){
var hidSaved = '';

hidSaved = "hdn_" + PropertyRef + "_Saved";

	if (document.form1[hidSaved].value == ""){
		for (var i=1; i<=5; i++){
			StarName = PropertyRef + "_imgStar" + i;
			document.images[StarName].src = "images/starQuest.gif";
		}	
	}	
}

function clickStar(StarNumber,PropertyRef){
	var StarName = '';
	var hidSaved = '';
	
	hidSaved = "hdn_" + PropertyRef + "_Saved";
	document.form1[hidSaved].value = "saved";
	
	for (var i=1; i<= StarNumber; i++){
		StarName = PropertyRef + "_imgStar" + i;
		document.images[StarName].src = "images/starRed.gif";
	}	
	for (var i=5; i> StarNumber; i--){
		StarName = PropertyRef + "_imgStar" + i;
		document.images[StarName].src = "images/starQuest.gif";
	}	

	//insert into db...
	window.open('prop/addRating.asp?property_ref=' + PropertyRef + '&rating=' +  StarNumber ,'Rating','toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=100');
	window.focus();
}


//clickFav(PropertyRef)
function clickFav(PropertyRef){
	var FavName = '';
	var hidSaved = '';
	
	FavName = "Fav_" + PropertyRef;

	document.images[FavName].src = "images/resultFavAdded.gif";
	document.images[FavName].onmouseover="" ;
	document.images[FavName].onmouseout="" ;
	document.images[FavName].onclick=""	;
	
	//insert into db...
	window.open('prop/addFavourites.asp?property_ref=' + PropertyRef,'addFavourites','toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=100');
	window.focus();
}

function sendEmailClient(propRef,client_id,isRent){
  	//insert into db...
	window.open('mail/sendPropdetailClient.asp?property_reference=' + propRef + '&isRent=' + isRent,'sendPropClient','toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=100');
	window.focus();
	if (client_id != ''){
		//alert('Sucessfully sent email.');
	}
}


