﻿

function valid_go_header(ddlSearch, txtkey, txtfprice, txttprice) {

    if (!emptyField(txtkey)) {
        if (ddlSearch.value == 0) {
            alert('Please Select Type');
            ddlSearch.focus();
            return false;
        }
    }
    if (ddlSearch.value == "3") {
        if (emptyField(txtfprice)) {
            alert('Please enter From Price');
            txtfprice.focus();
            return false;
        }
        if (!isNum(txtfprice.value)) {
            alert('Please enter Numeric From Price');
            txtfprice.focus();
            return false;
        }
        if (emptyField(txttprice)) {
            alert('Please enter UpTo Price');
            txttprice.focus();
            return false;
        }
        if (!isNum(txttprice.value)) {
            alert('Please enter Numeric UpTo Price');
            txttprice.focus();
            return false;
        }
        if (parseFloat(txtfprice.value) >= parseFloat(txttprice.value)) {
            alert('Minimum Price must be lessthan the Maximum Price.');
            txtfprice.focus();
            return false;
        }
    }
    else {
//        if (ddlSearch.value != 0) {
//            if (emptyField(txtkey)) {
//                alert('Please enter type value');
//                txtkey.focus();
//                return false;
//            }
//        }
    }
}



function chang(ddlSearch, txtkey,txtfprice, txttprice) {
    if (ddlSearch.value == 3) {

        if (txtfprice.value == "") {
            txtfprice.value = "min"
        }
        if (txttprice.value == "") {
            txttprice.value = "max"
        }
        txtkey.style.display = "None";
        txtfprice.style.display = "Block";
        txttprice.style.display = "Block";
        return false;
    }
    else {
        txtkey.style.display = "Block";
        txtfprice.style.display = "None";
        txttprice.style.display = "None";
        return false;
    }
}
function cleartextp(txtfprice) {
    if (txtfprice.value == "min") {
        txtfprice.value = "";
    }
}
function cleartextt(txttprice) {
    if (txttprice.value == "max") {
        txttprice.value = "";
    }
}

function validAdvSearch(txtpprice, txttprice) 
{
    if (!emptyField(txtpprice)) {
        if (emptyField(txttprice)) {
            alert('Please enter To Price');
            txttprice.focus();
            return false;
        }
    }
    if (!emptyField(txtpprice)) {
        if (!isNum(txtpprice.value)) {
            alert('Please enter Numeric From Price');
            txtpprice.focus();
            return false;
        }
    }
     if (!emptyField(txttprice)) {
         if (emptyField(txtpprice)) {
            alert('Please enter From Price');
            txtpprice.focus();
            return false;
        }
    }
    if (!emptyField(txttprice)) {
        if (!isNum(txttprice.value)) {
            alert('Please enter Numeric To Price');
            txttprice.focus();
            return false;
        }
    }
    if (parseFloat(txtpprice.value) >= parseFloat(txttprice.value)) {
        alert('Minimum Price must be lessthan the Maximum Price.');
        txtpprice.focus();
        return false;
    } 
}

function chang1() {
    if (document.getElementById("ctl00_ddlSearch").value == 3) {

        if (document.getElementById("ctl00_txtfprice").value == "") {
            document.getElementById("ctl00_txtfprice").value = "min"
        }
        if (document.getElementById("ctl00_txttprice").value == "") {
            document.getElementById("ctl00_txttprice").value = "max"
        }
        document.getElementById("ctl00_txtkey").style.display = "None";
        document.getElementById("ctl00_txtfprice").style.display = "Block";
        document.getElementById("ctl00_txttprice").style.display = "Block";
        return false;
    }
    else {
        document.getElementById("ctl00_txtkey").style.display = "Block";
        document.getElementById("ctl00_txtfprice").style.display = "None";
        document.getElementById("ctl00_txttprice").style.display = "None";
        return false;
    }
}

function chang11() {
    if (document.getElementById("header1_ddlSearch").value == 3) {

        if (document.getElementById("header1_txtfprice").value == "") {
            document.getElementById("header1_txtfprice").value = "min"
        }
        if (document.getElementById("header1_txttprice").value == "") {
            document.getElementById("header1_txttprice").value = "max"
        }
        document.getElementById("header1_txtkey").style.display = "None";
        document.getElementById("header1_txtfprice").style.display = "Block";
        document.getElementById("header1_txttprice").style.display = "Block";
        return false;
    }
    else {
        document.getElementById("header1_txtkey").style.display = "Block";
        document.getElementById("header1_txtfprice").style.display = "None";
        document.getElementById("header1_txttprice").style.display = "None";
        return false;
    }
}


