function Go(url){
	if (url=="") return;
	try {
	window.location.href="http://www.discover-bulgaria.com/" + url;
	} catch (e){}
}
function Search(){
					var SearchBox = document.getElementById("SearchBox");
					var srch=SearchBox.getElementsByTagName("INPUT")(0);
					var TypeID = SearchBox.getElementsByTagName("SELECT")(0);
					//window.location.href='Search.aspx?TypeID=' + TypeID.options[TypeID.selectedIndex].value + '&srchString=' + escape(srchString.value); 
					window.location.href= "http://www.discover-bulgaria.com/" + TypeID.options[TypeID.selectedIndex].value + 'srchString=' + escape(srchString.value); 
}

var Regions
function getsearchfields(f){
	var loc = f.elements[3];
	var sparams;
	sparams= "";
	if (f.locationtype.selectedIndex > 0) sparams += "&locationtype=" + f.locationtype.options[f.locationtype.selectedIndex].value;
	if (f.type.selectedIndex > 0) sparams += "&type=" +  f.type.options[f.type.selectedIndex].value;
	if (f.region.selectedIndex > 0) sparams += "&region=" +  f.region.options[f.region.selectedIndex].value;
	if (loc.selectedIndex> 0) sparams += "&location=" +  loc.options[loc.selectedIndex].value;
	if (f.PriceFrom.value!="") sparams += "&pricefrom=" + f.PriceFrom.value;
	if (f.PriceTo.value!="") sparams += "&priceto=" + f.PriceTo.value;
	if (f.order.value!="") sparams += "&order=" + f.order.value;
	return sparams;
}

function addasalert(btn){
	var f = btn.form;
	var sparams = getsearchfields(f);
	window.location.href="Member_Alerts.asp?action=save" + sparams;
}
function addassearch(btn){
	var f = btn.form;
	var sparams = getsearchfields(f);
	window.location.href="Member_Searches.asp?action=save" + sparams;
}

function chLocationType(lt){
try {
	var f = lt.form;
	if ((lt.selectedIndex==1) || (lt.selectedIndex==2)) {
		if (f.region.selectedIndex!=1) {
			f.region.selectedIndex = 1;
			loadcities(f.region);
		}
	}
} catch (e) {}
}

