﻿
var binrun = null;
var ads_time = 500;
var ads_h = 0;
var ads_time_2 = 500;
var ads_h_2 = 0;

function Trim(ss) {
    return ss.replace(/(^\s*)|(\s*$)/g, "");
}

function PageLoad() {
    adTurnPlay('g_AsImageG0102',12000);
    adTurnPlay('g_AsImageG0109',12000,1);//type1不显示btn
    adTurnPlay('g_AsImageG0114',12000);
    adTurnPlayTx("infoTop2", 2000);
    
    new Marquee("sblist", 0, 2, 640, 200, 30, 4000, 5000, 200);
    new Marquee("splist", 0, 2, 640, 104, 20, 7000, 4000, 104);
    new Marquee("jjlist", 0, 2, 306, 100, 20, 5000, 5000, 100);
    //new Marquee("ibdList", 0, 2, 632, 180, 18, 5000, 5000, 180);
    /*中国制作样式修改部start*/
    if (document.getElementById("chinachipsshow").getElementsByTagName("li").length > 2) {
        new Marquee("chinachipsshow", 0, 2, 288, 198, 30, 7000, 5000, 198);
    }
    /*中国制作样式修改部end*/	

   
    adTurnPlay('g_AsImageG0106',12000);
    Popup();
}
function over_provide(cur) {
    if (cur == 1 && document.getElementById("providerList").getElementsByTagName("table").length == 0) {
        if (document.getElementById("providerList").getElementsByTagName("ul").length > 6) {
            new Marquee("providerList", 0, 2, 291, 252, 30, 7000, 5000, 254);
        }
    }
    var tabtit = document.getElementById("providetit").getElementsByTagName("a");
    var tabidx = [0, 1];
    var tabcon = ["chinachips", "providerList"];
    for (var i = 0; i < tabidx.length; i++) {
        if (i == cur) {
            document.getElementById(tabcon[i]).style.display = "";
            tabtit[i].className = "over";
            //new Marquee(tabcon[i], 0, 2, 276, 252, 30, 7000, 5000, 254);
        }
        else {
            document.getElementById(tabcon[i]).style.display = "none";
            tabtit[i].className = "";
        }
    }
}
function openhonesty() {
    new Marquee("NewOpenHonestylist", 0, 2, 306, 100, 20, 5000, 5000, 100);
}

var g_index_honesty = 0;
function over_honesty(el, d1, d2) {
    el.className = 'activeb r1';
    document.getElementById('from0' + d2).className = 'activea_2 r1';
    document.getElementById('from0' + d1 + 'div').style.display = 'block';
    document.getElementById('from0' + d2 + 'div').style.display = 'none';

    if (d1 == 2 && g_index_honesty == 0) {
        //openhonesty();
        g_index_honesty = 1;
    }

    if (d1 == 1) {
        document.getElementById('from02').className = 'activea_2 r1';
    } else {
        document.getElementById('from01').className = 'activea r1';
    }
    //    el.className='activeb r1';
    //    document.getElementById('from02').className='activea_2 r1';
    //    document.getElementById('from01div').style.display='block';
    //    document.getElementById('from02div').style.display='none';
    //    
    //    el.className='activeb r1';
    //    document.getElementById('from01').className='activea r1';
    //    document.getElementById('from02div').style.display='block';
    //    document.getElementById('from01div').style.display='none';
    //    openhonesty();
}



