function $(id) {
    return document.getElementById(id);
}
var playnum = 1;
function showproductdiv(id) {
    if (id == 0) { id = playnum; }
    for (i = 1; i <= 3; i++) {

        if (i == id) {
            $("showproduct" + id).style.display = "block";
            $("imgproduct" + id).style.display = "none";
            $("__I" + id).style.display = "block";
        }
        else {
            $("showproduct" + i).style.display = "none";
            $("imgproduct" + i).style.display = "block";
            $("__I" + i).style.display = "none";
        }
    }
    playnum++;
    if (playnum == 4) { playnum = 1 }
}
var myplay;
function ProductDivPlay(id) {
    if (id == "") { id = 1 } else { playnum = id }

    myplay = setInterval("showproductdiv(0)", 8000);
}
function ProductDivStop() {

    clearInterval(myplay);
}

ProductDivPlay(0);
function showhidediv() {
    for (i = 0; i < arguments.length; i++) {
        if (i == 0) {
            if (arguments[i] == "service") { $(arguments[i]).className = "h2_other nonce" } else { $(arguments[i]).className = "nonce" };
        }
        if (i == 1) {
            $(arguments[i]).style.display = "";
        }
        if (i == 2) {
            if (arguments[i] == "service") { $(arguments[i]).className = "h2_other" } else { $(arguments[i]).className = "" };
        }
        if (i == 3) {
            if (arguments[i] == "service") { $(arguments[i]).className = "h2_other" } else { $(arguments[i]).className = "" };
        }
        if (i == 4) {
            $(arguments[i]).style.display = "none";
        }
        if (i == 5) {
            $(arguments[i]).style.display = "none";
        }
    }
}

function showhidedivbhbang(shownum, idname) {
    for (i = 1; i < 4; i++) {
        if (i == shownum) {
            $(idname + i).style.display = "";
            if (i == 1)
                $(idname + "title" + i).className = "other nonce";
            else
                $(idname + "title" + i).className = "nonce";

        } else {
            $(idname + i).style.display = "none";
            if (i != 1)
                $(idname + "title" + i).className = "";
            else
                $(idname + "title" + i).className = "other";
        }
    }
}