function mail(id) {
try {
var win;
win = window.open("Send.asp?OfferID="+id,'SendOffer','height=450,width=800,scrollbars=1,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
win.focus();
}
catch (exception) {return}
}

function prnt(id) {
try {
var win;
win = window.open("Print.asp?OfferID="+id+"&action=print",'PrintOffer','height=400,width=620,scrollbars=1,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
win.focus();
//win.window.print()
}
catch (exception) {return}
}

function Show(ID){
	var wwidth=388;
	var wheight=280;
	var winw = (screen.width - wwidth) / 2;
	var winh = (screen.height - wheight) / 2;
	//var gallery_newpwin = window.open("show_picture.html?" + ID,"gallery","resizable=1,scrollbars=0,width="+wwidth+",height="+wheight+",top=100,left="+winh);
	try
	{
		var gallery_newpwin = window.open("about:blank","gallery","resizable=1,scrollbars=1,width="+wwidth+",height="+wheight+",top=100,left="+winh);
		gallery_newpwin.focus();
		gallery_newpwin.document.write("<HTML><HEAD><title>Gallery</title></HEAD>");
		gallery_newpwin.document.write("<script>function resize(){try{var img = document.images[0];window.resizeTo(img.width+15+20,img.height+65);}catch(e){}window.focus();}</" + "script>");
		gallery_newpwin.document.write("<body dir=rtl topmargin=2 leftmargin=2 bottommargin=0 rightmargin=0 onload='resize();'>	<img src='http://www.partners4properties.net/photos/original/" + ID + "'></body></HTML>");
		gallery_newpwin.document.close();
	}
	catch (e)
	{
		var gallery_newpwin = window.open("Image.asp?url=photos/original/" + ID,"_blank","resizable=1,scrollbars=1,width="+wwidth+",height="+wheight+",top=100,left="+winh);
		gallery_newpwin.focus();
	}
}

function nan (obj) {
	if (isNaN(obj.value)) {
		for (var i=0;i<obj.value.length;i++) { 
			if (isNaN(obj.value.charAt(i))) { obj.value = obj.value.replace (obj.value.charAt(i), '') }
		} 
		obj.focus(); 
	} 
}
function AddToWishList(OfferID){
	if (!(wlcount<wllimit)) {
		alert ("Your wish list is full! You can not add more than " + wllimit + " offers to it.");
		return;
	}
	var wwidth=260;
	var wheight=100;
	var newwin
	var winw = (screen.width - wwidth) / 2;
	var winh = (screen.height - wheight) / 2;
	//wlcount++;
    newwin = window.open("Properties_Wish_List.asp?OfferID=" + OfferID,"cities","width="+wwidth+",height="+wheight+",top="+winw+",left="+winh+"");
}

	var newwin
	function loadcities(lb)
	{
		var qry;
		var wwidth=260;
		var wheight=100;
		try {
			var targetlist = lb.form.location;
			var regions = lb.form.region;
		}
		catch (e) {
			var targetlist = document.getElementById('location');
		}
		targetlist.clear
		if (regions.selectedIndex == 0) {
			targetlist.length = 0;
			return;
		}
		targetlist.length = 1;
		targetlist.options[0].text="Loading...";
		targetlist.options[0].value="";
		qry = lb.options[lb.selectedIndex].value;		
		qryt = lb.options[lb.selectedIndex].text;		
		var winw = (screen.width - wwidth) / 2;
		 var winh = (screen.height - wheight) / 2;
		targetlist.focus();

	    newwin = window.open("about:blank","cities","width="+wwidth+",height="+wheight+",top="+winw+",left="+winh+"");
		newwin.focus();
		var doc ="<html><head><title>Loading "+ qryt + "....</title>";
		doc += "</head><body>";
		doc += "<p align='center' class='hotel_search_loadcities'>Loading region " + qryt.toUpperCase() + "!</p><span id=pnlSearch></span>\n";
		doc += "&lt;script language='JavaScript'&gt;\n";
		doc += "var intLeft = 300;\n";
		doc += "function TimerAlert(){\n";
		doc += "	if (0==intLeft){\n";
		doc += "		intLeft = 300;\n";
		doc += "		TimerAlert();\n";
		doc += "	} else {\n";
		doc += "		A = (300 - intLeft)\n";
		doc += "		document.getElementById('pnlSearch').innerHTML=(\"<table align=left border=1><td width=\" + A + \" height=12 ></td></table>\");\n";
		doc += "		intLeft -=1;\n";
		doc += "		setTimeout('TimerAlert()',10)\n";
		doc += "	}\n";
		doc += "}TimerAlert();\n"
		
		doc += "opener.changeurl('"+qry+"');&lt;/script&gt;\n";
		doc += "</body></html>";
		doc=doc.replace(/&gt;/g, "\>");				
		doc=doc.replace(/&lt;/g,"\<");				
		//var doc ="<html> <head><LINK href='hoteli.css' type='text/css' rel='stylesheet'>";
		//doc += "</head> <body>  <p align='center'>Loading...!</p><" + "script language='JavaScript'>opener.changeurl(''+qry+'');</" + "script></body> </html>";
    	newwin.document.write(doc);
	}
	
	function changeurl(qry1)	
	{	
		newwin.location.href = ("loadregion.asp?region=" +qry1)
	}
	
	function makeOptions(sCities, sCount)	
	{
	try {
		var targetlist = region.form.location;
	}
	catch (e) {
		var targetlist = document.getElementById('location');
	}
	var op_text;
	var op_value;
	var op_defsel = false;
	var op_sel = false;
	var op;

	var i=0;
	targetlist.clear
	targetlist.length = 0;
	//targetlist.options[0].text="=== Entire region ===";
	//targetlist.options[0].value="";
	if (sCities=="") return;
	oarray = sCities.split(',');
	while (i<oarray.length)
	{
			var barray = oarray[i].split("|")
			op_text = barray[0];
			op_value = barray[1];
			if (op_text!="") {
				targetlist.length++;
				targetlist.options[targetlist.length-1].value = op_value
				targetlist.options[targetlist.length-1].text = op_text
				//op = new Option(op_text, op_value, op_defsel, op_sel);
				//targetlist.options[targetlist.length] = op;
			}
			i++;
	}
	targetlist.options[0].selected=true;
	if (document.layers)
		{
		self.resizeBy(-1,-1);
		self.resizeBy(1,1);
		}
	}

function checkrequest(f){
try {
	if (f.ClientName.value=="") {
		alert ("Please fill your name");
		f.ClientName.focus();
		return false;
	}
	if (f.Email.value=="") {
		alert ("Please fill your email");
		f.Email.focus();
		return false;
	}
	if ((f.Email.value.indexOf("@")<1) || (f.Email.value.indexOf(".")<1)) {
		alert("Email address is invalid.");
		f.Email.focus();
		return false;
	}
	}
	catch (e) {}
	if (f.City.value=="") {
		alert ("Please fill your city");
		f.City.focus();
		return false;
	}
	if (f.Country.value=="") {
		alert ("Please fill your country");
		f.Country.focus();
		return false;
	}
	return true;
}