//随机显示竞价与在线交易
function randomShowBiddingAndDocHonesty() {

    var arr = new Array('biddingMenu', 'chengxinMenu');
    var irandom = Math.floor(Math.random() * arr.length);
    //debugger;
    if (irandom == 0) {
        //        document.getElementById('biddingMenu').className = 'activeb r1';
        //        document.getElementById('chengxinMenu').className = 'activea_2 r2';
        //        document.getElementById('biddingdiv').style.display = 'block';
        //        document.getElementById('chengxindiv').style.display = 'none';

        document.getElementById('biddingMenu').className = 'activeb r1';
        document.getElementById('chengxinMenu').className = 'activea_2 r2';
        document.getElementById('biddingdiv').style.display = 'block';
        document.getElementById('chengxindiv').style.display = 'none';

    }
    else {
        //        document.getElementById('biddingMenu').className = 'activea r1';
        //        document.getElementById('chengxinMenu').className = 'activeb r2';
        //        document.getElementById('chengxindiv').style.display = 'block';
        //        document.getElementById('biddingdiv').style.display = 'none';

        document.getElementById('chengxinMenu').className = 'activeb r2';
        document.getElementById('biddingMenu').className = 'activea r1';
        document.getElementById('chengxindiv').style.display = 'block';
        document.getElementById('biddingdiv').style.display = 'none';
    }
}

//搜索PDF
function SearchPdf() {

    var keyword = Trim(document.getElementById("PdfSearchKeyword").value);
    if(keyword == '')
    {
        alert("请输入一个IC型号！");
        document.getElementById("PdfSearchKeyword").select();
        return false;
    }
    if (keyword.length < 3) {
        alert('请输入要搜索的型号，且不能少于三个字符！');
        document.getElementById("PdfSearchKeyword").select();
        return false;
    }

    window.open('/tech/' + keyword + '.html');

    return false;
}

//搜索IC
function SearchIc() {
    var keyword = Trim(document.getElementById("IcSearchKeyword").value);
    if(keyword == '')
    {
        alert("请输入您要找的产品型号！")
        document.getElementById("IcSearchKeyword").select();
        return false;
    }
    if(keyword.length < 2) {
        alert('型号不能少于两个字符！');
        document.getElementById("IcSearchKeyword").select();
        return false;
    }
    setHeadSearchCookies(keyword,"ic");  //记cookies 
//    var re = /^[a-zA-Z0-9\@\$\％\-\(\)\+_\·\u00B7\u2022\,\，\ \=]*$/;
//    if(!re.test(keyword))
//    {
//        window.open("/buyer/ic_search.html?SearchKeyword="+encodeURIComponent(keyword));
//    }
//    else
//    {
//         window.open("/ic/"+Base64Encode(keyword)+".html");
//    }
        var striccb = "";
        if(keyword.length == 2){
            striccb = "1";
        }
        window.open("/ic/"+Base64Encode(keyword)+"_1000_____"+striccb+"_.html");
    return false;
}

//指数
function hislist(id) {
    for (var i = 1; i < 5; i++) {
        if (i == id) {
            document.getElementById("hqIndex" + id).className = "hiscur";
            document.getElementById("chart" + id).className = "g_db";
        }
        else {
            document.getElementById("hqIndex" + i).className = "hisli";
            document.getElementById("chart" + i).className = "g_dn";
        }
    }
}

//选择非IC变色
function UnIcMouseOver(obj, eId) {
    var curClass = obj.className;
    var newClass = "";

    var el = document.getElementById(eId);
    el.className = el.className.replace(" boxbg", "");

    if (curClass.indexOf("boxbg") > -1) {
        newClass = curClass + " boxOver";
    } else {
        newClass = curClass + " boxbg boxOver";
    }
    obj.className = newClass;
}

function UnIcMouseOut(obj, eId) {
    var curClass = obj.className;
    var newClass = curClass.replace("boxOver", "");
    obj.className = newClass;
}

//begin 显示顶部Flash下拉广告
//不伸展的广告
function ShowTopAdsNoextend(val) {

    var height = 40;
    if (val != undefined) {
        if (val != "") {
            try {
                height = parseInt(val);
            } catch (e) {
                height = 40;
            }
        }
    }
    document.getElementById("g_AsImageG0101ByJs").style.marginTop = "0px";
    document.getElementById("g_AsImageG0101ByJs").style.marginBottom = "10px";
    document.getElementById("g_AsImageG0101ByJs").style.height = height + "px";
    document.getElementById("g_AsImageG0101ByJs").style.display = "";
}
function ShowTopAds() {
    document.getElementById("g_AsImageG0101ByJs").style.marginTop = "0px";
    document.getElementById("g_AsImageG0101ByJs").style.marginBottom = "10px";
    addCount();

}

