function startUrl(){
	var fileToEx = 'xsl=list.xsl';
	var urlTo = 'http://data.cassarcooper.com/estate/xml/search.xml?xsl=list.xsl&';
	var bay = document.getElementById("bay").value;
	var type = document.getElementById("type").value;
	var type2 = document.getElementById("type2").value;
	var residential = document.getElementById("Residential").value;
	var locality = document.getElementById("locality").value;
	
	var urlToSeend = urlTo;
	switch(bay){ // dodati & kad budes ubacivo xsl
		case "0":
			urlToSeend += 'forletting=0';
			var priceFrom = document.getElementById("pricefrom0").value;
			var priceTo = document.getElementById("priceto0").value;
		break;
		case "1":
			urlToSeend += 'forletting=1&typelet=1';
			var priceFrom = document.getElementById("pricefrom1").value;
			var priceTo = document.getElementById("priceto1").value;
		break;
		case "2":
			urlToSeend += 'forletting=1&typelet=2';
			var priceFrom = document.getElementById("pricefrom2").value;
			var priceTo = document.getElementById("priceto2").value;
		break;
		default:
			urlToSeend += 'forletting=0';
			var priceFrom = document.getElementById("pricefrom0").value;
			var priceTo = document.getElementById("priceto0").value;
		break;
	}
		if(type != "0"){
			urlToSeend += '&type1='+type; 
		}else{
			
		}
		if(type2 != "0"){
			urlToSeend += '&type1='+type2; 
		}else{
			
		}
		if(locality != "0"){
			urlToSeend += '&locality='+locality;	
		}else{
			
		}
		if(priceFrom != "0"){
			urlToSeend += '&pricefrom='+priceFrom;
		}else{
			
		}
		if(priceTo != "0"){
			urlToSeend += '&priceto='+priceTo;
		}else{
			
		}
	urlToSeend += '&currency=EUR';
	//alert(priceFrom+' '+priceTo);
	window.location = urlToSeend;
}
function izmeniPrice(){
	switch(document.getElementById("bay").value){
		case "0":
			document.getElementById("pricesBuy").style.display="block";
			document.getElementById("pricesHoliday").style.display="none";
			document.getElementById("pricesLongLet").style.display="none";
			document.getElementById("vtype").style.display="block";
			document.getElementById("vtype2").style.display="none";
		break;
		case "1":
			document.getElementById("pricesBuy").style.display="none";
			document.getElementById("pricesHoliday").style.display="block";
			document.getElementById("pricesLongLet").style.display="none";
			document.getElementById("vtype").style.display="none";
			document.getElementById("vtype2").style.display="block";
		break;
		case "2":
			
			document.getElementById("pricesBuy").style.display="none";
			document.getElementById("pricesHoliday").style.display="none";
			document.getElementById("pricesLongLet").style.display="block";
			/*
			document.getElementById("vtype").style.display="none";
			document.getElementById("vtype2").style.display="block";
			*/
			document.getElementById("vtype").style.display="block";
			document.getElementById("vtype2").style.display="none";
		break;
	}
}
function vidiTipove(){
	switch(document.getElementById("bay").value){
		case "0":
			document.getElementById("Residential").style.visibility="visible";
			document.getElementById("Commercial").style.visibility="visible";
			
		break;
		case "1":
			document.getElementById("Residential").style.display="block";
			document.getElementById("Commercial").style.visibility="hidden";
		break;
		case "2":
			document.getElementById("Residential").style.visibility="visible";
			document.getElementById("Commercial").style.visibility="hidden";
		break;
		default:
			document.getElementById("Residential").style.visibility="visible";
			document.getElementById("Commercial").style.visibility="hidden";
		break;
	}
}
function byRef(){
	/*
	STARA.
	var toFInd = document.getElementById("refToFf").value;
	var refUrl = 'http://data.cassarcooper.com/estate/xml/reference.xml?xsl=details.xsl&currency=EUR&ref='+toFInd;
	window.location = refUrl;
	*/	
	var toFInd = document.getElementById("refToFf").value;
	if(toFInd == ""){
		document.getElementById("refToFf").value = 'By Reference';
		return false;
	}
	else if(toFInd == "By "+"Reference"){
		document.getElementById("refToFf").value = 'By Reference';
		return false;
	}
	else if(toFInd != ""){
		return true;
		document.byRefff.submit();	
	}
}
/* detailed search */
function local(id){
	document.getElementById("area").value = id;
	document.getElementById("locality2").disabled = true;
}
function localC(){
	document.getElementById("locality2").disabled = false;
}
function byRef2(){
	var toFInd = document.getElementById("refToF").value;
	var refUrl = 'http://data.cassarcooper.com/estate/xml/reference.xml?xsl=details.xsl&currency=EUR&ref='+toFInd;
	window.location = refUrl;
}
function resComm(){
	switch(document.getElementById("purpose").value){
		case "38":
			document.getElementById("Residential1").style.display="block";
			document.getElementById("Residential2").style.display="block";
			document.getElementById("Commercial1").style.display="none";
			document.getElementById("Commercial2").style.display="none";
		break;
		case "37":
			document.getElementById("Residential1").style.display="none";
			document.getElementById("Residential2").style.display="none";
			document.getElementById("Commercial1").style.display="block";
			document.getElementById("Commercial2").style.display="block";
		break;
		default:
			document.getElementById("Residential1").style.display="block";
			document.getElementById("Residential2").style.display="block";
			document.getElementById("Commercial1").style.display="none";
			document.getElementById("Commercial2").style.display="none";
	}
}
function svitchSale(){
	var sale = document.getElementById("sale").value;
	if(sale == "1"){
		document.getElementById("enlargemap").style.display="none";	
	}else{
		document.getElementById("enlargemap").style.display="block";
	}
}
function dUrl(){
	var fileToEx = 'xsl=list.xsl';
	var toSerUrl = 'http://data.cassarcooper.com/estate/xml/search.xml?xsl=list.xsl&';
	/*VREDNOSTI*/
	
	var urlToSend = toSerUrl;
	var sale = document.getElementById("sale").value;
	var purpose = document.getElementById("purpose").value;
	var type1 =  document.getElementById("type1").value;
	var priceTo = document.getElementById("priceTo5").value;
	var priceFrom = document.getElementById("priceFrom5").value;
	var locality2 = document.getElementById("locality2").value;
	var area = document.getElementById("area").value;
	var currency = document.getElementById("currency").value;
	var pool = document.getElementById("pool").checked;
	var garage = document.getElementById("garage").checked;
	var seafront = document.getElementById("seafront").checked;
	var garden = document.getElementById("garden").checked;
	var view = document.getElementById("view").checked;
	
	urlToSend += 'forletting='+sale;
	urlToSend += '&purpose='+purpose;
	if(type1 != 0){
		urlToSend += '&type1='+type1;
	}
	switch(purpose){
		case "38":
			var type21 = document.getElementById("type21").value;
			var type31 = document.getElementById("type31").value;
			if(type21 != 0){
				urlToSend += '&type2='+type21;
			}
			if(type31 != 0){
				urlToSend += '&type3='+type31;
			}
		break;
		case "37":
			var type22 = document.getElementById("type22").value;
			var type32 = document.getElementById("type32").value;
			if(type22 != 0){
				urlToSend += '&type2='+type22;
			}
			if(type32 != 0){
				urlToSend += '&type3='+type32;
			}
		break;
	}
	
	/*
	if(type2 != 0){
		urlToSend += '&type2='+type2;
	}
	if(type3 != 0){
		urlToSend += '&type3='+type3;
	}
	*/
	if(locality2 != 0 && area == 0){
		urlToSend += '&locality='+locality2;
	}
	if(area !=0 && locality2 == 0){
		urlToSend += '&area='+area;	
	}
	if(priceFrom != 'From' && priceFrom != ''){
		urlToSend += '&pricefrom='+priceFrom;
	}
	if(priceTo != 'To' && priceTo != ''){
		urlToSend += '&priceto='+priceTo;
	}
	if((priceFrom != 'From' && priceFrom != '') || (priceTo != 'To' && priceTo != '')){
		urlToSend += '&currency='+currency;
	}else{
		urlToSend += '&currency=EUR';	
	}
	if(pool == true){
		urlToSend += '&pool=1';
	}
	if(garage == true){
		urlToSend += '&garage=1';
	}
	if(seafront == true){
		urlToSend += '&seafront=1';
	}
	if(garden == true){
		urlToSend += '&garden=1';
	}
	if(view == true){
		urlToSend += '&fview=1';
	}
	window.location = urlToSend;
}
function clearAllxxx(){
	document.getElementById("locality2").value = 0;
	document.getElementById("sale").value = 0;
	document.getElementById("purpose").value = 38;
	document.getElementById("type1").value = 0;
	document.getElementById("Residential1").style.display="block";
	document.getElementById("Residential2").style.display="block";
	document.getElementById("Commercial1").style.display="none";
	document.getElementById("Commercial2").style.display="none";
	document.getElementById("type21").value = 0;
	document.getElementById("type31").value = 0;
	document.getElementById("priceTo5").value = "To";
	document.getElementById("priceFrom5").value = "From";
	document.getElementById("pool").checked = false;
	document.getElementById("garage").checked = false;
	document.getElementById("seafront").checked = false;
	document.getElementById("garden").checked = false;
	document.getElementById("view").checked = false;
}
/*Coockie for search
function selectSelc(name,val){
	var sel = document.getElementById(name);
	sel.options[val].selected = true;
}
function startCookies(){
	
	if(readCookie("bay") != "" && readCookie("bay") != 'unidentified'){
		selectSelc("bay",readCookie("bay"));
	}
	if(readCookie("type") != "" && readCookie("type") != 'unidentified'){
		selectSelc("type",readCookie("type"));
	}
	if(readCookie("type2") != "" && readCookie("type2") != 'unidentified'){
		selectSelc("type2",readCookie("type2"));	
	}
	if(readCookie("locality") != "" && readCookie("locality") != 'unidentified'){
		selectSelc("locality",readCookie("locality"));
	}
	if(readCookie("pricefrom0") != "" && readCookie("pricefrom0") != 'unidentified'){
		selectSelc("pricefrom0",readCookie("pricefrom0"));	
	}
	if(readCookie("priceto0") !== "" && readCookie("priceto0") != 'unidentified'){
		selectSelc("priceto0",readCookie("priceto0"));	
	}
	if(readCookie("pricefrom1") != "" && readCookie("pricefrom1") != 'unidentified'){
		selectSelc("pricefrom1",readCookie("pricefrom1"));	
	}
	if(readCookie("priceto1") !== "" && readCookie("priceto1") != 'unidentified'){
		selectSelc("priceto1",readCookie("priceto1"));	
	}
	if(readCookie("pricefrom2") != "" && readCookie("pricefrom2") != 'unidentified'){
		selectSelc("pricefrom2",readCookie("pricefrom2"));	
	}
	if(readCookie("priceto2") !== "" && readCookie("priceto2") != 'unidentified'){
		selectSelc("priceto2",readCookie("priceto2"));	
	}
	/*
	selectSelc("bay",readCookie("bay"));
	selectSelc("type",readCookie("type"));
	selectSelc("type2",readCookie("type2"));
	selectSelc("locality",readCookie("locality"));
	selectSelc("pricefrom0",readCookie("pricefrom0"));
	selectSelc("priceto0",readCookie("priceto0"));
	selectSelc("pricefrom1",readCookie("pricefrom1"));
	selectSelc("priceto1",readCookie("priceto1"));
	selectSelc("pricefrom2",readCookie("pricefrom2"));
	selectSelc("priceto2",readCookie("priceto2"));
	
}
function startCookieSelectedQS(idName){
	var ar = new Array();
	var co = document.getElementById(idName);
	
	coockieStaus(idName,co.value,1,1);
	
	
	/*
	var bay = document.getElementById("bay");
	var type = document.getElementById("type");
	var type2 = document.getElementById("type2");
	var locality = document.getElementById("locality");
	var pricefrom0 = document.getElementById("pricefrom0");
	var priceto0 = document.getElementById("priceto0");
	var pricefrom1 = document.getElementById("pricefrom1");
	var priceto1 = document.getElementById("priceto1");
	var pricefrom2 = document.getElementById("pricefrom2");
	var priceto2 = document.getElementById("priceto2");
	coockieStaus("bay",bay.value,1,1);
	coockieStaus("type",type.value,1,1);
	coockieStaus("type2",type2.value,1,1);
	coockieStaus("locality",locality.value,1,1);
	coockieStaus("pricefrom0",pricefrom0.value,1,1);
	coockieStaus("priceto0",priceto0.value,1,1);
	coockieStaus("pricefrom1",pricefrom1.value,1,1);
	coockieStaus("priceto1",priceto1.value,1,1);
	coockieStaus("pricefrom2",pricefrom2.value,1,1);
	coockieStaus("priceto2",priceto2.value,1,1);
	
}
function coockieStaus(c_name,c_val,c_stat,c_days){
	// c_stat 0 delete, 1 start
	switch(c_stat){
		case 1:
			createCookie(c_name,c_val,c_days);
		break;
		case 0:
			eraseCookie(c_name);
		break;
	}
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	setCookie(name,-1);
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
/*END OF COOKIE*/

