﻿
var xmlHttp, xmlHttp1, xmlHttp2, xmlHttp3, xmlHttp4;
var places
var ddl_places
var url, url1, url2, url3, url4;
var callfn, callfn1, callfn2, callfn3, callfn4;
var scrOfX = 0, scrOfY = 0;
var myWidth = 0, myHeight = 0;
var w = 0, h = 0;
var IE = document.all ? true : false
var comState = "";
var category = "";



function ld_clear() {
    document.getElementById("ddl_property_type").value = "Select One";
    document.getElementById("ddl_property_type").text = "Select One";

    document.getElementById("ddl_bed_rooms").text = "Any";
    document.getElementById("ddl_bed_rooms").value = "Any";

    document.getElementById("ddl_location").text = "Any";
    document.getElementById("ddl_location").value = "Any";

    document.getElementById("ddl_rent").text = "Any";
    document.getElementById("ddl_rent").value = "Any";

    document.getElementById("ddl_status").text = "Any";
    document.getElementById("ddl_status").value = "Any";
}

function load_location() {
    InitComponents();
    callfn = "loadlocation";
    area = document.getElementById(ddl_area.id).value;
    url4 = "../Load_Location_ajax.aspx?area=" + area;
    xmlsettings7(url4);
}

function loadFeature() {
    alert("hia");
    callfn = "loadfeaturestatus";
    propid = document.getElementById("ddl_property_type").value;
    url = "../Load_Feature_ajax.aspx?propid=" + propid ;
    xmlsettings3(url);
}

function loadFeature_new() {
    //alert("hia");
    
    callfn = "loadfeaturestatus";
    propid = document.getElementById("ddl_property_type").value;
    url = "../Load_Feature_ajax.aspx?propid=" + propid;
    xmlsettings3(url);

    callfn1 = "loadbedrooms";
    var path1 = window.location.search;
    var p = path1
    var arrpath = p.split("=");
    cat = (arrpath[1]);
    s=document.getElementById("ddl_category").value;
    cat = s;
    //if (document.getElementById("ddl_category").options[document.getElementById("ddl_category").selectedIndex].text != "Select") {
    if (cat == "1") {
        url1 = "../Load_bedroom_ajax.aspx?propid=" + propid;
        //alert(url1);
        xmlsettings4(url1);
    }
//    else {
//        url1 = "../Load_Floor_Size_ajax.aspx?propid=" + propid + "&transtype=" + document.getElementById("ddl_trans_type").value;
//    }
    
}

function loadvalue() {
    document.getElementById("hid_bedroom").value = document.getElementById("ddl_bed_rooms").value;
    //alert(document.getElementById("hid_bedroom").value);
}

function getCategoryValue(proptype) {
    var i = 0;
    for (i = 0; i < cat.length; i++) {
        var splitstr = "";
        splitstr = cat[i].split("*");

        if (splitstr[0] == proptype) {
            category = splitstr[1];
            document.getElementById("hiddencategory").value = splitstr[2];
            return category;
            break;
        }
    }
}

function load_property1() {

    if (category != "" && category!="Any") {
        if (category == "Residential") {
            document.getElementById("div_bed_room").style.visibility = "";
            document.getElementById("div_bed_room").style.display = "block";
            document.getElementById("div_floor_size").style.visibility = "hidden";
            document.getElementById("div_floor_size").style.display = "none";
        }
        else {
            document.getElementById("div_floor_size").style.visibility = "";
            document.getElementById("div_floor_size").style.display = "block";
            document.getElementById("div_bed_room").style.visibility = "hidden";
            document.getElementById("div_bed_room").style.display = "none";
        }
    }
}