function addCount() {
    if (ads_time > 0) {
        ads_time--;
        ads_h = ads_h + 5;
    }
    else {
        return;
    }
    if (ads_h >= 190) //高度 
    {
        return;
    }

    document.getElementById("g_AsImageG0101ByJs").style.height = ads_h + "px";
    setTimeout("addCount()", 30);

}




function ShrinkTopAds() {
    ads_h_2 = document.getElementById("g_AsImageG0101ByJs").style.height;
    ads_h_2 = parseInt(ads_h_2.replace("px", ""));

    delCount();
}

function delCount() {
    if (ads_time_2 > 0) {
        ads_time_2--;
        ads_h_2 = ads_h_2 - 5;
    }
    else {
        return;
    }
    if (ads_h_2 <= 35) //高度 
    {
        return;
    }

    document.getElementById("g_AsImageG0101ByJs").style.height = ads_h_2 + "px";

    setTimeout("delCount()", 30);
}



function CloseTopAds() {

    document.getElementById("g_AsImageG0101ByJs").style.display = "none";
}
//begin 显示顶部Flash下拉广告



//页面跳转到另一个页面
function JumpUrl(url) {
    window.location.href = url;
}



//焦点图片轮换

function adTurnPlay(id,time,type){
    var asobj;
    var aspic ;
    var asbtn ;
    var focusList;
    var btnList;
    var t = 5000;
    if(time){t = time;}
    asobj = document.getElementById(id);
    aspic = document.getElementById(id + '_pic');
    asbtn = document.getElementById(id+'_btn');
    if(!asobj||!aspic||!asbtn) return;
   
    focusList = aspic.getElementsByTagName('li');
    btnList = asbtn.getElementsByTagName('span');
    if(!focusList||!btnList) return;
    if(type!=1 && focusList.length >1)
    {
        asbtn.className = "asbtn g_db";
    }
    var s= 0;
    s=Math.round(Math.random()*(focusList.length-1));
    for(var i=0; i<focusList.length; i++)
    {
        if(i==s)
        {
            focusList[i].className = 'current';
            btnList[i].className = 'current';
        }
        else
        {
            focusList[i].className ='normal';
            btnList[i].className='normal';
        }
    }   
    
    setautoturn(asobj,aspic,asbtn,focusList,btnList,t);
    btnturn(asobj,aspic,asbtn,focusList,btnList);
}


function classNormal(focusList,btnList){
 for(var i=0; i<focusList.length; i++) {
 focusList[i].className='normal';
 btnList[i].className='normal';
 }
}

function classCurrent(n,focusList,btnList){
 focusList[n].className='current';
 btnList[n].className='current';
}

var autoKey = false;
function btnturn(asobj,aspic,asbtn,focusList,btnList) {
     if(!asobj||!aspic||!asbtn) return;
     asobj.onmouseover = function(){autoKey = true};
     asobj.onmouseout = function(){autoKey = false};
     for (var m=0; m<btnList.length; m++){
         btnList[m].onmouseover = function() {
         classNormal(focusList,btnList);
         this.className='current';
         var n=this.childNodes[0].nodeValue-1;
         focusList[n].className='current';
         }
     }
}


function setautoturn(asobj,aspic,asbtn,focusList,btnList,time) {
 setInterval(function(){autoTurn(asobj,aspic,asbtn,focusList,btnList);}, time);
}

function autoTurn(asobj,aspic,asbtn,focusList,btnList) {
 if(!asobj||!aspic) return;
 if (autoKey) return;
 for(var i=0; i<focusList.length; i++) {
     if (focusList[i].className == 'current') {
        var currentNum = i;
     }
 }
 if (currentNum==focusList.length-1 ){
 classNormal(focusList,btnList);
 classCurrent(0,focusList,btnList);
 } else {
 classNormal(focusList,btnList);
 classCurrent(currentNum+1,focusList,btnList);
 }

}

