﻿
function check_valid01() {
    var check_form = document.forms.frm_vehicle;
    var strVehicleNo = check_form.txtVehicleNo.value;
    if (strVehicleNo == "") {
        alert("请输入您的车牌号!");
        check_form.txtVehicleNo.focus();
        return false;
    }
    return true;
}

function check_valid02() {
    var check_form = document.forms.frm_driver;
    var strDriverId = check_form.DriverId.value;
    var strIdNo = check_form.IdNo.value;
    if (strDriverId == "") {
        alert("您必须同时输入档案编号和身份证号!");
        check_form.DriverId.focus();
        return false;
    }
    if (strIdNo == "") {
        alert("您必须同时输入档案编号和身份证号!");
        check_form.IdNo.focus();
        return false;
    }
    return true;
}

function movement(index) {
    for (i = 0; i < 6; i++) {
        document.getElementById("channel" + i.toString()).style.display = 'none';
        document.getElementById("channersize" + i.toString()).className = "Blach"
    }
    document.getElementById("channel" + index.toString()).style.display = 'block';
    document.getElementById("channersize" + index).className = "White"
}

function Marquee() {
    try {
        if (document.getElementById("de2").offsetWidth - document.getElementById("de").scrollLeft <= 0) {
            document.getElementById("de").scrollLeft = 0;
        }
        else {
            document.getElementById("de").scrollLeft++;
        }
    } catch (e) {
    }
}

function MarqueeMsg() {
    try {
        if (document.getElementById("msg2").offsetHeight - document.getElementById("msg").scrollTop <= 0) {
            document.getElementById("msg").scrollTop = 0;
        }
        else {
            document.getElementById("msg").scrollTop++;
        }
    }
    catch(e) {
    }
}

function spec_sn(mouseobj) {
    var obj = document.getElementById('ddlCar');
    var obj_br = document.getElementById('ddlBrand');
    var obj_fct = document.getElementById('ddlFactory');

    if (obj.value != 0 && obj.value != '') {
        var path = '//newcar.dizo.com.cn/ncar-{carid}.html';
        path = path.replace("{carid}", obj.value);
        mouseobj.href = path;
        mouseobj.target = "_blank";
    }
    else {
        if (obj_br.value != 0 && obj_br.value != '') {
            var path = '//newcar.dizo.com.cn/brand-{brandid}.html';
            path = path.replace("{brandid}", obj_br.value);
            mouseobj.href = path;
            mouseobj.target = "_blank";
        }
        else {
            mouseobj.href = "javascript:alert('请选择厂商和品牌！');";
            mouseobj.target = "_self";
        }
    }
}

function spec_sn2(mouseobj) {
    var obj = document.getElementById('ddlCar');
    var obj_br = document.getElementById('ddlBrand');
    var obj_fct = document.getElementById('ddlFactory');

    var cpath = '//newcar.dizo.com.cn/comparecar.aspx?carid={carid}';
    cpath = cpath.replace("{carid}", obj.value);
    mouseobj.href = cpath;
}

function UsedCardSearchList(mouseobj) {
    var obj_Scope = $get('ddlScope1');
    var obj_Factory = $get('ddlFactory1');
    var obj_Brand = $get('ddlBrand1');

    if (obj_Scope.value == 0 || obj_Scope.value == '') {
        mouseobj.href = "javascript:alert('请选择产地')";
    }
    else {
        if (obj_Factory.value == 0 || obj_Factory.value == '') {
            var path = '//usedcar.dizo.com.cn/result.html';
            path = path + "?Scope=" + obj_Scope.value
            mouseobj.href = path;
            mouseobj.target = "_blank";
        }
        else {
            if (obj_Brand.value == 0 || obj_Brand.value == '') {
                var path = '//usedcar.dizo.com.cn/result.html';
                path = path + "?Scope=" + obj_Scope.value + "&Factory=" + obj_Factory.value;
                mouseobj.href = path;
                mouseobj.target = "_blank";
            }
            else {
                var path = '//usedcar.dizo.com.cn/result.html';
                path = path + "?Scope=" + obj_Scope.value + "&Factory=" + obj_Factory.value + "&Brand=" + obj_Brand.value;
                mouseobj.href = path;
                mouseobj.target = "_blank";
            }
        }
    }
}

function GetCarprice(sub) {
    for (var i = 0; i < 4; i++) {
        $get("Content" + i).style.display = "none";
        $get("image" + i).style.background = "none";
        $get("image" + i).style.fontWeight = '';
        $get("image" + i).style.cursor = "pointer";
    }
    $get("Content" + sub).style.display = "";
    $get("image" + sub).style.background = "url(img/onmouseoveimg.gif)";
    $get("image" + sub).style.fontWeight = 'bolder';
}