function load_property() {
    
    if (document.getElementById("ddl_category").options[document.getElementById("ddl_category").selectedIndex].text == "Residential") {

        document.getElementById("div_bed_room_box").style.visibility = "";
        document.getElementById("div_bed_room_box").style.display = "block";
        document.getElementById("div_bed_room_text").style.visibility = "";
        document.getElementById("div_bed_room_text").style.display = "block";

        document.getElementById("div_floor_size_box").style.display = "none";
        document.getElementById("div_floor_size_box").style.visibility = "hidden";
        document.getElementById("div_floor_size_text").style.display = "none";
        document.getElementById("div_floor_size_text").style.visibility = "hidden";
    }
    else {
        document.getElementById("div_bed_room_box").style.visibility = "hidden";
        document.getElementById("div_bed_room_box").style.display = "none";
        document.getElementById("div_bed_room_text").style.visibility = "hidden";
        document.getElementById("div_bed_room_text").style.display = "none";

        document.getElementById("div_floor_size_box").style.display = "block";
        document.getElementById("div_floor_size_box").style.visibility = "";
        document.getElementById("div_floor_size_text").style.display = "block";
        document.getElementById("div_floor_size_text").style.visibility = "";

    }

    callfn3 = "loadproperty";
    catid = document.getElementById("ddl_category").value;
    url3 = "../Load_Property_ajax.aspx?catid=" + catid;
    xmlsettings6(url3);

    
}


function loadFeature_1() {
    //var cat = getCategoryValue(document.getElementById("ddl_property_type").value);
    //alert(cat);
    propid = document.getElementById("ddl_property_type").value;
    transtype = GetRadioButtonValue(document.getElementById("rbtn_trans_type").id);
    
    callfn = "loadfeaturestatus";
    url = "../Load_Feature_ajax.aspx?propid=" + propid;
    xmlsettings3(url);

    callfn1 = "loadbedrooms";
    if (document.getElementById("ddl_category").options[document.getElementById("ddl_category").selectedIndex].text != "Select One") {
        if (document.getElementById("ddl_category").options[document.getElementById("ddl_category").selectedIndex].text == "Residential") {
            url1 = "../Load_bedroom_ajax.aspx?propid=" + propid;
        }
        else {
            url1 = "../Load_Floor_Size_ajax.aspx?propid=" + propid + "&transtype=" + transtype;

        }
        xmlsettings4(url1);
    }
    callfn2 = "loadrent";
    url2 = "../Load_Rent_ajax.aspx?propid=" + propid + "&transtype=" + transtype;
    xmlsettings5(url2);
}


function loadFeature_2() {
    var cat = getCategoryValue(document.getElementById("ddl_property_type").value);
    //alert(cat);
    propid = document.getElementById("ddl_property_type").value;
    transtype = GetRadioButtonValue(document.getElementById("rbtn_trans_type").id);

    if (transtype == "Sale") {
        document.getElementById("priceid").innerHTML = "Min. Price (INR)";
    }
    else {
        document.getElementById("priceid").innerHTML = "Min. Rent (INR)";
    }

    callfn = "loadfeaturestatus";
    url = "../Load_Feature_ajax.aspx?propid=" + propid;
    xmlsettings3(url);

    callfn1 = "loadbedrooms";
    load_property1();
    //if (document.getElementById("ddl_category").options[document.getElementById("ddl_category").selectedIndex].text != "Select") {
        if (cat == "Residential") {
            url1 = "../Load_bedroom_ajax.aspx?propid=" + propid;
        }
        else {
            url1 = "../Load_Floor_Size_ajax.aspx?propid=" + propid + "&transtype=" + transtype;
        }
        xmlsettings4(url1);
    //}
    callfn2 = "loadrent";
    url2 = "../Load_Rent_ajax.aspx?propid=" + propid + "&transtype=" + transtype;
    xmlsettings5(url2);
}


function GetRadioButtonValue(id) {

    var radio = document.getElementsByName(id);

    for (var j = 0; j < radio.length; j++) {

        if (radio[j].checked)
          return radio[j].value;
//            alert(radio[j].value);

    }

}



function xmlsettings3(url) {

    xmlHttp = GetXmlHttpObject1();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp.onreadystatechange = stateChanged4;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}