function sellover(obj)
{
    var id=obj.id;
    if(id=="Li1")
    {
        document.getElementById("Li1").className='activeb zli br';
        document.getElementById("Li2").className='activea zli';
        
        document.getElementById("zhsell").style.display="block";
        document.getElementById("ibdData").style.display="none";
    }
    else
    {
        document.getElementById("Li1").className='activea zli br';
        document.getElementById("Li2").className='activeb zli';
        
        document.getElementById("zhsell").style.display="none";
        document.getElementById("ibdData").style.display = "block";
        if (document.getElementById("ibdData").getElementsByTagName("table").length == 0) {
            new Marquee("ibdList", 0, 2, 632, 180, 18, 5000, 5000, 180);
        }
    }
}
//图片切换带文字片
function adTurnPlayTx(id, time, type) {
    var asobj;
    var aspic;
    var asbtn;
    var infoTop2List;
    var btnList;
    var t = 5000;
    if (time) { t = time; }
    asobj = document.getElementById(id);
    aspic = document.getElementById(id + '_pic');
    asbtn = document.getElementById(id + '_btn');
    astx = document.getElementById(id + '_tx');
    if (!asobj || !aspic || !asbtn) return;

    infoTop2List = aspic.getElementsByTagName('li');
    btnList = asbtn.getElementsByTagName('span');
    txList = astx.getElementsByTagName("li");
    if (!infoTop2List || !btnList || !btnList) return;
    if (type != 1 && infoTop2List.length > 1) {
        asbtn.className = "asbtn g_db";
    }
    var s = 0;
    s = Math.round(Math.random() * (infoTop2List.length - 1));
    for (var i = 0; i < infoTop2List.length; i++) {
        if (i == s) {
            infoTop2List[i].className = 'current';
            btnList[i].className = 'current';
            txList[i].className = 'current';
        }
        else {
            infoTop2List[i].className = 'normal';
            btnList[i].className = 'normal';
            txList[i].className = 'normal';
        }
    }

    setAutoTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList, t);
    btnTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList);
}


function classNormalTx(infoTop2List, btnList, txList) {
    for (var i = 0; i < infoTop2List.length; i++) {
        infoTop2List[i].className = 'normal';
        btnList[i].className = 'normal';
        txList[i].className = 'normal';
    }
}

function classCurrentTx(n, infoTop2List, btnList) {
    infoTop2List[n].className = 'current';
    btnList[n].className = 'current';
    txList[n].className = 'current';
}

var autoKey = false;
function btnTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList) {
    if (!asobj || !aspic || !asbtn) return;
    asobj.onmouseover = function() { autoKey = true };
    asobj.onmouseout = function() { autoKey = false };
    for (var m = 0; m < btnList.length; m++) {
        btnList[m].onmouseover = function() {
            classNormalTx(infoTop2List, btnList, txList);
            this.className = 'current';
            var n = this.childNodes[0].nodeValue - 1;
            infoTop2List[n].className = 'current';
            txList[n].className = 'current';
        }
    }
}


function setAutoTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList, time) {
    setInterval(function() { autoTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList); }, time);
}

function autoTurnTx(asobj, aspic, asbtn, infoTop2List, btnList, txList) {
    if (!asobj || !aspic) return;
    if (autoKey) return;
    for (var i = 0; i < infoTop2List.length; i++) {
        if (infoTop2List[i].className == 'current') {
            var currentNum = i;
        }
    }
    if (currentNum == infoTop2List.length - 1) {
        classNormalTx(infoTop2List, btnList, txList);
        classCurrentTx(0, infoTop2List, btnList, txList);
    } else {
        classNormalTx(infoTop2List, btnList, txList);
        classCurrentTx(currentNum + 1, infoTop2List, btnList, txList);
    }

}