//amos
function remeberQS(){
selectedQS.add('type',document.getElementById('type').selectedIndex);
selectedQS.add('type2',document.getElementById('type2').selectedIndex);
selectedQS.add('locality',document.getElementById('locality').selectedIndex);
selectedQS.add('bay',document.getElementById('bay').selectedIndex);
selectedQS.add('pricefrom0',document.getElementById('pricefrom0').selectedIndex);
selectedQS.add('priceto0',document.getElementById('priceto0').selectedIndex);
selectedQS.add('pricefrom1',document.getElementById('pricefrom1').selectedIndex);
selectedQS.add('priceto1',document.getElementById('priceto1').selectedIndex);
selectedQS.add('pricefrom2',document.getElementById('pricefrom2').selectedIndex);
selectedQS.add('priceto2',document.getElementById('priceto2').selectedIndex);
}


function setQS(){
document.getElementById('type').selectedIndex=selectedQS.read('type');
document.getElementById('type2').selectedIndex=selectedQS.read('type2');
document.getElementById('locality').selectedIndex=selectedQS.read('locality');
document.getElementById('bay').selectedIndex=selectedQS.read('bay');
document.getElementById('pricefrom0').selectedIndex=selectedQS.read('pricefrom0');
document.getElementById('priceto0').selectedIndex=selectedQS.read('priceto0');
document.getElementById('pricefrom1').selectedIndex=selectedQS.read('pricefrom1');
document.getElementById('priceto1').selectedIndex=selectedQS.read('priceto1');
document.getElementById('pricefrom2').selectedIndex=selectedQS.read('pricefrom2');
document.getElementById('priceto2').selectedIndex=selectedQS.read('priceto2');
izmeniPrice();
vidiTipove();
}

var selectedQS = {
pref:'',last:null,
cnfg:function(a1) {
	var Bool={secure:1}, text='';
	if (''+a1!==a1) for (var k in a1) if (a1[k]) text += '; '+(
		Bool[k] ? k : k+'='+(
			k!='expires'||isNaN(a1[k]) ? a1[k] : this.date(a1[k])
		)
	);
	return this.pref = text||a1||text;
},
date:function(a1) {
	var D = new Date();
	D.setTime(D.getTime()+(a1||0)*86400000);
	return D.toGMTString();
},
read:function(a1) {
	var F=' '+document.cookie+';', S=F.indexOf(' '+(a1=escape(a1)));
	return S==-1 ? null : unescape(
		F.substring(a1=S+a1.length+2,F.indexOf(';',a1))
	);
},
add:function(a1,a2) {
 var a3={expires:12,path:'/',domain:'.cassarcooper.com'}
 this.cnfg({ expires:12, path:'/', domain:'.cassarcooper.com' });
 document.cookie = this.last=escape(a1)+'='+escape(a2)+';'+this.cnfg(a3);
}
}
//amos end
