/*
 Standard routines
 
 */



country = new Array();
region = new Array();
town = new Array();

country[1]='Menorca';
region['Menorca']='...,Ciutadella Area,South East,South West,North East,North West,Inland,Mahon Area';
town['North West']='...,Cala en Blanes,Cala en Brut,Cala en Forcat,Ciutadella,Cala Morrel,Los Delfines,Santandria';
town['South East']='...,Alcufar,Binibeca,Binisafuller,Cala en Porter,Cala Longa,Es Canutells,Es Castell,Es Macaret,Punta Prima,S Algar,Sant Lluis,Sant Tomas,Son Bou,Sol del este,Son Vilar';
town['South West']='...,Cala Blanca,Cala en Bosch,Cala Galdana,Son Xoriquer';
town['North East']='...,Addaya,Arenal den Castell,Es Grau,Fornells,Playa den Fornells,Son Parc';

town['Inland']='...,Alaior,Es Mercadal,Es Migjorn Gran,Ferreries,Llucmacanes,Sant Climent,Trebaluger';
town['Mahon Area']='...,Cala Longa,Es Castell,Llucmacanes,Sant Antoni,Son Vilar';
town['Ciutadella Area']='...,Cala Blanca,Cala en Blanes,Cala en Brut,Cala en Forcat,Los Delfines,Santandria';

town['all']='...,Addaya,Alaior,Alcufar,Arenal den Castell,Binibeca,Binisafuller,Cala Blanca,Cala en Blanes,Cala en Brut,Cala en Bosch,Cala en Porter,Cala Galdana,Cala Longa,Ciutadella,Cala Morrel,Es Canutells,Es Castell,Es Grau,Es Macaret,Es Mercadal,Es Migjorn Gran,Fornells,Los Delfines,Llucmacanes,Mahon,Playa den Fornells,Punta Prima,S Algar,Santandria,Sant Antoni,Sant Climent,Sant Lluis,Sant Tomas,Son Bou,Son Parc,Sol del Este,Son Xoriquer,Trebaluger';


function changeregion() {


        // test if DOM el exists if not return
        obj = document.form_search;
        
        var town_array =  town['all'].split(',');
        //obj.QStown.length=0;
        for (var i=0; i < town_array.length; i++) {
                    obj.QStown.options[i] = new Option(town_array[i], town_array[i], 0, 0);
                    obj.QStown.options[0].selected =  true;
            }
   
}

function changetown() {

        obj = document.form_search;
        var town_now  = obj.QSregiunea.options[obj.QSregiunea.selectedIndex].value;
        
      if (town_now != '...') {
            var town_array =  town[town_now].split(',');
            obj.QStown.length=0;
            for (var i=0; i < town_array.length; i++) {
                    obj.QStown.options[i] = new Option(town_array[i], town_array[i], 0, 0);
                    obj.QStown.options[0].selected =  true;
            }
    }else{
            var town_array =  town['all'].split(',');
            obj.QStown.length=0;
            for (var i=0; i < town_array.length; i++) {
                    obj.QStown.options[i] = new Option(town_array[i], town_array[i], 0, 0);
                    obj.QStown.options[0].selected =  true;
            }
    }
}



function reset_myform() { 

document.form_search.QSregiunea.value = '...';
document.form_search.QStown.value = '...';

}


 

function verifyquicksearchForm(theForm){
   var msg='';
   
   

   if ((document.getElementById('pid').value!='') ){
		
		
		window.location.href='http://www.holidayhomerentalsonline.com/searchresults.php?pid='+document.getElementById('pid').value;
			
				
	 }
	 else if ((document.getElementById('pname').value!='') ){
		
		
		window.location.href='http://www.holidayhomerentalsonline.com/searchresults.php?pname='+document.getElementById('pname').value+'&regiunea='+document.getElementById('QSregiunea').value+'&town='+document.getElementById('QStown').value+'&bedrooms='+document.getElementById('QScamere').value;;
			
				
	 }
	 else if ((document.getElementById('sd').value!='') && (document.getElementById('ed').value!='')){
		
		//alert("here "+document.getElementById('sd').value);	
        sdf=document.getElementById('sd').value.split("-");
		edf=document.getElementById('ed').value.split("-");
		
		window.location.hash='http://www.holidayhomerentalsonline.com/searchresults.php?ziua='+sdf[0]+'&ziual='+edf[0]+'&luna='+sdf[1]+'&lunal='+edf[1]+'&an='+sdf[2]+'&anl='+edf[2]+'&search_property=1&search_rooms=1'+'&regiunea='+document.getElementById('QSregiunea').value+'&town='+document.getElementById('QStown').value+'&bedrooms='+document.getElementById('QScamere').value;
		return true;
				
	 }
	 else {
	    window.location.href='http://www.holidayhomerentalsonline.com/searchresults.php?regiunea='+document.getElementById('QSregiunea').value+'&town='+document.getElementById('QStown').value+'&bedrooms='+document.getElementById('QScamere').value;
	 }
	 
	 	
	return false;                              
}

jQuery.cookie = function (key, value, options) {    

// key and value given, set cookie...    
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);        
        if (value === null) {            options.expires = -1;        }  
        if (typeof options.expires === 'number') {  
          var days = options.expires, t = options.expires = new Date();
          t.setDate(t.getDate() + days);        
        }        
        return (document.cookie = [  
           encodeURIComponent(key), '=',
           options.raw ? String(value) : encodeURIComponent(String(value)),
           options.expires ? ';  expires=' + options.expires.toUTCString() : '', 
        
        // use expires attribute, max-age is not supported by IE            
           options.path ? '; path=' + options.path : '', 
           options.domain ? '; domain=' + options.domain : '', 
           options.secure ? '; secure' : ''        ].join(''));    
}    // key and possibly options given, get cookie...    

options = value || {};    
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;

}; 
           