function xmlsettings4(url1) {

    xmlHttp1 = GetXmlHttpObject2();
    if (xmlHttp1 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp1.onreadystatechange = stateChanged5;
    xmlHttp1.open("GET", url1, true);
    xmlHttp1.send(null);
}

function xmlsettings5(url2) {

    xmlHttp2 = GetXmlHttpObject3();
    if (xmlHttp2 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp2.onreadystatechange = stateChanged6;
    xmlHttp2.open("GET", url2, true);
    xmlHttp2.send(null);
}

function xmlsettings6(url3) {

    xmlHttp3 = GetXmlHttpObject4();
    if (xmlHttp3 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp3.onreadystatechange = stateChanged7;
    xmlHttp3.open("GET", url3, true);
    xmlHttp3.send(null);
}

function xmlsettings7(url4) {

    xmlHttp4 = GetXmlHttpObject5();
    if (xmlHttp4 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp4.onreadystatechange = stateChanged8;
    xmlHttp4.open("GET", url4, true);
    xmlHttp4.send(null);
}
function stateChanged4() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {

            if (callfn == "loadfeaturestatus") {

                if (xmlHttp.responseText == "0") {
                    var feature = document.getElementById("ddl_status");
                    for (x2 = (feature.length - 1); x2 >= 0; x2--) {
                        feature.remove(x2);
                    }

                    var opt2 = document.createElement("OPTION");
                    opt2.text = "Any";
                    opt2.value = "Any";
                    feature.options.add(opt2);
                }
                else {
                    var w2 = xmlHttp.responseText.split(",");
                    var x2;
                    var feature = document.getElementById("ddl_status");
                    for (x2 = (feature.length - 1); x2 >= 0; x2--) {
                        feature.remove(x2);
                    }

                    var opt2 = document.createElement("OPTION");
                    opt2.text = "Any";
                    opt2.value = "Any";
                    feature.options.add(opt2);

                    for (x2 = 0; x2 <= w2.length - 1; x2++) {
                        var opt2 = document.createElement("OPTION");
                        var splitValue2 = w2[x2].split("*");
                        opt2.text = splitValue2[1];
                        opt2.value = splitValue2[0];
                        feature.options.add(opt2);
                    }

                    var f2;
                    for (x2 = 0; x2 < feature.length; x2++) {
                        if (feature.options[x2].value == document.getElementById("hid_feature").value) {
                            document.getElementById("ddl_status").value = document.getElementById("hid_feature").value;
                            f2 = 0;
                            break;
                        }
                        else {
                            f2 = 1;
                        }
                    }
                    if (f2 == 1) {
                        feature.options[0].selected = true;
                    }
                    return;
                }
            }
        }
    }
}


function stateChanged5() {
    if (xmlHttp1.readyState == 4) {
        if (xmlHttp1.status == 200) {

            if (callfn1 == "loadbedrooms") {

                if (xmlHttp1.responseText == "0") {
                    var bedroom = document.getElementById("ddl_bed_rooms");
                    for (x1 = (bedroom.length - 1); x1 >= 0; x1--) {
                        bedroom.remove(x1);
                    }

                    var opt3 = document.createElement("OPTION");
                    opt3.text = "Any";
                    opt3.value = "Any";
                    bedroom.options.add(opt3);
                }
                else {
                    var w1 = xmlHttp1.responseText.split(",");
                    var x1;
                    var bedroom = document.getElementById("ddl_bed_rooms");
                    for (x1 = (bedroom.length - 1); x1 >= 0; x1--) {
                        bedroom.remove(x1);
                    }

                    var opt3 = document.createElement("OPTION");
                    opt3.text = "Any";
                    opt3.value = "Any";
                    bedroom.options.add(opt3);

                    for (x1 = 0; x1 <= w1.length - 1; x1++) {
                        var opt3 = document.createElement("OPTION");
                        var splitValue1 = w1[x1].split("*");
                        opt3.text = splitValue1[1];
                        opt3.value = splitValue1[0];
                        bedroom.options.add(opt3);
                    }

                    var f1;
                    for (x1 = 0; x1 < bedroom.length; x1++) {
                        if (bedroom.options[x1].value == document.getElementById("hid_bedroom").value) {
                            document.getElementById("ddl_bed_rooms").value = document.getElementById("hid_bedroom").value;
                            f1 = 0;
                            break;
                        }
                        else {
                            f1 = 1;
                        }
                    }
                    if (f1 == 1) {
                        bedroom.options[0].selected = true;
                    }
                    return;
                }
            }
        }
    }
}


function stateChanged6() {
    if (xmlHttp2.readyState == 4) {
        if (xmlHttp2.status == 200) {

            if (callfn2 == "loadrent") {

                if (xmlHttp2.responseText == "0") {
                    var rent = document.getElementById("ddl_rent");
                    for (x3 = (rent.length - 1); x3 >= 0; x3--) {
                        rent.remove(x3);
                    }

                    var opt4 = document.createElement("OPTION");
                    opt4.text = "Any";
                    opt4.value = "Any";
                    rent.options.add(opt4);
                }
                else {
                    var w3 = xmlHttp2.responseText.split(",");
                    var x3;
                    var rent = document.getElementById("ddl_rent");
                    for (x3 = (rent.length - 1); x3 >= 0; x3--) {
                        rent.remove(x3);
                    }

                    var opt4 = document.createElement("OPTION");
                    opt4.text = "Any";
                    opt4.value = "Any";
                    rent.options.add(opt4);

                    for (x3 = 0; x3 <= w3.length - 1; x3++) {
                        var opt4 = document.createElement("OPTION");
                        var splitValue4 = w3[x3].split("*");
                        opt4.text = splitValue4[1];
                        opt4.value = splitValue4[0];
                        rent.options.add(opt4);
                    }

                    var f3;
                    for (x3 = 0; x3 < rent.length; x3++) {
                        if (rent.options[x3].value == document.getElementById("hid_rent").value) {
                            document.getElementById("ddl_rent").value = document.getElementById("hid_rent").value;
                            f3 = 0;
                            break;
                        }
                        else {
                            f3 = 1;
                        }
                    }
                    if (f3 == 1) {
                        rent.options[0].selected = true;
                    }
                    return;
                }
            }
        }
    }
}

function stateChanged7() {
    if (xmlHttp3.readyState == 4) {
        if (xmlHttp3.status == 200) {

            if (callfn3 == "loadproperty") {

                if (xmlHttp3.responseText == "0") {
                    var property = document.getElementById("ddl_property_type");
                    for (x4 = (property.length - 1); x4 >= 0; x4--) {
                        property.remove(x4);
                    }

                    var opt5 = document.createElement("OPTION");
                    opt5.text = "Select One";
                    opt5.value = "Select One";
                    property.options.add(opt5);
                }
                else {
                    var w4 = xmlHttp3.responseText.split(",");
                    var x4;
                    var property = document.getElementById("ddl_property_type");
                    for (x4 = (property.length - 1); x4 >= 0; x4--) {
                        property.remove(x4);
                    }

                    var opt5 = document.createElement("OPTION");
                    opt5.text = "Select One";
                    opt5.value = "Select One";
                    property.options.add(opt5);

                    for (x4 = 0; x4 <= w4.length - 1; x4++) {
                        var opt5 = document.createElement("OPTION");
                        var splitValue5 = w4[x4].split("*");
                        opt5.text = splitValue5[1];
                        opt5.value = splitValue5[0];
                        property.options.add(opt5);
                    }

                    var f4;
                    for (x4 = 0; x4 < property.length; x4++) {
                        if (property.options[x4].value == document.getElementById("hid_property").value) {
                            document.getElementById("ddl_property_type").value = document.getElementById("hid_property").value;
                            f4 = 0;
                            break;
                        }
                        else {
                            f4 = 1;
                        }
                    }
                    if (f4 == 1) {
                        property.options[0].selected = true;
                    }
                    return;
                }
            }
        }
    }
}


function stateChanged8() {
    if (xmlHttp4.readyState == 4) {
        if (xmlHttp4.status == 200) {

            if (callfn4 == "loadlocation") {

                if (xmlHttp4.responseText == "0") {
                    var city = document.getElementById(ddl_city.id);
                    for (x5 = (city.length - 1); x5 >= 0; x5--) {
                        city.remove(x5);
                    }

                    var opt6 = document.createElement("OPTION");
                    opt6.text = "Any";
                    opt6.value = "Any";
                    city.options.add(opt6);
                }
                else {
                    var w5 = xmlHttp4.responseText.split(",");
                    var x5;
                    var city = document.getElementById(ddl_city.id);
                    for (x5 = (city.length - 1); x5 >= 0; x5--) {
                        city.remove(x5);
                    }

                    var opt6 = document.createElement("OPTION");
                    opt6.text = "Any";
                    opt6.value = "Any";
                    city.options.add(opt6);

                    for (x5 = 0; x5 <= w5.length - 1; x5++) {
                        var opt6 = document.createElement("OPTION");
                        var splitValue6 = w5[x5].split("*");
                        opt6.text = splitValue6[1];
                        opt6.value = splitValue6[0];
                        city.options.add(opt6);
                    }

                    var f5;
                    for (x5 = 0; x5 < city.length; x5++) {
                        if (city.options[x5].value == document.getElementById(hid_location.id).value) {
                            document.getElementById(ddl_city.id).value = document.getElementById(hid_location.id).value;
                            f5 = 0;
                            break;
                        }
                        else {
                            f5 = 1;
                        }
                    }
                    if (f5 == 1) {
                        city.options[0].selected = true;
                    }
                    return;
                }
            }
        }
    }
}

function xmlsettings(url) {
    xmlHttp = GetXmlHttpObject1();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    xmlHttp.onreadystatechange = stateChanged;

    xmlHttp.open("GET", url, true);

    xmlHttp.send(null);


}
function stateChanged() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            if (callfn == "login") {
                if (xmlHttp.responseText == "Yes") {
                    window.location = "User/us_profile.aspx";
                }
                else {
                    document.getElementById("lbl_msg").innerHTML = xmlHttp.responseText;
                }
            }
            if (callfn == "logincheck") {
                if (xmlHttp.responseText == "Yes") {
                    window.location = "us_profile.aspx";
                }
                else {
                    document.getElementById("lbl_msg").innerHTML = xmlHttp.responseText;
                }
            }
            if (callfn == "loadgh") {
                if (xmlHttp.responseText == "0") {

                    var caste = document.getElementById("dr_gothram");
                    for (x = (caste.length - 1); x >= 0; x--) {
                        caste.remove(x);
                    }

                    var opt = document.createElement("OPTION");
                    opt.text = "Select";
                    opt.value = "Select";
                    caste.options.add(opt);
                }

                else {

                    var w = xmlHttp.responseText.split(",");
                    var x;
                    var caste = document.getElementById("dr_gothram");
                    for (x = (caste.length - 1); x >= 0; x--) {
                        caste.remove(x);
                    }

                    var opt = document.createElement("OPTION");
                    opt.text = "Select";
                    opt.value = "Select";
                    caste.options.add(opt);
                    for (x = 0; x <= w.length - 1; x++) {
                        var opt = document.createElement("OPTION");
                        opt.text = w[x];
                        opt.value = w[x];
                        caste.options.add(opt);
                    }                   
                    return;
                }
            }
        }
    }
}



function GetXmlHttpObject1() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function GetXmlHttpObject2() {
    var xmlHttp1 = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp1 = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp1 = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp1;
}

function GetXmlHttpObject3() {
    var xmlHttp2 = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp2 = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp2;
}

function GetXmlHttpObject4() {
    var xmlHttp3 = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp3 = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp3 = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp3;
}

function GetXmlHttpObject5() {
    var xmlHttp4 = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp4 = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp4 = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp4;
}