function ScrollText(content, btnPrevious, btnNext, autoStart) {
    this.Delay = 10;
    this.LineHeight = 25;
    this.Amount = 1;
    this.Direction = "up";
    this.Timeout = 4000;

    this.ScrollContent = this.gid(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
    //this.ScrollContent.scrollTop = 0;



    if (btnNext) {
        this.NextButton = this.gid(btnNext);
        this.NextButton.onclick = this.GetFunction(this, "Next");
        this.NextButton.onmouseover = this.GetFunction(this, "Stop");
        this.NextButton.onmouseout = this.GetFunction(this, "Start");
    }
    if (btnPrevious) {
        this.PreviousButton = this.gid(btnPrevious);
        this.PreviousButton.onclick = this.GetFunction(this, "Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
        this.PreviousButton.onmouseout = this.GetFunction(this, "Start");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
    this.ScrollContent.onmouseout = this.GetFunction(this, "Start");
    if (autoStart) {
        this.Start();
    }
}

ScrollText.prototype.gid = function (element) {
    return document.getElementById(element);
}

ScrollText.prototype.Previous = function () {
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("up");
}

ScrollText.prototype.Next = function () {
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("down");
}

ScrollText.prototype.Start = function () {
    clearTimeout(this.AutoScrollTimer);
    this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}

ScrollText.prototype.Stop = function () {
    clearTimeout(this.ScrollTimer);
    clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function () {
    if (this.Direction == "up") {
        if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
            this.ScrollContent.scrollTop = 0;
            clearTimeout(this.AutoScrollTimer);
            this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
            return;
        }
        this.ScrollContent.scrollTop += this.Amount;
    }
    else {
        if (parseInt(this.ScrollContent.scrollTop) <= 0) {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
        this.ScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Delay);
    }
    else {
        this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
    }
}

ScrollText.prototype.Scroll = function (direction) {
    if (direction == "up") {
        if (this.ScrollContent.scrollTop == 0) {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    else {
        this.ScrollContent.scrollTop += this.Amount;
    }
    if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
        this.ScrollContent.scrollTop = 0;
    }
    if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
        this.ScrollTimer = setTimeout(this.GetFunction(this, "Scroll", direction), this.Delay);
    }
}

ScrollText.prototype.GetFunction = function (variable, method, param) {
    return function () {
        variable[method](param);
    }
}
//ff¼æÈÝ
function isIE_c() {
    if (window.navigator.userAgent.toLowerCase().indexOf("msie 8.0") > 1)
        return false;
    return window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1 ? true : false;
}

function isIE_8() {
    if (window.navigator.userAgent.toLowerCase().indexOf("msie 8.0") > 1)
        return true;
    else
        return false;
}



function d_getCookies(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return '';
}
function d_setCookie(name, value, expires, path, domain, secure) {

    var t_dq_now = new Date();
    var t_dq_year = t_dq_now.getFullYear();
    var t_dq_month = t_dq_now.getMonth() + 1;
    var t_dq_date = t_dq_now.getDate();
    var cookietimeout = new Date(t_dq_year + "/" + t_dq_month + "/" + t_dq_date + " 23:59:59");


    var liveDate = new Date();
    //expires = liveDate.setTime(liveDate.getTime() + expires*60*1000);//ºÁÃë
    expires = new Date((new Date()).getTime() + expires * 60000); //°´·ÖÖÓ
    document.cookie = name + "=" + escape(value) + "; expires=" + cookietimeout.toGMTString() +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}



function default_trim(str) { return str.replace(/(\s*$)|(^\s*)/g, ''); };

function startObjVisible(objId) {

    var shows = d_getCookies("showbanner");
    if (shows != "" && shows != "NaN") {
        banner_show_num = shows;
    } else {
        banner_show_num = 1;
    }
    imgObj = document.getElementById('top_ads_pic');
    var bigimg_path = document.getElementById('bigpic_path').value;
    imgObj.src = bigimg_path;
    if (banner_show_num < 3) {
        curSObj = document.getElementById(objId);
        setObjState();
        setObjClose();
    }
}

function setObjState() {
    var width = Math.max(document.documentElement.clientWidth, document.body.clientWidth);
    curSObj.style.left = (width - 960) / 2 + "px";
    curSObj.style.display = "block";

    /*
    if(isIe)
    {
    imgObj.style.filter="alpha(opacity=0)";
    }else
    {
    imgObj.style.opacity=0
    }
    curOpacity=0;
    */
}
function setObjOpen() {
    catalogs = document.getElementById("catalog_S");
    catalogs.style.display = "none";
    curSObj.style.overflow = "hidden";
    divheight -= intHeiStep;
    curSObj.style.height = divheight + "px";
    if (divheight > 0)
        setTimeout('setObjOpen()', intTimeStep);
    else {
        setObjClose();
        return;
    }

    /*
    if(isIe)
    {
    curOpacity+=intAlphaStep;
    imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
    if (curOpacity<100)
    setTimeout('setObjOpen()',intTimeStep);
    else{
    setObjClose();
    return;
    }
    }
    else{
    curOpacity+=intAlphaStep;
    imgObj.style.opacity =curOpacity;
    if (curOpacity<1) setTimeout('setObjOpen()',intTimeStep);else {setObjClose();return};
    }
    */
}
//--------------------
function setObjClose()//
{
    setTimeout('ObjClose()', 7000);
}

function Close_Div() {
    catalogs = document.getElementById("catalog_S");
    catalogs.style.display = "block";
    curSObj.style.display = 'none';
    banner_show_num++;
    d_setCookie("showbanner", banner_show_num, "", "/", "bijia123.com");
}

function ObjClose() {

    divheight -= intHeiStep;
    //imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
    curSObj.style.overflow = "hidden";
    if (divheight > 0)
        curSObj.style.height = divheight + "px";
    else
        curSObj.style.height = '0px';
    if (divheight > 0) {
        setTimeout('ObjClose()', intTimeStep);
    } else { Close_Div(); }

    /*
    if(isIe)
    {
    curOpacity-=10;

    imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
    if (curOpacity>0) {
    setTimeout('ObjClose()',50);}else{Close_Div();}
    }
    else{
    curOpacity-=0.1;
    if (curOpacity>0) {
    imgObj.style.opacity =curOpacity;
    setTimeout('ObjClose()',50);}else{Close_Div();}
    }
    */
}
