﻿// JScript 文件
var Ex=function (o){for(var k in o)this[k]=o[k];return this}
var UI=function (id){return document.getElementById(id)}
var UIs=function (tag){return Ex.call([],this.getElementsByTagName(tag))}
var Each=function (a,fn)
{for(var i=0;i<a.length;i++)fn.call(a[i],i,a)}
var dhooo=function (ini){
this.bind(ini,this);
this.autoIndex=0;
};
Ex.call(dhooo.prototype,{
bind:function (ini,me){
var dir=ini.dir=='top'?'scrollTop':'scrollLeft',pan=UI(ini.contentID);
var start=function (o){
Each(ini.btns,function(){this.className=''});
o.className=ini.className;
me.autoIndex=o.index;
me.begin(o.index,pan,ini.len,dir);
};
pan.onmouseover=function (){me.stop=true};
Each(ini.btns,function (i){
this.index=i;
this.onmouseover=function (){me.stop=true;start(this)};
pan.onmouseout=this.onmouseout=function(){me.stop=false}
});
var auto=function(){
if(!me.stop){
me.autoIndex=me.autoIndex==bannercount?0:++me.autoIndex;
start(ini.btns[me.autoIndex]);
}
};
if(ini.auto)this.autoPlay=window.setInterval(auto,5000);
}
,begin:function (i,o,len,dir){
    var img=o.getElementsByTagName("li");
    if(document.all)
        img[i].childNodes[0].childNodes[0].style.filter="alpha(opacity=0)";
    else
        img[i].style.opacity=0.05;
    var diff=(i*len-o[dir])*1;
    
o[dir]+=Math[diff>0?'ceil':'floor'](diff);
var opacitynum=0;
(function (me){
clearInterval(me.only);
me.only=setInterval(function (){
opacitynum+=0.05;

if(document.all)
    img[i].childNodes[0].childNodes[0].style.filter="alpha(opacity="+opacitynum*100+")";
else
img[i].style.opacity=opacitynum;


if(opacitynum>=1)clearInterval(me.only);
},10)
})(this)
}
})


if(!isIE_8()){

    new dhooo({
    btns:UIs.call(UI('myTab_btns2'),'LI')
    ,className:'nonce'
    ,contentID:'main2'
    ,len:203
    ,dir:'top'
    ,auto:true
    });
}else{

    new dhooo({
    btns:UIs.call(UI('myTab_btns2'),'LI')
    ,className:'nonce'
    ,contentID:'main2'
    ,len:198
    ,dir:'top'
    ,auto:true
    });
}


function $(id)
{
    return document.getElementById(id);
}
        var productDiv=new Array();
productDiv=[["showproduct1,imgproduct1","productlist1"],["showproduct2,imgproduct2","productlist2"],["showproduct3,imgproduct3","productlist3"],["showproduct4,imgproduct4","productlist4"]];

var playnum=1;

function showproductdiv(id){
if(id==0){id=playnum;}
    for(i=1;i<=4;i++){

            if(i==id){
            $("showproduct"+id).style.display="inline";
            $("imgproduct"+id).style.display="none";
            $("productlist"+id).style.display="";
            }
            else{
            $("showproduct"+i).style.display="none";
            $("imgproduct"+i).style.display="";
            $("productlist"+i).style.display="none";
            }



    }

    if(playnum==4){playnum=1}else{playnum++}

}
var myplay;
function ProductDivPlay(id){
    if(id==""){id=0}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 showhide_divU(showdivid,hidedivid){
    if($(showdivid)!=null){
        $(showdivid).style.display="";
        if(showdivid=='guanzhu')
            $(showdivid+"_title").className="nonce";
        else
            $(showdivid+"_title").className="other nonce";
    }
    if($(hidedivid)!=null){
        $(hidedivid).style.display="none";
        if(hidedivid=='huodong')
            $(hidedivid+"_title").className="other";
        else
            $(hidedivid+"_title").className="";
    }
}


//限时抢购
var the_s=new Array();



function view_time(the_s_index,objid){

    if(the_s[the_s_index]>=0){
        var the_D=Math.floor((the_s[the_s_index]/3600)/24)
        var the_H=Math.floor((the_s[the_s_index]-the_D*24*3600)/3600);
        var the_M=Math.floor((the_s[the_s_index]-the_D*24*3600-the_H*3600)/60);
        var the_S=(the_s[the_s_index]-the_H*3600)%60;
        html = "还剩 ";
        //if(the_D!=0) html += the_D+"天";
        if(the_D!=0 || the_H!=0) html += '<span class="hour">'+(the_H+(the_D*24))+"</span>小时";
        if(the_D!=0 || the_H!=0 || the_M!=0) html += '<span class="minute">'+the_M+"</span>分";
        html += '<span class="second">'+the_S+"</span>秒";
        $(objid).innerHTML = html;
        the_s[the_s_index]--;
    }else{
        $(objid).innerHTML = "已结束";

    }
}



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 scrollImg(){
    var posX,posY;
    if (window.innerHeight) {
        posX = window.pageXOffset;
        posY = window.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
        posX = document.documentElement.scrollLeft;
        posY = document.documentElement.scrollTop;
    }
    else if (document.body) {
        posX = document.body.scrollLeft;
        posY = document.body.scrollTop;
    }
    if(document.body.clientWidth>1024){
    posX=970+((document.body.clientWidth-960)/2);
    }else{
    posX=950+((document.body.clientWidth-960)/2);
    }

    var ad=$("feedback");
    ad.style.top=(posY+100)+"px";
    ad.style.left=(posX)+"px";
    setTimeout("scrollImg()",100);
}

