﻿//选项卡
function piInfo(n)
{
    for(var i=1;i<=3;i++)
    {
        if(i==n)
        {
            document.getElementById("li"+i).className="show"+n;
           document.getElementById("dd"+i).className="div";
        }
        else
        {
          document.getElementById("li"+i).className="dis"+i;
           document.getElementById("dd"+i).className="divdis";
        }
    }
}

    function chkcookies()
            {
                 if(confirm("您还没登陆,现在去登陆？"))
                       top.location="../MemberLands.aspx";
            }
            
             function chkcookiessc()
            {
                 if(confirm("您还没登陆,现在去登陆？"))
                       top.location="../MemberLands.aspx";
            }

//产品跳转
function aclick(piid)
{
    top.location="ProductInfo"+piid+".html";
}

//数量验证
function txtchange(obj)
{
    if(obj.value<1)
        obj.value=1;
    if(obj.value> parseInt('999'))
          obj.value=999;
}


function order(id)
{
    alert(id);
    for(var i=1;i<=2;i++)
    {
         if(i==id)
         {
            document.getElementById("li"+id).className="click";
            document.getElementById("div"+id).className="shopingCar_3";
         }
         else{
            document.getElementById("li"+i).className="dis";
            document.getElementById("div"+i).className="divDis";
         }
    }
}


function dgorder(id)
{
    for(var i=1;i<=2;i++)
    {
         if(i==id)
         {
            document.getElementById("dgli"+id).className="click";
            document.getElementById("dgdiv"+id).className="dg_order";
            document.getElementById("dgdiv"+id).style.width="760px";
         }
         else{
            document.getElementById("dgli"+i).className="dis";
            document.getElementById("dgdiv"+i).className="divDis";
         }
   }
}


function Invoice(id)
{
    for(var i=3;i<=4;i++)
    {
         if(i==id)
         {
            document.getElementById("li"+id).className="click";
            document.getElementById("div"+id).className="shopingCar_3";
         }
         else{
            document.getElementById("li"+i).className="dis";
            document.getElementById("div"+i).className="divDis";
         }
    }
}

function del(i)
{
    if(i==0)
        alert("删除成功");
   else
        alert("添加成功");
}


function clearField()
{
     for(var i=0;i<document.elements.length;i++){
           var field=form.elements[i];
           var fieldType=form.elements[i].type.toLowerCase();
           if(fieldType=="checkbox")
           {
              field.checked=false;
           }
     }
}





