window.onresize = function  () {
    
    //if ($("#property_full_details").size() > 0)
   // $("#property_full_details").center();
}

//window.onbeforeprint = function () {
 //   alert(1)
    //$("#page").css("display","none");
   // $("#property_full_details").css ({
   //     left:"0px",
  //      top: "0px"
    //})
    
   // $("#property_description, #property_area").css({width:"600px"})
//}




//window.onafterprint = function () {
   // $("#page").css("display","block");
   // $("#property_full_details").center();
   // $("#property_description, #property_area").css({width:"700px"})
//}



jQuery.fn.center = function () {
    
    var _this = $(this[0]);
    
    
    this.css("position","absolute");
    //this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("top","10px");
    //this>css("margin","0 auto")
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    
    //$(_this).css({position: "relative", margin: "0 auto"})
    
    //var l = $(_this).position().left;
    //var t = $(_this).position().top;
    
    //$(_this).css({ top: "10px;"})
    
   
    
    
    
    
    //return this;
}

jQuery.fn.setFooter = function () {
    if ($("#address_list").size()>0) {
        var t = parseInt($("#address_list").css("height")) +  parseInt($("#content").css("top")) + 280;
        
        $("#bottom_divider").css ({top: t + "px"})
        t+=10;
        $("#footer").css ({top: t + "px"})
        
    }
    
}



house = function (id) {
    var _this = this;
    _this.initialize(id);
}

house.prototype.host = "http://" + top.location.host + "/";
house.prototype.href = top.location.href;

house.prototype.getTags = function (tagname) {    
    var elements =  (document.getElementsByTagName("my:" + tagname).length>0) 
		? document.getElementsByTagName("my:" + tagname) 
		: document.getElementsByTagName(tagname) ;
    return elements;
}

house.prototype.page = function () {
    var _this = this;
    return _this.href.substring(_this.href.lastIndexOf('/') + 1);
}

