var testo = '';
var idcomune = 0;
var isNewSearch = true;
function goToNewSearch(event) {
isNewSearch = true;
idcomune = 0;
var flagvendita = $j("input[@name='rdVendita']:checked").val();
testo = $j("#lblCerca").text();
if (flagvendita == '1') testo+= " vendita";
else testo+= " affitto";
$j("div#grpResult").css("display", "none");
resetPagingFilter();
clearGoogleMarker();
$j('div#pnlProgress').modal();
cerca(this);}
function cercaDis(value) {
idcomune = value;
var flagvendita = $j("input[@name='rdVendita']:checked").val();
if (flagvendita == '1') testo = "vendita";
else testo = "affitto";
$j("div#grpResult").css("display", "none");
resetPagingFilter();
clearGoogleMarker();
$j('div#pnlProgress').modal();
cerca(this);}
function getResult(obj) {
if(isNewSearch){
$j(".clnnws").html("");
$j(".clnnws").css("display", "none");
$j("div#SearchSaved").css("display", "block");
$j("div#BoxRicercaMappa").css("width", "828px");
$j("div#BoxRicercaMappaHeader").css("width", "828px");
$j("div#BoxRicercaMappaHeaderCenter").css("width", "810px");
$j("div#BoxRicercaMappaBody").attr("style", "height:480px; width:826px !important; width: 828px;");
$j("div#BoxRicercaMappaFooth").css("width", "828px");
$j("div#BoxRicercaMappaFoothCenter").css("width", "810px");
$j("div#BoxRicercaMappaBodyInfoHeader").css("width", "580px");
$j("div#BoxRicercaMappaBodyRicerca").css("width", "580px");
$j("div#BoxRicercaMappaBodyRicercaContent").css("width", "580px");
$j("div#BoxRicercaMappaBody").append($j("div#Memorandum"));
$j("div#BoxRicercaMyDiv").css("width", "600px");
$j("div#BoxRicercaMappaBody").append($j("div#map"));
$j("div#map").attr("style", "width:580px; height:310px; position:relative; top: 10px; left:10px; clear:both;");
$j("div#BoxGoogleMap").remove();
$j("div#TitleBoxMemorandumImmobiliSelect").remove();
$j("div#TitleBoxMemorandumImmobiliCommand").remove();
$j("div#BoxMemorandumHeader").css("width", "215px");
$j("div#BoxMemorandum>.top_spacing").css("height", "5px");
$j("div#Memorandum").attr("style", "width:215px !important; width: 215px;; float:right; margin-right: 5px;");
$j("div#BoxMemorandum").attr("style", "width:215px !important; width: 215px;");
$j("div#BoxMemorandumHeaderCenter").css("width", "196px");
$j("div#BoxMemorandumBody").attr("style", "width: 212px !important; width: 208px;");
$j("div#BoxMemorandumFoothCenter").css("width", "196px");
$j("div#SavedResult").attr("style", "padding-left: 5px; width: 212px;");
$j("div#lblImmobiliSelect").remove();
$j("div#lblCommand").remove();
isNewSearch = false;}
pageResult(obj);
$j.modal.close();}
function cerca(obj) {
var params = null;
if (idcomune == 0) $j("div#pnlResult").html('');
if (idcomune == 0)
params = {
json: 'true',
op: 'GetResult',
iIDCom: 0,
testo: testo,
iCurrentIndex: indexToRequest,
orderExp: orderExp,
orderDir: orderDir};
else
params = {
json: 'true',
op: 'GetResult',
iIDCom: idcomune,
testo: testo,
iCurrentIndex: indexToRequest,
orderExp: orderExp,
orderDir: orderDir};
$j.getJSONsecure(domainName+"HandlerUIQuickSearch.ashx?jsoncallback=?", params, getResult);}
function loadGeoIP(obj) {
if(obj.error) {
if(obj.errorCode == 1) window.location.href = 'working.html'; return;}
GetGeoIp(obj);}
function initPage(obj) {
if (!$j) setTimeout(function() { initPage(obj); }, 200);
$j(document).ready(function() {
$j("div#grpResult").css("display", "none");
$j("div#CommandSearch").click(goToNewSearch);
resetPagingFilter();
initMap($j("#lblCerca"), $j("window"));
$j.getJSONsecure(domainName+"HandlerUIGeoIP.ashx?jsoncallback=?", { json: 'true', op: 'GetGeoIp' }, loadGeoIP);});}
initPage();