//////////////////////////
//弹出层
function openLayer(objId,conId){
var arrayPageSize   = getPageSize();//调用getPageSize()函数
var arrayPageScroll = getPageScroll();//调用getPageScroll()函数
if (!document.getElementById("popupAddr")){
//创建弹出内容层
var popupDiv = document.createElement("div");
//给这个元素设置属性与样式
popupDiv.setAttribute("id","popupAddr")
popupDiv.style.position = "absolute";
popupDiv.style.border = "1px solid #ccc";
popupDiv.style.background = "#fff";
popupDiv.style.zIndex = 99;
//创建弹出背景层
var bodyBack = document.createElement("div");
bodyBack.setAttribute("id","bodybg")
bodyBack.style.position = "absolute";
bodyBack.style.width = "100%";
bodyBack.style.height = (arrayPageSize[1] + 35 + 'px');
bodyBack.style.zIndex = 98;
bodyBack.style.top = 0;
bodyBack.style.left = 0;
bodyBack.style.filter = "alpha(opacity=50)";
bodyBack.style.opacity = 0.5;
bodyBack.style.background = "#ccc";
//实现弹出(插入到目标元素之后)
var mybody = document.getElementById(objId);
insertAfter(popupDiv,mybody);//执行函数insertAfter()
insertAfter(bodyBack,mybody);//执行函数insertAfter()
}
//显示背景层
document.getElementById("bodybg").style.display = "";
//显示内容层
var popObj=document.getElementById("popupAddr")
popObj.innerHTML = document.getElementById(conId).innerHTML;
popObj.style.display = "";
//让弹出层在页面中垂直左右居中(统一)
//// popObj.style.width  = "600px";
 popObj.style.clear="both";
 popObj.style.height = "auto";
 popObj.style.top  = arrayPageScroll[1] + (arrayPageSize[3] - 35 - 300) / 2 + 'px';
 popObj.style.left = (arrayPageSize[0] - 20 - 600) / 2 + 'px';
  
//让弹出层在页面中垂直左右居中(个性)
//var arrayConSize=getConSize(conId)
// popObj.style.width  = "980px";
//// popObj.style.height = "600px";
//popObj.style.top  = arrayPageScroll[1] + (arrayPageSize[3] - arrayConSize[1]) / 2-60 + 'px';
//popObj.style.left = (arrayPageSize[0] - arrayConSize[0]) / 2-50  + 'px';
//popObj.style.right =300  + 'px';
}
//获取内容层内容原始尺寸
function getConSize(conId){
var conObj=document.getElementById(conId)
conObj.style.position = "absolute";
conObj.style.left=-1000+"px";
conObj.style.display="inline";
var arrayConSize=[conObj.offsetWidth,conObj.offsetHeight]
conObj.style.display="none";
return arrayConSize;
}
function insertAfter(newElement,targetElement){//插入
var parent = targetElement.parentNode;
if(parent.lastChild == targetElement){
parent.appendChild(newElement);
}
else{
parent.insertBefore(newElement,targetElement.nextSibling);
}
}
//获取滚动条的高度
function getPageScroll(){
var yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){
yScroll = document.documentElement.scrollTop;
} else if (document.body) {
yScroll = document.body.scrollTop;
}
arrayPageScroll = new Array('',yScroll)
return arrayPageScroll;
}
//获取页面实际大小
function getPageSize(){
var xScroll,yScroll;
if (window.innerHeight && window.scrollMaxY){
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){
sScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth,windowHeight;
//var pageHeight,pageWidth;
if (self.innerHeight) {
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) {
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
var pageWidth,pageHeight
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth) {
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
//关闭弹出层
function closeLayer(){
document.getElementById("popupAddr").style.display = "none";
document.getElementById("bodybg").style.display = "none";
return false;
}


//============================图片滚动===================================
<!--
//图片滚动列表 mengjia 070927
var Speed_1 = 10; //速度(毫秒)
var Space_1 = 20; //每次移动(px)
var PageWidth_1 = 150 * 1; //翻页宽度
var interval_1 = 5000; //翻页间隔
var fill_1 = 10; //整体移位
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1="right";
var Comp_1 = 0;
var AutoPlayObj_1=null;
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
function AutoPlay_1(){clearInterval(AutoPlayObj_1);AutoPlayObj_1=setInterval('ISL_GoDown_1();ISL_StopDown_1();',interval_1)}
function ISL_GoUp_1(){if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="left";MoveTimeObj_1=setInterval('ISL_ScrUp_1();',Speed_1);}
function ISL_StopUp_1(){if(MoveWay_1 == "right"){return};clearInterval(MoveTimeObj_1);if((GetObj('ISL_Cont_1').scrollLeft-fill_1)%PageWidth_1!=0){Comp_1=fill_1-(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1);CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrUp_1(){if(GetObj('ISL_Cont_1').scrollLeft<=0){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft+GetObj('List1_1').offsetWidth}
GetObj('ISL_Cont_1').scrollLeft-=Space_1}
function ISL_GoDown_1(){clearInterval(MoveTimeObj_1);if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="right";ISL_ScrDown_1();MoveTimeObj_1=setInterval('ISL_ScrDown_1()',Speed_1)}
function ISL_StopDown_1(){if(MoveWay_1 == "left"){return};clearInterval(MoveTimeObj_1);if(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1-(fill_1>=0?fill_1:fill_1+1)!=0){Comp_1=PageWidth_1-GetObj('ISL_Cont_1').scrollLeft%PageWidth_1+fill_1;CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrDown_1(){if(GetObj('ISL_Cont_1').scrollLeft>=GetObj('List1_1').scrollWidth){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft-GetObj('List1_1').scrollWidth}
GetObj('ISL_Cont_1').scrollLeft+=Space_1}
function CompScr_1(){if(Comp_1==0){MoveLock_1=false;return}
var num,TempSpeed=Speed_1,TempSpace=Space_1;if(Math.abs(Comp_1)<PageWidth_1/2){TempSpace=Math.round(Math.abs(Comp_1/Space_1));if(TempSpace<1){TempSpace=1}}
if(Comp_1<0){if(Comp_1<-TempSpace){Comp_1+=TempSpace;num=TempSpace}else{num=-Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft-=num;setTimeout('CompScr_1()',TempSpeed)}else{if(Comp_1>TempSpace){Comp_1-=TempSpace;num=TempSpace}else{num=Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft+=num;setTimeout('CompScr_1()',TempSpeed)}}
function picrun_ini(){
GetObj("List2_1").innerHTML=GetObj("List1_1").innerHTML;
GetObj('ISL_Cont_1').scrollLeft=fill_1>=0?fill_1:GetObj('List1_1').scrollWidth-Math.abs(fill_1);
GetObj("ISL_Cont_1").onmouseover=function(){clearInterval(AutoPlayObj_1)}
GetObj("ISL_Cont_1").onmouseout=function(){AutoPlay_1()}
AutoPlay_1();
}
//产品展示滚动图片结束
//-->

function friendLink()
{
    var obj=document.getElementById("txtDepict");
    var span=document.getElementById("span");
    if(obj.value=="")
       span.innerHTML="200";
    else
    {
        if(obj.value.length>200)
        {
            obj.value=obj.value.substring(0,200);
            span.innerHTML="0";
            alert("您最多可输入200字");
        }
        else
            span.innerHTML=200-obj.value.length;
    }
    
}


var xmlHttp;
function aa(name)
	{
		var url = "BtnBack.ashx?key=area&val="+name; 
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET" , url , true);
		xmlHttp.send(null);
	}
function stateChanged()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			document.getElementById("divArea").innerHTML = xmlHttp.responseText; 
			//alert(xmlHttp.responseText);
			}
		else{
			document.getElementById("divArea").innerHTML = "处理中，请稍候……";
			}
	}


function GetXmlHttpObject(handler){ 
var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This example doesnt work in Opera") ;
		return; 
	}
	
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP";
		} 
		try{ 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler ;
			return objXmlHttp;
		} 
		catch(e){ 
			alert("Error. Scripting for ActiveX might be disabled") ;
			return 
		} 
	}
	
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
}

function selLoad()
{  
    var name=document.getElementById("txt");
    aa(name.value);
}

function selChange()
{
    var obj=document.getElementById("dlstArea");    
    var name=obj.options[obj.selectedIndex].innerHTML;
    //alert(name);
    aa(name);
}

function test()
{
    document.getElementById("Repeater1$ctl01$aa");
}


function brand_togg(index,count,obj)
{
    for(var i=0;i<count;i++)
    {
        var btn=document.getElementById("btnAll"+i);
        if(i==index)
        {    
            $("#div_more"+index).toggle(1000);
            //alert(index);
           // document.getElementById(obj).innerTEXT="ss";
            //$("#"+obj+"").css("color","red"); 
          
           
            if(btn.className=="brandbtncss")
           {    
              btn.className="brandbtncss_2"; 
           }
           else
           {   
                btn.className="brandbtncss";
           }
        }
        else
            {
                $("#div_more"+i).hide(1000);
                btn.className="brandbtncss"; 
            }
            
    }
    
}


function getCookieCount(count)
{
    document.getElementById("sp_buy").innerHTML=count;
}

function buyOK(count,piid)
{
    if(confirm('商品添加成功, 是否前往购物车查看？'))
    {
        window.open("ShopingCar.html");
        //document.getElementById("sp_buy").innerHTML=count;
    }

    location="ProductInfo"+piid+".html";
  
}

function tgonload()
{
    //setTimeout(tgadBtnDis,5000);
}

function tgadBtnDis()
{
     $("#headTgAd").toggle(1000);
     $("#headTgAd_btn").toggle(10);
     $("#tgad").toggle(1000);
}

function tgadClick()
{
    //alert("11");
    $("#tgad").toggle(1000);
    setTimeout(headTgAdDis,500);
}

function tgadDis()
{
        $("#tgad").toggle(1000);
}

function headTgAdDis()
{
        $("#headTgAd").toggle(1000);
        $("#headTgAd_btn").toggle(1500);
}

function headTgAdBtnClick()
{
     $("#headTgAd").toggle(1000);
      $("#headTgAd_btn").toggle(10);
        setTimeout(tgadDis,500);
}


function headTgAdClick()
{
    window.open("HPTime.html");
}


joeHeight=
{
    init:function()
    {
        var joe=document.getElementById("joe");
        if(!joe){return false;}
        var joe_tr=joe.getElementsByTagName("tr");
        for(var i=0;i<joe_tr.length;i++)
        {
            var joe_left=null,joe_right=null;
            var joe_td=joe_tr[i].getElementsByTagName("td");
            for(var j=0;j<joe_td.length;j++)
            {
                if(joe_td[j].className=="help_joe_list_info_left")
                {
                    joe_left=joe_td[j];
                }
                else if(joe_td[j].className=="help_joe_list_info_right")
                {
                    joe_right=joe_td[j];
                }
            }   
            if(!joe_left||!joe_right){ continue;}
            var row=joe_right.getElementsByTagName("tr").length;
            joe_left.style.height=joe_right.offsetHeight-3+"px";
            joe_left.style.lineHeight=joe_left.style.height;
            //alert(joe_left.style.height);
        }
        
    }
}


//购物车礼品卡充值
function giftBuy()
{
    var tal_gift=document.getElementById("tal_gift");
    if(!tal_gift){return false;}
    
    $("#tal_gift").slideToggle(500); 
    location="#link_gift";
}


////判断余额输入
//function txtGiftChange()
//{
//    var txtYuE=document.getElementById("txtYuE");   //余额
//    if(!txtYuE){return false;}

//    var txtGift=document.getElementById("txtGift");   //礼品卡
//    var lblYuE=document.getElementById("lblYuE");   //允许输入的余额最大数量
//    var lblGift=document.getElementById("lblGift");   //允许输入的礼品卡最大数量
//    var lblAll=document.getElementById("lblAllMoney");   //产品总金额
//    var lblYF=document.getElementById("lblAllFreight");    //运费
//    var lblOrderAllMoney=document.getElementById("lblOrderAllMoney");    //需要支付的金额
//    
//    //判断是否输入
//    if(txtYuE.value.length==0)
//    {
//        txtYuE.value="0";
//    }
//    if(txtGift.value.length==0)
//    {
//        txtGift.value="0";
//    }
//    
//    //判断第一位不可为0
//    if(txtYuE.value[0]=="0")
//    {
//        txtYuE.value="0";
//        txtYuE.select();
//    }
//    if(txtGift.value[0]=="0")
//    {
//        txtGift.value="0";
//        txtGift.select();
//    }
//    
//    //判断是否超出范围
//    if(parseInt(txtYuE.value,10)>parseInt(lblYuE.innerHTML,10))
//    {
//        txtYuE.value="0";
//        alert("对不起，您的余额不足");
//    }
//    if(parseInt(txtGift.value,10)>parseInt(lblGift.innerHTML,10))
//    {
//        txtGift.value="0";
//        alert("对不起，您的礼品卡余额不足");
//    }
//    
//    //判断是否超出总价
//    if((parseInt(txtGift.value,10)+parseInt(txtYuE.value,10))>(parseInt(lblAll.innerHTML,10)+parseInt(lblYF.innerHTML,10)))
//    {
//        txtYuE.value="0";
//        txtGift.value="0";
//        alert('对不起，输入的余额和礼品卡余额总和不可超过订单总价');
//    }
//    
//    lblOrderAllMoney.innerHTML=(parseInt(lblAll.innerHTML,10)+parseInt(lblYF.innerHTML,10))-(parseInt(txtGift.value,10)+parseInt(txtYuE.value,10));
//}

function txtGiftBlur(obj)
{
    if(obj.value.length==0)
    {
        obj.value="0";
    }
}



//添加收货人信息
function AddInsert(id,link)
{
    var tal_gift=document.getElementById(id);
    if(!tal_gift){return false;}

    
    $("#"+id).slideToggle(500); 
    location="#"+link;
}

DOMhelp.addEvent(window,'load',joeHeight.init,false);