function chang111() {
    if (document.getElementById("ctl00_header1_ddlSearch").value == 3) {

        if (document.getElementById("ctl00_header1_txtfprice").value == "") {
            document.getElementById("ctl00_header1_txtfprice").value = "min"
        }
        if (document.getElementById("ctl00_header1_txttprice").value == "") {
            document.getElementById("ctl00_header1_txttprice").value = "max"
        }
        document.getElementById("ctl00_header1_txtkey").style.display = "None";
        document.getElementById("ctl00_header1_txtfprice").style.display = "Block";
        document.getElementById("ctl00_header1_txttprice").style.display = "Block";
        return false;
    }
    else {
        document.getElementById("ctl00_header1_txtkey").style.display = "Block";
        document.getElementById("ctl00_header1_txtfprice").style.display = "None";
        document.getElementById("ctl00_header1_txttprice").style.display = "None";
        return false;
    }
}

function chang2() {
    if (document.getElementById("txtCom").value == "") {
        document.getElementById("txtCom").value = "Write Comments"
        }
    }

    function cleartextt1(txttprice) {
        if (txttprice.value == "Write Comments") {
            txttprice.value = "";
        }
    }




 

    var inid = "";
    var divid = "";
    var formname = "";

    //Gets the browser specific XmlHttpRequest Object
    function getXmlHttpRequestObject() {
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
        }
    }

    //Our XmlHttpRequest object to get the auto suggest
    var searchReq = getXmlHttpRequestObject();
    var key;
    function suggestUser(txtkey, ddlSearch) {
        //alert(txtkey);
        //alert(ddlSearch);
            if (searchReq.readyState == 4 || searchReq.readyState == 0) {
                //alert('in suggestUser');
                
                document.getElementById('suggest_user').style.display = "block";
                document.getElementById("suggest_user").innerHTML = searchReq.responseText;
                var str = escape(txtkey.value);
                key = txtkey;
                searchReq.open("GET", 'getdata.aspx?type=' + ddlSearch.value + '&search=' + str, true);
                searchReq.onreadystatechange = handleSearchSuggest;
                searchReq.send(null);
                inid = txtkey;
                //alert(inid);
                divid = 'suggest_user';
                formname = '';
            }
        }
    //Called when the AJAX response is returned.
        function handleSearchSuggest() {
            if (searchReq.readyState == 4) {
              //alert('in handleSearchSuggest');
            var ss = document.getElementById(divid)
            ss.innerHTML = '';
            var str = searchReq.responseText.split("<br />");
            //alert(str);
            //alert(key.value);
            //alert(str.length);
            if (key.value != '') {
                for (i = 0; i < str.length - 1; i++) {
                    //Build our element string.  This is cleaner using the DOM, but
                    //IE doesn't support dynamically added attributes.
                    var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
                    suggest += 'onmouseout="javascript:suggestOut(this);" ';
                    suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
                    suggest += 'class="suggest_link" id="divresult" >' + str[i] + '</div>';
                    ss.innerHTML += suggest;
                }
               //alert(ss.innerHTML);
            }
            else {
                ss.style.display = "none";

            }
        }
    }

    //Mouse over function
    function suggestOver(div_value) {
        div_value.className = 'suggest_link_over';
    }
    //Mouse out function
    function suggestOut(div_value) {
        div_value.className = 'suggest_link';
    }
    //Click function
    function setSearch(value) {
        key.value = value;
        document.getElementById(divid).innerHTML = '';
        document.getElementById(divid).style.display = "none";
        if (formname != '')
            eval("document." + formname + ".submit()");
    }
    function setFree() {
        if (divid != "")
            document.getElementById(divid).style.display = "none";
    }


////////    function suggestUser() {
////////        var xmlHttp;
////////        try {
////////            // Firefox, Opera 8.0+, Safari
////////            xmlHttp = new XMLHttpRequest();
////////        }
////////        catch (e) {
////////            // Internet Explorer
////////            try {
////////                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
////////            }
////////            catch (e) {
////////                try {
////////                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
////////                }
////////                catch (e) {
////////                    alert("Your browser does not support AJAX!");
////////                    return false;
////////                }
////////            }
////////        }
////////        xmlHttp.onreadystatechange = function() {
////////        if (xmlHttp.readyState == 4) {
////////                document.getElementById('suggest_user').style.display = "block";
////////                document.getElementById("suggest_user").innerHTML = xmlHttp.responseText;
////////                ////            var s, ss;
////////                ////            var s = xmlHttp.responseText;
////////                ////            var ss = s.split('#');
////////                ////            document.getElementById("divprice").innerHTML = ss[0];
////////                ////            document.getElementById("hdsmids").value = ss[2];
////////            }
////////        }
////////        var str = escape(document.getElementById('header1_txtkey').value);
////////        xmlHttp.open("GET", 'getdata.aspx?type=' + document.getElementById('header1_ddlSearch').value + '&search=' + str, true);
////////        xmlHttp.send(null);
////////    }

