if( typeof cGlobal  == 'undefined' )
{
	cGlobal = {}
}

cGlobal.sPropertyDataLoaded = function()
{
var aResults = this.hXMLHttp.responseText.split( ',' )

document.getElementById("DIVcityID").style.display ="block";
document.getElementById("cityID").options.length = 0;
 var i=0; 
for ( keyVar in aResults )
   {
   res=aResults[keyVar].split( '_' );
   document.getElementById("cityID").options[i]= new Option(res[1],res[0]);
   i++;
   } 
 
}

cGlobal.sPropertyDataUrl="getcity.php";

cGlobal.CityLoader = function()
{
	var country=document.getElementById("countryID");
	
	sPropertyId=country.options[country.selectedIndex].value
	if(sPropertyId)
	{cGlobal.hRemoteLoader.abortLoading();
	cGlobal.hRemoteLoader.loadContent( cGlobal.sPropertyDataUrl+'?prop='+sPropertyId, cGlobal.sPropertyDataLoaded )
	}	
	else
	{document.getElementById("DIVcityID").style.display ="none";
	}
}

cGlobal.sPropertyDataUrl="changecountry.php";
cGlobal.ChangeCountry = function()
{
   var country=document.getElementById("countryID");
	sPropertyId=country.options[country.selectedIndex].value
   document.location.href = 'index.php?country='+sPropertyId
}

cGlobal.sPropertyNull= function()
{
}


cGlobal.ViewLocation=function()
{
var aResults = this.hXMLHttp.responseText.split( ',' );
document.getElementById("type_check_in_place").options.length = 0;
var i=0; 
 // alert(aResults);
for ( keyVar in aResults )
   {
   res=aResults[keyVar].split( '_' );
   document.getElementById("type_check_in_place").options[i]= new Option(res[1],res[0]);

   i++;
   } 
}

cGlobal.LocationLoader=function()
{
    cGlobal.sPropertyDataUrl="getlocs.php";
    var city=document.getElementById("cityID");
	sPropertyId=city.options[city.selectedIndex].value
	cGlobal.hRemoteLoader.abortLoading();
	cGlobal.hRemoteLoader.loadContent( cGlobal.sPropertyDataUrl+'?prop='+sPropertyId, cGlobal.ViewLocation)
	
	
}



cGlobal.datedifference = function()
{
  var from_date=document.getElementById("from_date").value;
  var to_date=document.getElementById("to_date").value;
  var f_h=document.getElementById("f_hour").options[document.getElementById("f_hour").selectedIndex].value;
  var f_m=document.getElementById("f_min").options[document.getElementById("f_min").selectedIndex].value;
  var t_h=document.getElementById("t_hour").options[document.getElementById("t_hour").selectedIndex].value;
  var t_m=document.getElementById("t_min").options[document.getElementById("t_min").selectedIndex].value;

  var f_d=from_date.split( '.' )
  var t_d=to_date.split( '.' )
  var f_date=new Date()
  var t_date=new Date()

  f_date.setFullYear(f_d[2]);
  f_date.setMonth(f_d[1]-1);
  f_date.setDate(f_d[0]);
  f_date.setHours(f_h);
  f_date.setMinutes(f_m);

  
  t_date.setFullYear(t_d[2]);
  t_date.setMonth(t_d[1]-1);
  t_date.setDate(t_d[0]);
  t_date.setHours(t_h);
  t_date.setMinutes(t_m);

  var vreme= t_date.getTime()-f_date.getTime();
  var days=Math.ceil(vreme/(1000*60*60*24));

   
  return days;
 }
 
 cGlobal.dateprint = function(id)
	{
	var days=cGlobal.datedifference();
	//document.getElementById(id).innerHTML=days+"d ";
	//alert(days);
	if(days<0)
	{
	//alert(document.getElementById('from_date').value)
	document.getElementById('from_date').style.backgroundColor='#F9ACAC';
	document.getElementById('to_date').style.backgroundColor='#F9ACAC';
	
	return false;
	}
	else return true;
	/*var is_input = location.href.indexOf('?')
	   
	if((location.href.indexOf('res_details.php')!= -1)&&is_input!=-1) 
	   {
	   addr_str = location.href.substring(is_input+1, location.href.length);
	   var variables=addr_str.split('&');
	   var carid=variables[0].split('=');
	   alert(carid[1]);
	   //cGlobal.hRemoteLoader.abortLoading();
	   //cGlobal.hRemoteLoader.loadContent('getprice.php?prop='+sPropertyId, cGlobal.sPropertyDataLoaded )
	   }*/
	
	
	}
 
 cGlobal.viewaddress = function(id)
	{
	if(document.getElementById(id).style.display=='none')
		{
		document.getElementById(id).style.display=document.all?'block':'table-row'
		document.getElementById(id).style.visibility="visible";
		
		}
	else 
		{document.getElementById(id).style.display='none';
		document.getElementById(id).style.visibility="hidden";
		}
	
	}
	
	//init the estate list scripts
cGlobal.hRemoteLoader = null
cGlobal.init = function()
{
	cGlobal.hRemoteLoader = new cRemoteLoader()
}
cDomEvent.addEvent2( window, 'load', cGlobal.init )