house.prototype.createUUID = function () {
    // http://www.ietf.org/rfc/rfc4122.txt 
    var s = [];
    var hexDigits = '0123456789ABCDEF';
    for (var i = 0; i < 32; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[12] = '4';  // bits 12-15 of the time_hi_and_version field to 0010 
    s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01 
    var uuid = s.join('');
    return uuid;
}

house.prototype.options = {
    page: house.prototype.page(),
    eaid: 209,
    bid: 298,
    api_key: "3ABAC73C-97D2-48FE-AB36-7AA4655E04AA",
    /*dezrez: "http://www.dezrez.com/DRApp/DotNetSites/WebEngine/property/Default.aspx",*/
    dezrez: "http://www.dezrez.com/DRAPP/DotNetSites/WebEngine/Property/",
    latestproperties: "latestproperties.aspx",
    sessionGUID : house.prototype.createUUID(),
    php_file : "/modules/house/house.php"
}

/*
 http://www.dezrez.com/DRAPP/DotNetSites/WebEngine/Property/pictureResizer.aspx?eaid=209&apikey=3ABAC73C-97D2-48FE-AB36-7AA4655E04AA&pid=2380708&bid=298&picture=1&width=100
 **/

house.prototype.setPriceSelect = function (sel_box, default_val, no_max) {
    
    
        var _no_max = no_max ? no_max : false;
        var html = "";
        //html+= "<li value=-1>Auction</li>";
        html += "<li value=" + default_val +  " selected>Not specified</li>";
    
        //$("#" + sel_box).append("<my:combo_box_body>");
        //$("#" + sel_box).append("<option value=-1>Auction</option>");
        //$("#" + sel_box).append("<option value=" + default_val +  " selected>Not specified</option>")
        html+= "<li value=50000>&pound;50000</li>";
        for (var v=100000; v<400000; v+=25000) {
            //$("#" + sel_box).append("<option value=" + v + ">&pound;" + v + " </option>")
            html += "<li value=" + v + ">&pound;" + v + "</li>";
        }
        for (v=400000; v<=700000; v+=50000) {
            html += "<li value=" + v + ">&pound;" + v + "</li>";
            //$("#" + sel_box).append("<option value=" + v + ">&pound;" + v + " </option>")
        }
        
        if (no_max) html += "<li value=" + 1000000 + ">No Maximum</li>";
        html += "";
        //$("#" + sel_box).append("</my:combo_box_body>");
        $("#" + sel_box).html(html);
}

house.prototype.setBedroomSelect = function (sel_box) {
    
    var html = "";
    html += "<li selected=\"1\" value=1>Not specified</li>";
    //$("#" + sel_box).append("<option value=1 selected>Not specified</option>");
    for (var v=1; v<=5; v++) {
        var bedrooms = (v===1) ? "bedroom" : "bedrooms";
        //$("#" + sel_box).append("<option value=" + v + ">" + v + " " + bedrooms + "</option>")
        html += "<li value=" + v + ">" + v + " " + bedrooms + "</li>";
    }
    html += "";
    $("#" + sel_box).html(html);
}

house.prototype.dezrez_image = function (id, width) {
    var _this = this;
    width = width ? width : 100;
    var img = _this.options.dezrez + "pictureResizer.aspx?eaid=" + _this.options.eaid + 
              "&apikey=" + _this.options.api_key + 
              "&pid=" + id + 
              "&bid=" + _this.options.bid + 
              "&picture=1&width="+width;
    return img;
}

house.prototype.lastest_properties = function (element) {
    var _this = this;
    var _element = $("#" + element);
    
    var search_data = {};
    search_data.latest_properties = 2;    
    
    $.ajax({
        async: true,
        url: _this.options.php_file,
        data: search_data,
        dataType: "json",
        type: "POST",  
        cache: false,
        success: function (response) {
              
              var html = "<my:latest_properties><h2>Latest Properties</h2>";
              
              for (_p in response.getLatestSalesProperties.properties.property ) {
                  
                  html += "<my:latest_properties_item>";
                  var summaryDescription = response.getLatestSalesProperties.properties.property[_p]["summaryDescription"].split(".")[0].substr(0, 150);
                  var price = response.getLatestSalesProperties.properties.property[_p]["@attributes"]["price"];
                  var id = response.getLatestSalesProperties.properties.property[_p]["@attributes"]["id"];
                  var useAddress = response.getLatestSalesProperties.properties.property[_p]["useAddress"];
                  
                  var img = _this.dezrez_image(id,140);
                  
                  html += "<my:latest_image property_id=" + id +  "><img src=" + img + "></my:latest_image>"
                  html += "<my:item_price>" + price + "</my:item_price>";
                  html += "<my:item_address>" + useAddress + "</my:item_address>";
                  html += "<my:item_description>" + summaryDescription + "... <my:property_link property_id=" + id + ">more&gt;&gt;</my:property_link></my:item_description>";      
                  html += "</my:latest_properties_item>";
              }
              html += "</my:latest_properties>";
              _element.after(html);  
              
             var return_text = "&larr; return to home page";

             _this.add_property_details("latest_image", return_text);
             _this.add_property_details("property_link", return_text);
                    
        }
    });
}

house.prototype.load_banner = function () {
    var _this = this;
    var search_data = {};
    search_data.banner_images =  1;
    $.ajax({
        async: false,
        url: _this.options.php_file,
        data: search_data,
        dataType: "json",
        cache: false,
        success: function (response) {
            
            var html = "<my:fader id=main_banner_images>";
            for (var i=0; i<response.length; i++) {
                html += "<my:fader_item><img src='/modules/house/images/bannerimages/" + response[i] + "'></my:fader_item>";
            }
            html += "</my:fader>";
            $("#main_image_box").html(html)
            $('#main_banner_images').innerfade({
                animationtype: fades.main_banner_images.animationtype,
                speed: fades.main_banner_images.speed,
                timeout: fades.main_banner_images.timeout,
                type: fades.main_banner_images.type,
                containerheight: fades.main_banner_images.containerheight
            });
        },
        error: function(jqXHR, textStatus, errorThrown) {
            $("#main_image_box").html("&nbsp;")
        }
     });  
    
}

house.prototype.initialize = function (id) {
    var _this = this;

    $(document).ready(function () {
        
        
      $.ajax({
        async: false,
        cache: false,
        url: "/modules/house/template/main.html",
        success: function (response) {
            $(_this.getTags("page")[0]).html(response)
            
            
             _this.load_banner();
            
            
            var this_page = (_this.options.page != "") ? _this.options.page : "/";
            
            $('a[href$="' + this_page + '"]').each(function (){
                $(this).parent().addClass("over");
            })
 
      
      for (_e in grid) {
          for (_p in grid[_e]) {
              if (_p != "offset") $("#" + _e).addClass(grid[_e][_p])
          }
      }
      
      switch (_this.options.page) {
          case "" : case "index.php" : case "index_new.php" :
              _this.searchBox("content",null,"Property Search");
              _this.lastest_properties("content");
              break;
          case "property_search.php" :
              
              $("#page_header").html("Property Search\
                                    <p>If you would like to arrange to view any of hte properties shown on our website, please call us on 01778 349300</p>\
                                    <p>If you call out of office hours, please leave your name, contact number and details of the property you would like to view and we will call you back as soon as the office re-opens.</p>\
                                    ")
              $("#main_banner_images").remove();
              $("#house_image_purple").remove();
              
              _this.searchBox("content","searchbox_upper");
              
              _this.searchResults("content");
              break;
          default:
              var _page = _this.options.page.replace(".php",".html");
              _this.load_template(_page);
              break;
      }
      
      $.ajax({
        async: true,
        cache: false,
        url: "/modules/house/template/house_image_orange_text.html",
        success: function (response) {
            $("#house_image_orange_text").html(response)
        },
        error: function(jqXHR, textStatus, errorThrown) {
            $("#house_image_orange_text").html("&nbsp;")
        }
        });
        
        var search_data = {};
        search_data.testimonial =  1;
        $.ajax({
            async: false,
            cache: false,
            url: _this.options.php_file,
            data: search_data,
            dataType: "json",
            success: function (response) {
                var html = "<my:fader id=testimonials>";
                for (var i=0; i<response.length; i++) {
                    html += "<my:fader_item>" + response[i] + "</my:fader_item>";
                }
                html += "</my:fader>";
                $("#house_image_purple_text").html(html)
                $('#testimonials').innerfade({
				animationtype: fades.testimonials.animationtype,
				speed: fades.testimonials.speed,
				timeout: fades.testimonials.timeout,
				type: fades.testimonials.type,
				containerheight: fades.testimonials.containerheight
			});
                
                
            },
            error: function(jqXHR, textStatus, errorThrown) {
            $("#house_image_purple_text").html("&nbsp;")
        }
        }); 
        
      
      
      
       }//end of document load
    });  
      
    })
}

house.prototype.load_template = function (page) {
    var _this = this;
    var content = document.getElementById("content");
    
    $.ajax({
        async: true,
        cache: false,
        url: "/modules/house/template/" + page,
        success: function (response) {
            $(content).html(response)
        },
        error: function(jqXHR, textStatus, errorThrown) {
            $(content).html("&nbsp;")
        }
    });
}

house.prototype.property_details = function (pid, return_text) {
    var _this = this;
    return_text = return_text ? return_text : "&larr; back to search results";
    //var property_details = _this.getTags("address_list")[0];
    
    
    
    var _modal = new modal_form();
    
    $("#modal_window").after("<my:property_full_details id=property_full_details></my:property_full_details>")
    
    var property_details = _this.getTags("property_full_details")[0];
    
    $(property_details).html("Loading...");
    
    var search_data = {};
    search_data.property_details =  1;
    search_data.pid = pid;
    
     
    $.ajax({
        async: true,
        cache: false,
        url: _this.options.php_file,
        data: search_data,
        dataType: "json",
        type: "POST",        
        success: function (response) {
            var html = "";
            
            var return_html = "<my:return_bar id=return_bar><my:return_bar_text class=noprint>" + return_text +  "</my:return_bar_text></my:return_bar>";
            
            //html = return_html;
            var property = response.propertyFullDetails.property;
            
            
            var picture = property.media.picture;
            
          
            
            var price = property["@attributes"]["price"];
            var header_address = property.address.sa1 + ", " + property.address.sa2;
            
            header_address += (typeof property.address.town == "object") ? "" : ", " + property.address.town; 
            header_address += (typeof property.address.city == "object") ? "" : ", " + property.address.city;
            
            header_address += ", " + property.address.county;
            
            
            header_address += ", " + property.address.postcode;
            
            
            
            return_html += "<my:property_header><my:property_address>" + header_address + "</my:property_address> <my:property_price>" + price + "</my:property_price></my:property_header>"
            
            html += return_html;
            
            //var map_html = "<iframe id=property_map frameborder='0' scrolling='no' src=\"/property_map.php?address=" + header_address + "\"></iframe>";
            var map_html = "<iframe id=property_map frameborder='0' scrolling='no' ></iframe>";
            if (typeof picture == "object") {
                html += "<my:major_image ><img src='" + picture[0]  +  "&width=400'></my:major_image>";
                html += map_html;
                html += "<my:minor_image_area id=minor_image_area>";
                for (var i=1; i<picture.length; i++) {
                    
                    if (picture[i].indexOf("Utilities") < 1) {
                        html += "<my:minor_image >";
                        html += "<img src='" + picture[i]  +  "&width=100'></my:major_image>"
                        html += "</my:minor_image>";
                    }
                }
                html += "</my:minor_image_area>";
                html += "<my:property_slide_show id=property_slide_show  class=noprint property_id=" + pid + ">View Slideshow</my:property_slide_show>";
            } else {
               html += "<my:major_image style=background-image:url(" + picture  +  "&width=500)></my:major_image>";
               html += map_html;
            }
            /*{"@attributes":{"type":"Hallway"},"heading":"Hallway","description":"With quarry tiled flooring and ceramic floor to rear, door to rear garden, stairs to first floor, radiator and window to front.
             *
             *
             */
            
            var points = property.text.description[1].split("<br\/>");
            
            var points_html = "<ul>";
            for (var p=0;p<points.length;p++) {
                if (points[p] !== "") points_html += "<li>" + points[p];
            }
            points_html += "</ul>";
            
            
            
            html += "<my:property_points>" + points_html + "</my:property_points>";
            
            html += "<my:property_description id=property_description>" + property.text.description[0] + "</my:property_description>";
            
            
            html += "<my:property_area id=property_area>";
            var areas = property.text.areas.area;
            for (_a in areas) {
                var area = areas[_a];
                for (var a=0; a<area.length; a++) {
                    html += "<my:area_heading>" + area[a].heading + "</my:area_heading>"
                    html += "<my:area_description>" + area[a].description + "</my:area_description>"
                }
            }
            html += "</my:property_area>";
            
            
          
            
            html += "<my:property_print  class=noprint id=property_print>Print Property</my:property_print>"
            
            var addr_bar ="<my:addr_bar id=addr_bar>";
            addr_bar +="&copy; Copyright briggs residential 17 Market Place Market Deeping Lincolnshire PE6 8EA 01778 349300";
            addr_bar +="</my:addr_bar>";
            
            //html += addr_bar;
            
            html += "<my:disclaimer id=disclaimer>Misrepresentation Act 1967: These particulars are believed to be correct but their accuracy is not guaranteed nor do they form part of any contract.</my:disclaimer>"
            //html += return_html;
            
            //html += return_html;
            
            html += "<iframe  id=iebugfix style=\"display:none\" frameborder=\"0\"></iframe>"
            
            $(property_details).html(html);
            
            setTimeout("document.getElementById('iebugfix').src = 'blank.html'", 500);
            
            $("#disclaimer").prepend (addr_bar);

            
            var pdt1 = 0;
            if ($("#minor_image_area").size()>0) {
                pdt1 = $("#minor_image_area").height() + $("#minor_image_area").position().top + 25;
                
            }
            
            
            $("#property_map").delay(500).attr("src","/property_map.php?address=" + header_address);
            var pdt2 = $("#property_map").height() + $("#property_map").position().top + 25;
            
            var pdt = (pdt1>pdt2) ? pdt1 : pdt2;
            
            $("#property_description").css("top",pdt + "px");
            
            
            
            var t = $("#property_description").height() + $("#property_description").position().top + 25;
            $("#property_area").css("top",t + "px");
            
            var p_top = $("#property_area").height() + $("#property_area").position().top;
            $("#property_print").css("top",p_top + "px");
            
            var p_left = $("#property_area").width()/2 - $("#property_print").width()/2;
            $("#property_print").css("left",p_left + "px");
            
            
            var d_top = $("#property_print").height() + $("#property_print").position().top + 50;
            $("#disclaimer").css("top",d_top + "px");
            
            
            
            $("#property_full_details").height($("#disclaimer").position().top + $("#disclaimer").height()+25)

            var p_html = $("#property_area").html()
            p_html = p_html.replace("Lounge (Reception)","Lounge")
            $("#property_area").html(p_html)
           
            
            
            
            //})  
            /*
            var page_details = _this.getTags("page_details");
            for (_pd in page_details) {
                try {
                    $(page_details[_pd]).html(return_html);
                    $(page_details[_pd]).css("text-align","left");
                } catch (err) {}
                
            }
            */
           
           var property_slide_show = _this.getTags("property_slide_show");
           for (_pss in property_slide_show) {try {
                   $(property_slide_show[_pss]).click (function () {
                       var pid = $(this).attr("property_id");
                       var url = 'http://www.dezrez.com/utilities/Gallery/gallery.asp?title=PictureGallery&pid=' + pid + '&agency=209&branch=298&width=310&rot=0&picnumber=1&stylesheet=http://www.dezrez.com/drapp/estateagents/209/slideShowStyle.css';
                       //alert($(this).attr("property_id"))
                       window.open(url, "Slideshow",'width=600,height=320,location=no')
                   })
           } catch (err) {}}
       
       
          var property_print = _this.getTags("property_print");
           for (_pss in property_print) {try {
                   $(property_print[_pss]).click (function () {
                       /*var w = $("#property_full_details").css("width");
                       $("#property_full_details").css({left: "0px",width:"100%"});
                       
                       var t = $("#property_full_details").css("top");
                       $("#property_full_details").css("top","0px");
                       
                       var b = $("#property_full_details").css("border");
                       $("#property_full_details").css("border", "none");
                       
                       
                       var pbg = $("#page").css("background-color");
                       $("#page").css("background-color","white");
                       
                       var bg = $("body").css("background-color");
                       $("body").css("background-color","white");
                       
                       $("#modal_window").css("background-color","white");
                       
                       $("#return_bar_text").hide();
                       $("#property_print").hide();
                       $("#property_slide_show").hide();*/
                       
                       window.print();
                       /*
                       
                       $("#return_bar_text").show();
                       $("#property_print").show();
                       $("#property_slide_show").show();
                       
                       
                       $("body").css("background-color",bg);
                       $("#page").css("background-color",pbg);
                       $("#property_full_details").css({width:w});
                       //$("#property_full_details").center();
                       
                       $("#property_full_details").css("top",t);
                       
                       $("#modal_window").css("background-color","black");
                       $("#property_full_details").css("border", b);
                       */
                   })
           } catch (err) {}}
       
       
           
            
            
            
            
            var minor_image = _this.getTags("minor_image");
            
            for (_mi in minor_image) {
                try {
                    $(minor_image[_mi]).click(function () {
                       
                        var major_image = _this.getTags("major_image")[0];
                        //var major_image_bg = $(major_image).css("background-image");
                        var major_image_bg = $(major_image).find("img").attr("src");
                        major_image_bg = major_image_bg.replace("width=400","width=100")
                        //var minor_image_bg = $(this).css("background-image");
                        var minor_image_bg = $(this).find("img").attr("src");
                        minor_image_bg = minor_image_bg.replace("width=100","width=400")
                        
                        
                        
                        //$(major_image).css("background-image", minor_image_bg)
                        //$(this).css("background-image", major_image_bg)
                        $(major_image).find("img").attr("src", minor_image_bg)
                        $(this).find("img").attr("src", major_image_bg)
                        
  
                    })
                    
                } catch (err) {window.status = "loaded"}
                
                
               
            }
           
            window.status = "loaded"
            
            var return_bar = _this.getTags("return_bar");
            for (_rb in return_bar) {
                try {
                $(return_bar[_rb]).click(function () {
                        //location.reload(true)
                        $(_this.getTags("property_full_details")[0]).slideUp(500).remove();
                        //$(_this.getTags("property_full_details")[0]).remove();
                        $("#modal_window").remove();
                    })
                } catch (err) {window.status = "loaded"}
            }
           
        
            /*$("#content").animate({
                top:"115px",
                left: "200px",
                width: "700px",
                height: "1000px"
            }) */
        
            //$("#property_full_details").center();
            
            $(window).resize(function() {
               // $("#property_full_details").center();
                //$("#address_list").niceScroll({cursorcolor:"#606",cursorwidth:"10px"});
            });
        }
    });
}

house.prototype.add_address_list = function () {
    var _this = this;
    if (_this.getTags("address_list").length == 0) {
        $("#content").append("<my:address_list id=address_list></my:address_list>")
        
        
        
        //ScrollLoad ("content", "address_list", false);
        $(document).setFooter();
        
        
    }
    $(document).ready(function (){
          //  $("#address_list").niceScroll({cursorcolor:"#606",cursorwidth:"10px"});
        })
}

house.prototype.searchResults = function (id) {
    var _this = this;
    
    var search_data  = ($.jStorage.get("search_data") != undefined) ? $.jStorage.get("search_data") : {search_properties: 1, page:1}
   /* if (window.name!=="") {
        search_data = JSON.parse(window.name);
        
        
    } else search_data = {search_properties: 1, page:1};*/
    
    
    _this.add_address_list();   
    
    $("#content").css({"z-index": "5"})
    $.ajax({
        async: true,
        cache: false,
        url: _this.options.php_file,
        data: search_data,
        dataType: "json",        
        success: function (response) {
            var property = response.propertySearchSales.properties.property;
            var pages = response.propertySearchSales.properties.pages;
            var address_list = _this.getTags("address_list")[0];          
            
            var page_count =  pages["@attributes"]["pageCount"];
            var page =  pages["@attributes"]["page"];
            
            var page_details_html_top = "<my:page_details id=page_details_top>Pages ";
            var page_details_html_bottom = "<my:page_details id=page_details_bottom>Pages ";   
            
            var page_details_html = "";
            for (var p=1;p<=page_count;p++)  {
                if (p == search_data.page ) page_details_html += "<my:current_page_link>" + p + "</my:current_page_link>";
                else page_details_html += "<my:page_link>" + p + "</my:page_link>";
            }
            
            page_details_html += "</my:page_details>";
            $(address_list).before(page_details_html_top + page_details_html);
            $(address_list).after(page_details_html_bottom + page_details_html);
            //console.log(1)
            
            if (property["@attributes"]===undefined) {
            for (_p in property) {
                //console.log(2)
                
                var html = "<my:address>";
                var price;
                try{price = property[_p]["@attributes"]["price"]}catch(err){price = property["@attributes"]["price"]}
                
                if (property[_p]["useAddress"] !== undefined) useAddress=property[_p]["useAddress"]; else useAddress=property["useAddress"]
                
                var id;
                try{id=property[_p]["@attributes"]["id"]}catch(err){id=property["@attributes"]["id"]}
                var property_image = _this.dezrez_image(id);
                
                var summaryDescription;
                try {
                summaryDescription=property[_p]["summaryDescription"].split(".")[0].substr(0, 100) + "... <my:property_link property_id=" +  id + ">more&gt;&gt;</my:property_link>";
                } catch(err){
                summaryDescription=property["summaryDescription"].split(".")[0].substr(0, 100) + "... <my:property_link property_id=" +  id + ">more&gt;&gt;</my:property_link>";     
                }
                
                
                    
                
                html += "<my:property_image property_id=" +  id  + " style=background-image:url(" + property_image + ")>&nbsp;</my:property_image>"
                html += "<my:price>" + price + "</my:price>"
                html += "<my:useAddress>" + useAddress + "</my:useAddress>";
                html += "<my:summaryDescription>" + summaryDescription + "</my:summaryDescription>"
                html += "</my:address>"
                //} catch (err) {}
                
                
                $(address_list).append(html);
            }} else {
            
                html = "<my:address>";
                price;
                price = property["@attributes"]["price"]
                
                useAddress=property["useAddress"]
                
                //var id;
                id=property["@attributes"]["id"]
                property_image = _this.dezrez_image(id);
                
                //var summaryDescription;
                
                summaryDescription=property["summaryDescription"].split(".")[0].substr(0, 100) + "... <my:property_link property_id=" +  id + ">more&gt;&gt;</my:property_link>";     
                
                
                
                    
                
                html += "<my:property_image property_id=" +  id  + " style=background-image:url(" + property_image + ")>&nbsp;</my:property_image>"
                html += "<my:price>" + price + "</my:price>"
                html += "<my:useAddress>" + useAddress + "</my:useAddress>";
                html += "<my:summaryDescription>" + summaryDescription + "</my:summaryDescription>"
                html += "</my:address>"
                //} catch (err) {}
                
                
                $(address_list).append(html);       
            
            
            }
            
            
            _this.add_property_details ("property_image");
            
            _this.add_property_details ("property_link");

            var page_link = _this.getTags("page_link");
            for (_pl in page_link) {
                if (page_link[_pl].innerHTML !== undefined) {
                    $(page_link[_pl]).click(function () {
                        _this.search($(this).html());
                    })
                }
            } 
        }
    });
}



house.prototype.add_property_details = function (custom_tag, return_text) {
    var _this = this;
   
    try {_this.add_address_list();}
    catch (err) {}
    
    var image_link = _this.getTags(custom_tag);
    //alert(image_link.length)
            for (_il in image_link) {
                
                //var pid
               
                try {
                    //var pid = $(image_link[_il]).attr("property_id");
                    $(image_link[_il]).click(function () {
                       
                         var pid = $(this).attr("property_id");
                        _this.property_details(pid, return_text);
                    });
                }
                catch (err) {}
            }
}

house.prototype.search = function (page_no) {
    var _this = this;
    
   
    
    
    
    //if (window.name!=="") {
    //    search_data = JSON.parse(window.name);
   // } else search_data = {};
   
    var minPrice = ($.jStorage.get("sel_min_price_data") != undefined) ? parseInt($.jStorage.get("sel_min_price_data").replace("£","")) : 0;
    var maxPrice = ($.jStorage.get("sel_max_price_data") != undefined) ? parseInt($.jStorage.get("sel_max_price_data").replace("£","")) : 0;
    if (minPrice >= maxPrice)   {
            alert("The minumum price (" + minPrice + ") must be less than the maximum price (" + maxPrice + ")");
            return false;
    }
        
        
    /*
    if ($("#sel_min_price").size()>0) {
        
        
        search_data.minPrice = ( $("#sel_min_price_data").html() == "Not specified") ? 0 : $("#sel_min_price_data").html().replace("£","");
        
        
        
        var max_price = $("#sel_max_price_data").html();
        
        if  ((max_price === "Not specified")||(max_price === "No Maximum")) search_data.maxPrice = 100000000;
        else search_data.maxPrice = max_price.replace("£","");
       
        if (search_data.minPrice>=search_data.maxPrice)   {
            alert("The minumum price " +search_data.minPrice + " must be less than the maximum price " + search_data.maxPrice)
            return false;
        }
        //search_data.maxPrice = ($("#sel_max_price_data").html() == "Not specified") ? 1000000 : $("#sel_max_price_data").html().replace("£","");
        search_data.bedrooms = 1;//($("#sel_min_beds_data").html() == "Not specified") ? 1 : parseInt($("#sel_min_beds_data").html());
    }
    */
    var search_data = {};
    
    search_data.minPrice = minPrice;
    search_data.maxPrice = maxPrice;
    search_data.search_properties = 1;
    search_data.page = page_no;
    //search_data.bedrooms = 1;
    $.jStorage.set("search_data", search_data);
    //window.name =  JSON.stringify(search_data);
    window.location.href = "/property_search.php"
}

house.prototype.searchBox = function (id,addclass,head_text) {
    var _this = this;
    head_text = head_text ? head_text : "";
    $(document).ready(function () {
        var sel_min_price = "sel_min_price";
        var sel_max_price = "sel_max_price";
        var sel_min_beds = "sel_min_beds";
        var html = "<div  id=frm_house_search class=\"frm_house_search " + addclass +"\">\
                        <h2>" + head_text + "</h2>\
                        <div class=lbox>\
                            \
                            To help you find the ideal property please choose a price guideline to view which properties match your criteria\
                        </div>\
                        <div class=rbox>\
                                <div><my:combo_label>Minimum price</my:combo_label><my:combo id=cmb_min_price><my:data id=sel_min_price_data> </my:data><my:combo_image></my:combo_image><ul id=sel_min_price></ul></my:combo></div>\
                                <div><my:combo_label>Maximum price</my:combo_label><my:combo id=cmb_max_price><my:data id=sel_max_price_data> </my:data><my:combo_image></my:combo_image><ul id=sel_max_price></ul></my:combo></div>\
                                <!--div><my:combo_label>Min Bedrooms</my:combo_label><my:combo><my:data id=sel_min_beds_data> </my:data><my:combo_image></my:combo_image><ul id=sel_min_beds></ul></my:combo></div-->\
                        </div>\
                        \
                    \
                    <div id=btn_go_search>\
                        \
                        <img  src=\"/modules/house/images/orange_go_butt.png\"><span>Go</span>\
                    </div></div>";
        $("#" + id).append(html);

        _this.setPriceSelect(sel_min_price,100);
        _this.setPriceSelect(sel_max_price,1000000,true);
        //_this.setBedroomSelect(sel_min_beds);
        
       
        var _combo = new combo();
        
        $("#btn_go_search").click(function () {
            
            _this.search(1);
        })   
        
    });
    
}








