var properties = []; var buttons = []; buttons['price_1'] = ['divbutton_1', 0, '500']; buttons['price_2'] = ['divbutton_2', 0, '600']; buttons['price_3'] = ['divbutton_1', 0, '700']; buttons['price_4'] = ['divbutton_2', 0, '1000']; buttons['price_5'] = ['divbutton_1', 0, '2000']; buttons['price_6'] = ['divbutton_2', 0, '-1']; buttons['bedroom_1'] = ['divbutton_1', 1, '1']; buttons['bedroom_2'] = ['divbutton_2', 1, '2']; buttons['bedroom_3'] = ['divbutton_1', 1, '3']; buttons['bedroom_4'] = ['divbutton_2', 1, '4']; buttons['bedroom_5'] = ['divbutton_1', 1, '5']; buttons['bedroom_6'] = ['divbutton_2', 1, '-1']; buttons['location_29'] = ['divlist_1', 2, '29']; buttons['location_26'] = ['divlist_2', 2, '26']; buttons['location_1'] = ['divlist_1', 2, '1']; buttons['location_18'] = ['divlist_2', 2, '18']; buttons['location_15'] = ['divlist_1', 2, '15']; buttons['location_16'] = ['divlist_2', 2, '16']; buttons['location_0'] = ['divlist_1', 2, '-1']; var selected = []; $.cookie('sel_0') ? selected[0] = [$.cookie('sel_0'),"",buttons[$.cookie('sel_0')][2]] : selected[0] = ["price_6","","-1"]; $.cookie('sel_1') ? selected[1] = [$.cookie('sel_1'),"",buttons[$.cookie('sel_1')][2]] : selected[1] = ["bedroom_6","","-1"]; $.cookie('sel_2') ? selected[2] = [$.cookie('sel_2'),"",buttons[$.cookie('sel_2')][2]] : selected[2] = ["location_0","","-1"]; selected[3] = ""; //Selected property. var propertyState = 0; //0 = Properties in grid. 1 = Properties in right side, with the property info shown. 2 = Properties in moving state. function safeText(text) { return encodeURIComponent(text); } function initButtons() { for (var i in buttons) { initButton(i,buttons[i][0],buttons[i][1],buttons[i][2]); } } function initButton(id,defaultClass,type,realvalue) { //Attach the events to a div var hoverClass; var selectClass; if (type == 0 || type == 1) { selectClass = "divbutton_selected"; hoverClass = "divbutton_hover"; } if (type == 2) { selectClass = "divlist_selected"; hoverClass = "divlist_hover"; } if (selected[type][0] == id) document.getElementById(id).className = selectClass; $('#' + id).click(function() { if (selected[type][0] != "") document.getElementById(selected[type][0]).className = buttons[selected[type][0]][0]; selected[type][0] = this.id; selected[type][1] = this.className; selected[type][2] = realvalue; $.cookie('sel_' + type, this.id, { expires: 9936000, path: '/' }); this.className = selectClass; if (curPage == "lettings" || curPage == "") { searchProperties(selected[0][2], selected[1][2], selected[2][2]); } else { window.location = "/lettings/"; } }); $('#' + id).mouseover(function() { selected[type][1] = this.className; if (selected[type][0] != this.id) this.className = hoverClass; }); $('#' + id).mouseout(function() { if (selected[type][0] != this.id) this.className = selected[type][1]; }); } function searchProperties(price, bedrooms, location) { if (price == null) price = selected[0][2]; if (bedrooms == null) bedrooms = selected[1][2]; if (location == null) location = selected[2][2]; if (propertyState == 1) resetPropertiesPos(); $.ajax({ type: "POST", url: "/core/ajax/search.php", data: "price=" + price + "&bedrooms=" + bedrooms + "&location=" + location, success: function (responseText) { var responseSplit = responseText.split("|"); if (responseSplit[0] == "1" || responseSplit[0] == "2") { properties = JSON.parse(responseSplit[1], null); if (responseSplit[0] == "2") { drawProperties(responseSplit[2]); } else { drawProperties(""); } } else { alert("An error occurred. Please try agan."); } } }); } function drawProperties(suggestion) { var buffer = ""; var cacheBuffer = ""; if (suggestion != "") { buffer = suggestion; } document.getElementById('content').innerHTML = "

Loading...

