﻿
/*  */
var LinkURL;
$(function() {
    //var url="http://www.iccpp.com.cn";
    //$(".setHome").click(function(){this.style.behavior='url(#default#homepage)';this.setHomePage(url);});

    if ('<%=isLogin %>' == 1) {
        $("#nologin").hide();
        $("#logging").show();
    }

    $(".stroll2").jMarquee({
        speed: 90,
        visible: 10,
        step: 1,
        direction: "up"
    });

    $("#txtAcc_Account").val("<%=uname %>");
    $("#txtAcc_Account").focus(function() { $(this).select(); });

    //搜索选择
    var store = str;
    $(".searchH div").click(function() {
        $(".searchH div").removeClass("selt");
        $(this).addClass("selt");
        if ($(this).hasClass("1")) {
            $("#txtStore").val(str).css("color", "#959595");
            store = str;
        } else if ($(this).hasClass("2")) {
            $("#txtStore").val(request).css("color", "#959595");
            store = request;
        }
        else if ($(this).hasClass("3")) {
            $("#txtStore").val(dl).css("color", "#959595");
            store = dl;
        }
        else if ($(this).hasClass("4")) {
            $("#txtStore").val(pdf).css("color", "#959595");
            store = pdf;
        }
    });

    $("#txtStore").keypress(function() {

        //                if ($("#serchU2 div:eq(0)").attr("class") == "serchU1L")
        //                    LinkURL = "/ComPanyInfo1_5/CompanyRequestShow1_5.aspx?key";
        //                else if ($("#serchU4 div:eq(0)").attr("class") == "serchU1L")
        //                    LinkURL = "http://www.alldatasheet.com/view.jsp?Searchword&q";

    });


    $("#txtStore").val(str).css("color", "#959595");
    $("#txtStore,#btnSearch").click(function() {

        if ($("#txtStore").val() == str || $("#txtStore").val() == request || $("#txtStore").val() == pdf || $("#txtStore").val() == dl) {
            $("#txtStore").val("").css("color", "#000");
        }
    });
    $("#txtStore").blur(function() {
        if ($(this).val() == "") {
            $(this).val(store).css("color", "#959595");
        }
    });

    $("#btnSearch").focus();
});

/*    */

imgUrl0 = "/image/index/focus/1.jpg";
imgtext0 = "00"
imgLink0 = escape("");
imgUrl1 = "/image/index/focus/2.jpg";
imgtext1 = "01"
imgLink1 = escape("");
imgUrl2 = "/image/index/focus/3.jpg";
imgtext2 = "02"
imgLink2 = escape("");

var focus_width = 419
var focus_height = 166
var text_height = 0
var swf_height = focus_height + text_height

//var pics = imgUrl0 + "|" + imgUrl1 + "|" + imgUrl2 + "|" + imgUrl3
var pics = [imgUrl0, imgUrl1, imgUrl2];
//var links = imgLink0 + "|" + imgLink1 + "|" + imgLink2 + "|" + imgLink3
var links = [imgLink0, imgLink1, imgLink2];
var texts = imgtext0 + "|" + imgtext1 + "|" + imgtext2

var num = [0, 1, 2];
var len = num.length;
while (len--) {
    var k = Math.round(Math.random() * len)
    num[len] = [num[k], num[k] = num[len]][0]
}

var p = "", picsStr = "", l = "", linksStr = "";
for (var i = 0; i < num.length; i++) {
    p = pics[num[i]] + "|";
    l = links[num[i]] + "|";
    if (i == num.length - 1) { p = pics[num[i]]; l = links[num[i]]; }
    picsStr += p;
    linksStr += l;
}
pics = picsStr;
links = linksStr;



/*   */

var intervalgqInfo, interval;
var gqI = 0;
$(function() {
    $("#gqInfo .boxT div:frist").click(function() { gqI = 1; gqInfo(); });
    $("#gqInfo .boxT div:last").click(function() { gqI = 0; gqInfo(); });

    //供求信息
    intervalgqInfo = setInterval(gqInfo, 5000);
    $("#gqInfo").mouseover(function() { intervalgqInfo = clearInterval(intervalgqInfo); });
    $("#gqInfo").mouseout(function() { intervalgqInfo = setInterval(gqInfo, 5000); });



    //优势信息
    $("#ysShow .boxT div").hover(function() {
        $("#ysShow .boxT div").addClass("noSelt");
        $(this).removeClass("noSelt");

        $("#ysShow .boxC .div").hide();
        if ($(this).hasClass("boxC2")) { $("#ysShow .boxC .div:last").show(); }
        else { $("#ysShow .boxC .div:first").show(); }
    });

    //热门型号
    interval = setInterval("numChange()", 3000);
    $("#numDiv").mouseover(function() { interval = clearInterval(interval); });
    $("#numDiv").mouseout(function() { interval = setInterval("numChange()", 3000); });
});

//供求信息
function gqInfo() {
    if (gqI >= $("#gqInfo .boxT div").size()) { gqI = 0; }

    $("#gqInfo .boxT div").removeClass("noSelt");
    $("#gqInfo .boxT div").eq(gqI).addClass("noSelt");

    $("#gqInfo .boxC .div").removeClass("noSelt");
    $("#gqInfo .boxC .div").eq(gqI).addClass("noSelt");
    gqI++;
}

//型号滚动
function numChange() {
    $("#numDiv li:first").animate({ marginTop: -14 }, 1000, function() {
        $(this).css("margin-top", 0).appendTo($("#numDiv ul"));
    });
}


//表单提交 判断是库存或资料
function formSub() {
    if ($("#txtStore").val() == "") {
        return false;
    }
    var result = true;

    $(".searchH div").each(function(i, n) {
        if ($(n).hasClass("selt")) {
            var num = $.trim($("#txtStore").val());
            if (i == 0) {
                location.href = '/ic/' + num + '.shtml';
            } else if (i == 1) {
                location.href = '/RequestShow.shtml?key=' + num;
            } else if (i == 2) {
                window.open("http://www.alldatasheet.com/view.jsp?Searchword=" + num + "&q=" + num + "");
            }
            result = false;
        }
    });
    return result;
}
