var returnUrl = "";
var baseDomain = "http://" + window.location.hostname;
function wopen(url, name, w, h){w += 32;h += 96;wleft = (screen.width - w) / 2;wtop = (screen.height - h) / 2; var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');}
function redirect(url) { window.location = url; }
function navigateWithReferrer(url)
{
    var fakeLink = document.createElement ("a");
    if (typeof(fakeLink.click) == 'undefined')
        location.href = url; 
    else
    {
        fakeLink.href = url;
        document.body.appendChild(fakeLink);
        fakeLink.click();  
    }
}
function n(url) { navigateWithReferrer(url); }
function uncache(url){var d = new Date();var time = d.getTime();return url + '&uct='+time;}
function sKey() {var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13){doSearch();return false;}else return true;}
function ssKey() {var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13){doSignup();return false;}else return true;}
function getValue(obj) { if (obj != null) { return obj.options[obj.selectedIndex].value;}}
function getStyleObject(objectId) { if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) {return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) {return document.layers[objectId]; } else { return false; }}
function changeObjectVisibility(objectId, newVisibility) { var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; if (newVisibility == "visible") { styleObject.display = 'block'; } else { styleObject.display = 'none'; }return true; } else { return false; }}
function Disable(obj) {try { obj.disabled = true; } catch (exception) { }}
function Enable(obj) {try { obj.disabled = false; } catch (exception) { }}
function HomePage() { if ( ! document.all ) { alert("This function doesn't work under Mozilla Browsers - Netscape or FireFox! \n\nPlease set it at:\n\tEdit/Preferences/Navigator \nmanualy!"); } else { newHomepage.style.behavior='url(#default#homepage)';newHomepage.setHomePage(baseDomain); } }
function textCounter(o, maxlimit) { var charsleft = (maxlimit - o.value.length); document.getElementById('charsleft').innerHTML = charsleft; if (charsleft <= 0) { o.value = o.value.substring(0, maxlimit); }}
function printPage() {window.print();}
function co(obj) { obj.className = "menuItem_on"; }
function cob(obj) { obj.className = "b_on"; }
function ct(obj) { obj.className = "menuItem_off"; }
function plo(obj) { obj.className = "plo"; }
function pl(obj) { obj.className = "property"; }
function cb(obj) { obj.className = "b"; }
function ro(obj) { obj.className = "n_on"; }
function rt(obj) { obj.className = "n_off"; }
function cso(obj) { obj.className = "submenuItem_on"; }
function cst(obj) { obj.className = "submenuItem_off"; }
function cmo(obj) { obj.className = "mi_on"; }
function cmb(obj) { obj.className = "mi"; }
jQuery.fn.selectOptions = function(value) {
	this.each(
		function()	{
			if(this.nodeName.toLowerCase() != "select") return;
			// get number of options
			var optionsLength = this.options.length;
			for(var i = 0; i<optionsLength; i++) {
					this.options[i].selected = false;
			}
			for(var i = 0; i<optionsLength; i++) {
				if (this.options[i].value == value) {
					this.options[i].selected = true;
					break;
				};
			}
		}
	)
	return this;
}
function QueryString(strParamName){
var strReturn = "";var strHref = window.location.href;if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");strReturn = aParam[1];break;}}}return unescape(strReturn);}
function Bookmark(obj, targetid) { $('#bookmarks').show(); $.getIfModified("/ajaxsetbookmark", { tid: targetid}, function(data) { $(obj).parent().TransferTo({to:'bookmarks',className:'trans1', duration: 1000,complete:function(){$('#tbi').html(data);$('#bm_' + targetid).hide(600);}});});return false; }
function SetDDL(ddlID, value) {
$("#" + ddlID).selectOptions(value);
} 

function vRefId() { 
if (isNaN($('#ref_id').val())) { $('#ref_id').css({ color: "red" }); } else { $('#ref_id').css({ color: "#000" }); }
return true; }

function getCheckBoxValues(cbField) {var result = "";for (i=0; i < cbField.length; i++) { if (cbField[i].checked) { result += cbField[i].value + ";" } }return result;}

function doSearch() { 
//encodeURIComponent(

var ss = "/search/?u=s";
var property_type = $('#ds_pt').val();
if ((property_type != "") && (property_type != null)) ss+= "&t=" + property_type;

var price_range = $('#ds_pricerange').val();
if ((price_range != "") && (price_range != null)) ss+= "&pr=" + price_range;

var area_range = $('#ds_area').val();
if ((area_range != "") && (area_range != null)) ss+= "&a=" + area_range;

var district = $('#ds_district').val();
if ((district != "0") && (district != "") && (district != null)) ss+="&d=" + district;

var countryCode = $('#ddlCountryCode').val();
if ((countryCode != "") && (countryCode != null)) ss+="&c=" + countryCode;

var renovation = $('#ddlRennovationStatus').val();
if ((renovation != "") && (renovation != null)) ss+="&rn=" + renovation;

var parking = $('#ddlParking').val();
if ((parking != "") && (parking != null)) ss+="&pk=" + parking;

var receptionrooms = $('#ds_receptionrooms').val();
if ((receptionrooms != "0") && (receptionrooms != "") && (receptionrooms != null)) ss+="&rr=" + receptionrooms;

var bedrooms = $('#ds_bedrooms').val();
if ((bedrooms != "0") && (bedrooms != "") && (bedrooms != null)) ss+="&br=" + bedrooms;

var bathrooms = $('#ds_bathrooms').val();
if ((bathrooms != "0") && (bathrooms != "") && (bathrooms != null)) ss+="&bb=" + bathrooms;

var floor = $('#ddlFloor').val();
if ((floor != "0") && (floor != "") && (floor != null)) ss+="&fl=" + floor;

var zipcode = $('#zipcode').val();
if ((zipcode != "") && (zipcode != null)) ss+="&z=" + zipcode;

var address = $('#address').val();
if ((address != "") && (address != null)) ss+="&st=" + encodeURIComponent(address);

var construction_year = $('#construction_year').val();
if ((construction_year != "") && (construction_year != null)) ss+="&cy=" + construction_year;

var ref = $('#ref_id').val();
if ((ref != "") && (ref != null)) ss+="&ri=" + ref;

if ($("input[@id='extras']:checked").val() != null) { 
//ss+="&ex=" + $("input[@id='extras']:checked").val();
 // alert($("input[@id='extras']:checked").val());
 // alert(getCheckBoxValues(document.getElementById('extras')));
}

var cprice1 = $('#cprice1').val();
var cprice2 = $('#cprice2').val();

if ((cprice1 != "") && (cprice2 != "")) ss+="&cp1=" + cprice1 + "&cp2=" + cprice2 + "&cpcur=" + $('#cpcurrency').val();;
if (ss != "/search/?u=s&c=HU") { n(ss); } else { alert('Please choose additional search parameter'); }

}

$(document).ready(function(){$(document).ScrollToAnchors(630);

var myPath = window.location.pathname.toLowerCase();
//Set DDLs (defined in search.js) 
if (myPath == "/search/") { SetSearchDDL(); }

MakePropertyListingClickable();


});

function MakePropertyListingClickable() { 

$(".property").css("cursor","pointer");

try {

$(".property").click(function () {
n($(this).find("a").attr("href"));
 });

 }
catch(e) {}

}

function ToggleSearchMode() { 

$('#detailedsearch').BlindToggleVertically(300, null, 'bounceout');

if ($('#txtdsearch').html() == 'Detailed Search') { 
$('#txtdsearch').html('Quick Search');
} else { 
$('#txtdsearch').html('Detailed Search');
}

return false;

}
function Send(id) {wopen ('/sendpage?pid=' + id, 'Send_page', 430, 340);}