"; for ( var i in properties ) { if(properties[i]['bedrooms'] == 0){ var bedroomsStr = 'Commercial'; }else if(properties[i]['bedrooms'] == 1){ var bedroomsStr = '1 bedroom'; }else{ var bedroomsStr = properties[i]['bedrooms'] + ' bedrooms'; } buffer += "\
\
\
\ " + bedroomsStr + ", " + properties[i]['price'] + "
\ " + properties[i]['street'] + "\
"; //cacheBuffer += "\"\"\"\""; } $("#content").html(buffer); buffer = "";cacheBuffer = ""; var offset = $("#content").offset(); $(".property_box_c").each(function(x){ var offset2 = $(this).offset(); var i = this.id; var iSplit = i.split("_"); i = iSplit[0]; properties[i]['relativeLeft'] = offset2.left - offset.left; // if (suggestion == "") { properties[i]['relativeTop'] = offset2.top - offset.top; // } else { // properties[i]['relativeTop'] = offset2.top - offset.top - $('#suggestion_message').height() - 21; // } }); $('.property_box').click(function() { if (propertyState == 0 || propertyState == 1) { if (selected[3] == this.id) return; movePropertiesToRight(this.id); getPropertiesInfo(this.id); document.getElementById(this.id).className = "property_box_selected"; if (selected[3] != "") { document.getElementById(selected[3]).className = "property_box"; $('#' + selected[3] + ' img').attr('src',properties[selected[3]]['image']); $('#' + selected[3] + ' .divheader2').css({background:"#DBD4C3", color:""}); } selected[3] = this.id; } if (propertyState == 0) { propertyState = 1; } }); $('.property_box').mouseover(function() { if (this.id == selected[3]) return; $('#' + this.id + ' img').attr('src',properties[this.id]['imagerollover']); $('#' + this.id + ' .divheader2').css({background:"#877138", color:"#FFFFFF"}); // background:"#877138", }); $('.property_box').mouseout(function() { if (this.id == selected[3]) return; $('#' + this.id + ' img').attr('src',properties[this.id]['image']); $('#' + this.id + ' .divheader2').css({background:"#DBD4C3", color:""}); }); } function switchImage(img) { document.getElementById('map_canvas_container').style.display = "none"; document.getElementById('property_large_img').style.display = "block"; document.getElementById('property_large_img').src = "images/blank.gif"; document.getElementById('property_large_img').src = img; } function movePropertiesToRight(id) { var realX = 0, realY = 0; var pcount = 0; var temp = []; for (var i in properties) if (i == id) temp[i] = properties[i]; for (var i in properties) if (i != id) temp[i] = properties[i]; for (var i in temp) { realX = 476 - temp[i]['relativeLeft']; realY = (pcount*217) - temp[i]['relativeTop']; $("#" + temp[i]['id'] + "_c").animate({top:realY+"px",left:realX+"px"},{queue:false,duration:500}); pcount++; } } function getPropertiesInfo(id) { //Grab property page from server with AJAX var header = "\
\ " + properties[id]['fullTitle'] + "\
\ \"\"\
"; $("#suggestion_message").fadeTo(100,0.1,function(){ // $(this).hide(); // window.alert($this); var heightString = "" + $("#suggestion_message").height() + "px"; // $("#suggestion_message").css({position:"absolute",zIndex: -1, width:10}); $("#suggestion_message").css({position:"relative",left:-9999,width:"4px", height: heightString,overflow:"hidden"}); }); $("#property_info_header").html(header); $("#property_info_content").html("
"); $("#property_info_container").stop(); $("#property_info_container").css({opacity:0}); $("#property_info_container").show(); $("#property_info_container").animate({opacity:1},{queue:false,duration:500}); $.ajax({ type: "POST", url: "/core/ajax/getproperty.php", data: "id=" + id, success: function (responseText) { $("#property_info_content").html(responseText); scroll(0,0); } }); } function resetPropertiesPos() { if (propertyState != 1) return; propertyState = 2; $("#property_info_container").stop(); $("#property_info_container").css({opacity:0}); $("#property_info_container").css({display:"none"}); $("#suggestion_message").css({position:"relative",left:0,width:"auto", height:"auto",overflow:"hidden"}); $("#suggestion_message").fadeTo(500, 1); for ( var i in properties ) { $("#" + properties[i]['id'] + "_c").animate({top:"0px",left:"0px"},{queue:false,duration:500}); } if (selected[3] != "") { document.getElementById(selected[3]).className = "property_box"; $('#' + selected[3] + ' img').attr('src',properties[selected[3]]['image']); $('#' + selected[3] + ' .divheader2').css({background:"#DBD4C3", color:""}); } selected[3] = ""; setTimeout('propertyState = 0;',600); } function closeHover(state) { if (state == 1) { document.getElementById('closeButton').src = "/images/close_hover.gif"; }else{ document.getElementById('closeButton').src = "/images/close.gif"; } } function kpulogin(e) { var keynum; if (window.event) { //IE keynum = e.keyCode; } else if (e.which) { //FF/NS/Opera/etc keynum = e.which; } if (keynum == 13) { ulogin(); } } function ulogin() { $("#ulogin_result").html("Logging in..."); $.ajax({ type: "POST", url: "/core/ajax/login.php", data: "email=" + safeText($("#e").val()) + "&password=" + safeText($("#p").val()), success: function (responseText) { if (responseText == "2") $("#ulogin_result").html("Invalid email/password, please try again."); else if (responseText == "1") { window.location = "/landlords-info/"; } else $("#ulogin_result").html("Login Error. Please try again later."); } }); } function ulogout() { $.ajax({ type: "POST", url: "/core/ajax/logout.php", success: function (responseText) { window.location = "/landlords-info/"; } }); }