function chinacars() {
    SetText("chinacar", "");
    $get("chinacar").style.background = "url(img/button099.gif) no-repeat center center";
    $get("Content4").style.display = "none";
    $get("importecar").style.background = "";
    SetText("importecar", "进口车");
    $get("carprice").style.display = "";
    GetCarprice(0)
}

function importecars() {
    SetText("importecar", "");
    $get("importecar").style.background = "url(img/button104.gif) no-repeat center center";
    $get("chinacar").style.background = "";
    SetText("chinacar", "国产车");
    $get("carprice").style.display = "none";
    for (var i = 0; i < 4; i++)
        $get("Content" + i).style.display = "none";
    $get("Content4").style.display = "";
}

function SetText(objid, text) {
    if (isIE)
        document.getElementById(objid).innerText = text;
    else
        document.getElementById(objid).textContent = text;
}

function ChangeSearch() {
    var SearchAnchor = document.getElementById("SearchAnchor");
    if (typeof SearchAnchor.baseHref == 'undefined')
        SearchAnchor.baseHref = SearchAnchor.href;
    SearchAnchor.href = SearchAnchor.baseHref +
        document.getElementById("SearchType").options[document.getElementById("SearchType").selectedIndex].value +
        ".aspx?q=" + encodeURIComponent(document.getElementById("SearchKey").value);
}

function addBookmark(title, url) {
    if (!title) title = document.title;
    if (!url) url = document.location.href;
    if (document.all) {
        window.external.AddFavorite(url, title);
    } else if (window.sidebar) {
        window.sidebar.addPanel(title, url, '');
    } else if (window.opera && window.print) {
        var mbm = document.createElement('a');
        mbm.setAttribute('rel', 'sidebar');
        mbm.setAttribute('href', url);
        mbm.setAttribute('title', title);
        mbm.click();
    }
}

function ShowCountDown(divname) {
    var endDate = new Date(2008, 8, 8, 19);
    var leftTime = endDate.getTime() - dateNow.getTime();
    var leftsecond = parseInt(leftTime / 1000);
    var day1 = Math.floor(leftsecond / (60 * 60 * 24));
    var cc = document.getElementById(divname);
    document.getElementById(divname).style.fontFamily = "黑体";
    document.getElementById(divname).style.color = "#FFFF01";
    document.getElementById(divname).style.fontSize = "40px";
    document.getElementById(divname).style.fontWeight = "bolder";
    cc.innerHTML = day1;
}

function Cascading(ControlID, Category, ParentControlID, PromptText) {
    var CascadingID = ControlID + "_Cascading";
    var ClientStateID = CascadingID + "_ClientState";
    var input = document.createElement("INPUT");
    input.type = "hidden";
    input.id = CascadingID;
    document.forms[0].appendChild(input);

    $create(Dizo.Controls.Ajax.CascadingDropDownBehavior,
    {
        "Category": Category,
        "ClientStateFieldID": ClientStateID,
        "LoadingText": "正在加载...",
        "ParentControlID": ParentControlID,
        "PromptText": PromptText,
        "ServiceMethod": "GetDropDownContents",
        "ServicePath": "http://www.tjcgs.gov.cn/cardata.asmx",
        "id": CascadingID
    }, null, null, $get(ControlID));

}

function redirectUrl(url) {
    var frm = document.createElement("form");
    document.body.insertBefore(frm);
    frm.method = "post";
    frm.action = url;
    frm.target = '_top';
    frm.submit();
}

function pageLoad() {
    var speed = 30
    document.getElementById("de2").innerHTML = document.getElementById("de1").innerHTML
    var MyMar = setInterval(Marquee, speed)
    document.getElementById("de").onmouseover = function() { clearInterval(MyMar) }
    document.getElementById("de").onmouseout = function() { MyMar = setInterval(Marquee, speed) }

    var speed2 = 60
    document.getElementById("msg2").innerHTML = document.getElementById("msg1").innerHTML
    var msgMar = setInterval(MarqueeMsg, speed2);
    document.getElementById("msg").onmouseover = function() { clearInterval(msgMar) }
    document.getElementById("msg").onmouseout = function() { msgMar = setInterval(MarqueeMsg, speed2) }

    Cascading('ddlScope', 'Scope', null, '==选择产地==');
    $find('ddlScope_Cascading').set_SelectedValue('1');
    Cascading('ddlFactory', 'Factory', 'ddlScope', '==选择厂商==');
    Cascading('ddlBrand', 'Brand', 'ddlFactory', '==选择品牌==');
    Cascading('ddlCar', 'Car', 'ddlBrand', '==选择车型==');

    movement(0)
}

function addFav() {
    if (document.all) {
        window.external.addFavorite(window.location, document.title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(document.title, window.location, "");
    }
}

function GetSearchUrl() {
    var SearchA = document.getElementById("SearchUrl");
    SearchA.href = "search.aspx?q=" + escape(document.getElementById("SearchText").value);
}

