// JavaScript Document
<!--
 
var formArrayPopup = new Array("Hurghada", "ElGouna","SharmElSheikh");
var Popupcurrent = "Hurghada";

 
var formArrayConvertor = new Array("Metrics", "Metrics2", "Currency");
var Convertorcurrent = 'Metrics';
BR=BRV=0;
var win_det=null; 
var shi = window.screen.availHeight;
var swi = window.screen.availWidth;



function ShowPopup(url, w_width, w_height){
	if(win_det && win_det.closed==false){
		if (!BR || BR==2) closepopup();
		else reswin(w_width,w_height);
		}
	if(win_det && win_det.closed==false) {
		if(url) win_det.location.replace(url);
		}
	else {	
		var alH = parseInt(shi, 10) - 35;		
		if(w_height > alH){
			scrollbars  = 'yes';		
			w_width = parseInt(w_width, 10) + 17;
			}
		else
		scrollbars  = 'yes';						
		var lf=(swi-w_width)/2;
		var tp=(shi-w_height)/2;
		win_det=window.open(url, "" , "left=" + lf + ", top=" + tp+", scrollbars=" + scrollbars+", menubar=yes,resizable=yes, status=yes, toolbar=no, width=" + w_width + ",height=" + w_height);
		}
	win_det.focus();	
}

function closepopup(){
	if(win_det!=null && win_det.open) 
	win_det.close();
}

if (BR==2 || !BR) 
window.onunload=closepopup;

function reswin(w_width,w_height) {
if(win_det && !win_det.closed) {
	x1 = BR==1 ? win_det.document.body.clientWidth  : win_det.innerWidth;
	y1 = BR==1 ? win_det.document.body.clientHeight : win_det.innerHeight;
	if (x1!=w_width || y1!=w_height)win_det.resizeBy(w_width-x1, w_height-y1);
	}
}

function displayLocationPopup(formId) {	
	i = 0;
	end = formArrayPopup.length;	
			
	for (i; i < end; i++) {
		document.getElementById('search-'+formArrayPopup[i]).style.display = 'none';
		document.getElementById('innerM-'+formArrayPopup[i]).className = 'PopupmenuLink';
		document.getElementById('innerM-'+formArrayPopup[i]).firstChild.className = 'PopupnMenuWrap';
	}
	document.getElementById('search-'+formId).style.display = 'block';
	document.getElementById('innerM-'+formId).className = 'Popupcurrent';	
	document.getElementById('innerM-'+formId).firstChild.className = 'PopupactMenuWrap';
        	
	Popupcurrent = formId;
}


function displayConvertor(formId) {	
	i = 0;
	end = formArrayConvertor.length;	
			
	for (i; i < end; i++) {
		document.getElementById('search-'+formArrayConvertor[i]).style.display = 'none';
		document.getElementById('innerM-'+formArrayConvertor[i]).className = 'PopupmenuLink';
		document.getElementById('innerM-'+formArrayConvertor[i]).firstChild.className = 'PopupnMenuWrap';
	}
	document.getElementById('search-'+formId).style.display = 'block';
	document.getElementById('innerM-'+formId).className = 'Popupcurrent';	
	document.getElementById('innerM-'+formId).firstChild.className = 'PopupactMenuWrap';
        	
	Convertorcurrent = formId;
}


function checkBox(action){
	if(action == 'on'){
		var checkBoxAct = true;
	}
	else{
		var checkBoxAct = false;
	}
	
   var formObj = document.getElementById('locations-form'); 
   
   var formNumElements =  formObj.length;
   
	for (i = 0; i<formNumElements; i++) {
		if(formObj[i].type == 'checkbox'){		
			if (formObj[i].id.indexOf(Popupcurrent) == 0) 
			formObj[i].checked = checkBoxAct; 
		}
	}
}
 
 
  
 
 function clearSelected(searchForm)
 {
 
      	//document.getElementById(searchForm+'-location-select').style.visibility = 'visible';
     	document.getElementById(searchForm+'-location-select').style.display = 'inline';
     	//document.getElementById(searchForm+'-location-link').style.visibility = 'visible';
    	document.getElementById(searchForm+'-location-link').style.display = 'inline';
	    document.getElementById(searchForm+'-location-checked').style.display = 'none';
	     
	    document.getElementById(searchForm+'-location-td').style.verticalAlign='middle';
	    document.getElementById(searchForm+'-location-edit').style.display = 'none'; 
	    document.getElementById(searchForm+'-location-checked').innerHTML = "";
	    document.getElementById(searchForm+'-location-list').value = "";
 
 }
 
 
 function ShowSearchPopup(querystr,formId)
{   
   
 ShowPopup('/page/locations/?q='+querystr+'&formId='+formId,'450','450');

 //  ShowPopup('http://secondhomesv.info/locations.php?q='+querystr+'&formId='+formId,'450','450');
 
 	  
}
 

 function ShowSearchMap(querystr,formId)
{   
   
 	  ShowPopup('/page/map/?q='+querystr+'&formId='+formId,'689','528');
 	  
}
 
function SubmitSelections(searchForm)
{
	var formObj = document.getElementById('locations-form'); 
 
   var formNumElements =  formObj.length;
   var submitVal="|";
   var showVal="&nbsp;&nbsp;";
   var locTmp="";
   var locTmparea="";
   var checkedcount=0;
	for (i = 0; i<formNumElements; i++) 
	 	if ((formObj[i].type == 'checkbox')&&(formObj[i].checked))
			 { 
			   submitVal=submitVal +'|' + formObj[i].value;
			   
			   var label = formObj[i].value;
			     
			   if (checkedcount<3) showVal=showVal+document.getElementById('L'+ formObj[i].value).innerHTML  +', ';
			   checkedcount++; 
		     }
    showVal = showVal.substring(0,showVal.length-2);
   
    
	if(checkedcount==0) { alert("Please check at least one checkbox"); }
	 else
	 {	
	   if (window.opener && !window.opener.closed)
	   {     
        window.opener.document.getElementById(searchForm+'-location-select').style.display = 'none';
       // window.opener.document.getElementById(searchForm+'-location-select').colspan="4";
        
    	window.opener.document.getElementById(searchForm+'-location-link').style.display = 'none';
	    window.opener.document.getElementById(searchForm+'-location-checked').style.display = 'inline';
 
	    window.opener.document.getElementById(searchForm+'-location-edit').style.display = 'inline'; 
	    window.opener.document.getElementById(searchForm+'-location-checked').innerHTML = showVal;
	    window.opener.document.getElementById(searchForm+'-location-list').value = submitVal;
	    if(checkedcount>3) showVal = showVal + "...";
	    window.opener.document.getElementById(searchForm+'-location-checked').innerHTML = showVal;		
	   }		 
	    window.close();
	 }
 }
 
  function  closeSearchPopup()
 {
 	window.close(); 
 }
 


//-->
