﻿/// <reference name="MicrosoftAjax.js"/>
Sys.Application.add_load(PageInit);
function PageInit() {

    var strHref = document.location.toString();
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1); //==========获取到右边的参数部分
    var arrTmp = strRight.split("&"); //=============以&分割成数组

        for (var i = 0; i < arrTmp.length ; i++) //===========循环数组
        {
            var dIntPos = arrTmp[i].indexOf("=");
            var paraName = arrTmp[i].substr(0, dIntPos);
            var paraData = arrTmp[i].substr(dIntPos + 1);


            if (paraName.toUpperCase() == "s".toUpperCase()) {
                $get("TextBox1").value = decodeURIComponent( paraData);
            }
        }


    $get("a4").className = strHref.indexOf("RealNameSearch.aspx") == -1 ? "" : "on";
    if (strHref.indexOf("YPSearch.aspx")>-1)
    $get("a5").className = strHref.indexOf("YPSearch.aspx") == -1 ? "" : "on";
    if (strHref.indexOf("YPSearchs.aspx")>-1)
    $get("a5").className = strHref.indexOf("YPSearchs.aspx") == -1 ? "" : "on";
    $get("a6").className = strHref.indexOf("ProductSearch.aspx") == -1 ? "" : "on";
    if ($get("a4").className == "" && $get("a5").className == "" && $get("a6").className == "")
        $get("a4").className = "on";
    if ($get("TextBox1").value=="") {
        TextBox1Blur();
    }

}
function btnSubmit_OnClick() {
    var q = $get("TextBox1").value;
    if (q.trim().length > 1 && q != "实名名称" && q != "黄页名称" && q != "产品名称")
    { SearchChange.GerUrls(encodeURIComponent(q), hrefSucceeded); }
    else
    {alert("搜索字数应大于2位");}
}
function TxtNameClear() {
    if ($get("txtName").value == "实名名称" || $get("TextBox1").value == "黄页名称" || $get("TextBox1").value == "产品名称") {
        $get("txtName").value = "";
    }

}
function TxtNameBlur() {
    if ($get("txtName").value == "") {
        SearchChange.GerDefaultText(SetTxtName);
    }
}
function SetTxtName(result) {
    $get("txtName").value = result;
}
function TextBox1Clear() {
    if ($get("TextBox1").value == "实名名称" || $get("TextBox1").value == "黄页名称" || $get("TextBox1").value == "产品名称") {
        $get("TextBox1").value = "";
    }

}
function TextBox1Blur() {
    if ($get("TextBox1").value == "") {
        SearchChange.GerDefaultText(SetTextBox1);
    }
}
function SetTextBox1(result) {
    $get("TextBox1").value = result;
}
function btn1() {
    SearchChange.SetSession("1");
    var q = $get("txtName");
    if (q.value == "" || q.value == "黄页名称" || q.value == "产品名称") {
        q.value = "实名搜索";
    } Category("");

}
function btn2() {
   SearchChange.SetSession("2");
    var q = $get("txtName");
    if (q.value == "" || q.value == "实名名称" || q.value == "产品名称") {
        q.value = "黄页搜索";
    } Category("none");

   

}
function btn3() {
    SearchChange.SetSession("3");
    var q = $get("txtName");
    if (q.value == "" || q.value == "实名名称" || q.value == "黄页名称") {
        q.value = "产品搜索";
    } Category("none");
    Category1("none");


}
function btn4() {
    SearchChange.SetSession("1");
var q =$get("TextBox1").value.trim();
if (q.length == 0 || q == "实名名称" || q == "黄页名称" || q == "产品名称")
    location.href = "RealNameSearch.aspx";
else
    location.href = "RealNameSearch.aspx?s=" + encodeURIComponent( q);
}
function btn5() {
    SearchChange.SetSession("2");
    var q = $get("TextBox1").value.trim();
    if (q.length == 0 || q == "实名名称" || q == "黄页名称" || q == "产品名称")
        location.href = "YPSearch.aspx";
    else
        location.href = "YPSearch.aspx?s=" + encodeURIComponent(q);
}
function btn6() {
    SearchChange.SetSession("3");
    var q = $get("TextBox1").value.trim();
    if (q.length == 0 || q == "实名名称" || q == "黄页名称" || q == "产品名称")
        location.href = "ProductSearch.aspx";
    else
        location.href = "ProductSearch.aspx?s=" + encodeURIComponent(q);

}



function LinkButton1() {
    $get("txtName").value = $get("TextBox1").value;
}
function Category(st) {
    $get("ctl00_sm_DropDownList11").style.display = st;
}
function Category1(st) {
    $get("ctl00_sm_DropDownList10").style.display = st;
    $get("ctl00_sm_DropDownList9").style.display = st;
}
function stylenone() {
    $get("a4").className = "";
    $get("a5").className = "";
    $get("a6").className = "";
}
function succeeded() {

}
function alertDropDownList() {
var s=$get("txtName").value;
if (s.trim().length > 1 && s.trim() != "实名名称" && s.trim() != "黄页名称" && s.trim() != "产品名称")
{
    var a = $get("ctl00_sm_DropDownList7").options[$get("ctl00_sm_DropDownList7").selectedIndex].value;
    var b = $get("ctl00_sm_DropDownList8").options[$get("ctl00_sm_DropDownList8").selectedIndex].value; ;
    var c = $get("ctl00_sm_DropDownList9").options[$get("ctl00_sm_DropDownList9").selectedIndex].value; ;
    var d = $get("ctl00_sm_DropDownList10").options[$get("ctl00_sm_DropDownList10").selectedIndex].value; ;
    var e = $get("ctl00_sm_DropDownList11").options[$get("ctl00_sm_DropDownList11").selectedIndex].value; ;
    SearchChange.GerUrl( encodeURIComponent( s),a,b,c,d,e,hrefSucceeded);
    }
    else
    {
        alert("搜索字数应大于2位");
    }
    }
    function hrefSucceeded(result)
    {
        location.href=result;
    }

