// JavaScript Document


//####################   初始化方法开始  ###############################################################

function PublicInitFunction()
{
   nice=setTimeout(function(){$.NiceJForms.build()},1200)
   //################################# 左边横出菜单###############################
   $("#liPromotion").hover(
			function() {
			    at = setTimeout(function() { $("#divPromotion").css({ width: "272px", visibility: "visible" }); }, 300)
			},
			function() {
			    clearTimeout(at)
			    $("#divPromotion").css({ width: "0px", visibility: "hidden" })
			});

	$("#liLimit").hover(
	function() {
	at = setTimeout(function() { $("#divLimit").css({ width: "312px", visibility: "visible"}); }, 300)
	},
	function() {
	    clearTimeout(at)
	    $("#divLimit").css({ width: "0px", visibility: "hidden" })
	});		
	$("#choos1").hover(
	function() {
	    at = setTimeout(function() { $(".mode").css({ width: "272px", visibility: "visible" }); }, 300)
	},
	function() {
	    clearTimeout(at)
	    $(".mode").css({ width: "0px", visibility: "hidden" })
	});
	
 	$("#choos2").hover(
			function() {
				bt=setTimeout(function(){$(".collection").css({width: "272px",visibility:"visible"});},300)		
				},
			function() {
				clearTimeout(bt)
				$(".collection").css({width: "0px",visibility:"hidden"})
			});
	$("#choos3").hover(
			function(){
				ct=setTimeout(function(){$(".color").css({width: "272px",visibility:"visible"});},300)
				    	},
			function() {
				clearTimeout(ct)
				$(".color").css({width: "0px",visibility:"hidden"})
					});
	$("#choos4").hover(
			function() {
				dt=setTimeout(function(){$(".jewelry").css({width: "272px",visibility:"visible"});},300)
				},
			function() {
				clearTimeout(dt)
				$(".jewelry").css({width: "0px",visibility:"hidden"})
				});				
	
	$("#choos5").hover(
			function() {
				et=setTimeout(function(){$(".skin").css({width: "272px",visibility:"visible"});},300)
				},
			function() {
				clearTimeout(et)
				$(".skin").css({width: "0px",visibility:"hidden"})
				});

   //############################### ##########################################################
   
   //显示隐藏高级搜索
    $("#searchall").click(function(){
						    var dis=$(".adserchcontent").css("display");
						    if(dis=="none")
						    {
					            $(".adserchcontent").css({display : "block"});
					            $(".radio-index").find("span").css({display : "block"});
        					   		   
        					    
					            if(curSearchSelect != 0)
					            {
					                SetCategory(curSearchSelect);
					            }
						         advanceSearch = true;    						
						         return false;						
						    }
						    else
						    {
						         $(".adserchcontent").css({display : "none"});
						         $(".radio-index").find("span").css({display : "none"});    											
        						 
						         advanceSearch = false;		
						         return false;
						    }											  
						    });
	    //关闭 隐藏高级搜索
	    $("#searchclose").click( function(){
							    $(".adserchcontent").hide();  
						        $(".adsearchwrap").hide();
						    });
	

     //这里是高级搜索的JS，弹出搜索栏时加载代码，搜索栏隐藏时移除DOCUMENT.WRITE的内容
        $(".adsearchwrap").hover(function(){},function(){
		           $(this).hide()
		           $(".adserchcontent").hide();
		           $(".optionsDivVisible").attr("class","optionsDivInvisible");
		            $(".radio-index").find("span").css({display : "none"});
		           })
        		   
        $("#shopcarbtn").mouseover(
		         function(){
		             $(".singin").hide();
		             $(".shopcar").show();
		             $(".shopcar").hover(function(){},function(){$(".shopcar").hide();});
		          carbag();
		          delgoods();//删除商品		
		           });

        //设置左边菜单‘系列’图片
        SetCollectionImage();
       // 搜索菜单弹出
        $("#searchbox").hover(function(){$(".adsearchwrap").show();},function(){$(".adsearchwrap").hide()});
        $("#searchbg").mouseover(function(){$(".adsearchwrap").show();})
        
}

//#################### 初始化方法结束 ###############################################################




//#################### 购物车自动调整高度 ###############################################################
function carbag()
	{	        //取得商品的高度，
	    		var gh=150-Math.floor($(".Scroller-container-car").height()/100)*10
				var hgh=gh<30?30:gh;	
			    $(".Scrollbar-Handle-car").css({height: hgh+"px"});
				/* 初始购物车滚动条的长度为 hgh ,根据购物车的内容改变其长度*/								
				var ch=$(".Scroller-container-car").height(); //商品长度
				if(ch>=335)
				{         
						$(".goods-container").css({height: "320px",overflow: "hidden"})
						
						//商品总长度大道350 既四个时规定其父亲框长度为350
						$(".carscrof").show();
						$(".Scroller-2").css({top:"0px",position: "absolute"})
						shopCarSlider();
						//长度大道350，显示滚动条
				}else{
						$(".goods-container").css({height: "auto",overflow: "hidden",_height: "20px",_overflow: "visible"})
						$(".carscrof").hide();//滚动条隐藏
						$(".Scroller-2").css({top:"0px",position: "static"})//当商品部足四个，商品框满格显示。
					 }
				
	}	

//#################################购物车滑动##################################################################
function shopCarSlider()
    { 	
	  	var scrollercar  = null;
		var scrollbarcar = null;
		scrollercar  = new jsScrollershopcar(document.getElementById("Scroller-2"), 250, 305);
		scrollbarcar = new jsScrollbarshopcar(document.getElementById("Scrollbar-Container-car"), scrollercar, false); 
		
     }	
function forgetpaswd()//显示忘记密码
	{  
	   //清除弹出框原来的提示行文字
	   ClearMsg("trForgetPwdMsg","tdForgetPwdMsg");
	   $(".forgetwrap").show();
	   $(".singin").hide();
	   $(".forgetwrap").hover(function(){},function(){$(this).hide();})
	}		
	
function allslide(wrap,h,control)    
	{
	//这个是滚动的JS,wrap控制的按钮，control控制的滚动栏,h滚动栏的高度
				   $(wrap).slider({
			        min: 1,
					max: 400, 
			       slide: function(){
			       var a=($(control).height()-h)/400;
				   var move=a*($(wrap).slider("value"))
				   //计算滚动条移动value 后，左边框移动的距离move
				   $(control).css({top: - move+"px" });						             
                    },
                    stop: function(){}
                });		
	}	

function showsearch()
{
	$(".adsearchwrap").show();
	
}	


//###################################################### 登陆部分脚本开始 ###############################################################*/
//登陆
function doSignIn()
{
    if($.trim($("#txtEmail").val())=="")
    {
        SetMsg("trLoginMsg","tdLoginMsg",$("#spanEmail").html());
    }
    else if(!CheckEmail($.trim($("#txtEmail").val())))
    {
        SetMsg("trLoginMsg","tdLoginMsg",$("#spanEmailFormat").html());
    }
    else if($.trim($("#txtPwd").val())=="")
    {
        SetMsg("trLoginMsg","tdLoginMsg",$("#spanPwd").html());
    }
    else
    {
        SetMsg("trLoginMsg","tdLoginMsg",$("#spanLoading").html());
        $.post("do.ashx",{t:"1",e:$("#txtEmail").val(),p:$("#txtPwd").val()},SignInResponse,'json');
    }
}
//登出
function doSignOut()
{
    $.post("do.ashx",{t:"2"},SignOutResponse,'json');
}
//忘记密码
function doForgetPwd()
{
    if($.trim($("#txtPwdEmail").val())=="")
    {
        SetMsg("trForgetPwdMsg","tdForgetPwdMsg",$("#spanEmail").html());
    }
    else if(!CheckEmail($.trim($("#txtPwdEmail").val())))
    {
        SetMsg("trForgetPwdMsg","tdForgetPwdMsg",$("#spanEmailFormat").html());
    }
    else
    {
        SetMsg("trForgetPwdMsg","tdForgetPwdMsg",$("#spanLoading").html());
        $.post("do.ashx",{t:"3",e:$("#txtPwdEmail").val()},ForgetPwdResponse,'json');
    }
}

//登陆处理方法:服务器端返回json ( login:0代表登陆失败,1代表登陆成功; msg:登陆失败返回信息;)
function SignInResponse(result)
{
   //成功登陆
   if(result.login == 1)
   {
        //隐藏对话框
       $(".singin").hide();
       //隐藏链接
       $("#ctl00_spanSignIn").hide();
       
       //显示用户姓名
       $("#ctl00_spanAfterSignIn").show();
       
       ClearMsg("trLoginMsg","tdLoginMsg");
       
       window.location = "myaccount.aspx";
   }
   else
   {
        SetMsg("trLoginMsg","tdLoginMsg",result.msg);
   }
}
//登出处理方法
function SignOutResponse(result)
{
    $("#ctl00_spanAfterSignIn").hide();    
     $("#ctl00_spanSignIn").show();
     window.location = "login.aspx";
}
//忘记密码处理方法:服务器端返回包括两个值的json: success: 0代表失败,1代表成功; msg:执行失败时的错误提示
function ForgetPwdResponse(result)
{
    SetMsg("trForgetPwdMsg","tdForgetPwdMsg",result.msg);
}
//设置错误错误提示
function SetMsg(trID,tdID,msg)
{
    $("#"+tdID).html(msg);
    $("#"+trID).show();
}
//清除错误提示
function ClearMsg(trID,tdID)
{
   $("#"+tdID).html(''); 
    $("#"+trID).hide();
}
//###################################################### 登陆部分脚本结束 ###############################################################*/


//###################################################### 公共方法开始 ###############################################################*/
function CheckEmail(email)
{
    var reg = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    return reg.exec(email);
}

//js获取url参数的function
function GetRequest(paras)
{ 
    var url = location.href.replace("#","");   
    var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");   
    var paraObj = {}   
    for (i=0; j=paraString[i]; i++)
    {   
        paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf 
        ("=")+1,j.length);      
    }   
    var returnValue = paraObj[paras.toLowerCase()];   
    if(typeof(returnValue)=="undefined")
    {   
        return "";   
    }
    else
    {   
        return returnValue;   
    }   
} 
//格式化输出UTC时间
function GetDateString(d)
{
    var str = "";
    str += d.getFullYear();
    if((d.getMonth() + 1)< 10)
        str += "-0" + (d.getMonth() + 1);
     else
        str += "-" + (d.getMonth() + 1);
    if((d.getDate()) < 10)
        str += "-0" + d.getDate(); 
    else
        str += "-" + d.getDate(); 
     return str;
}
//截取字符串 包含中文处理
//(串,长度,增加...)
function CutString(str, len, hasDot)
{
    var newLength = 0;
    var newStr = "";
    var chineseRegex = /[^\x00-\xff]/g;
    var singleChar = "";
    var strLength = str.replace(chineseRegex,"**").length;
    for(var i = 0;i < strLength;i++)
    {
    singleChar = str.charAt(i).toString();
    if(singleChar.match(chineseRegex) != null)
    {
    newLength += 2;
    }
    else
    {
    newLength++;
    }
    if(newLength > len)
    {
    break;
    }
    newStr += singleChar;
    }
    if(hasDot && strLength > len)
    {
    newStr += "...";
    }
    return newStr;
}
//写cookies函数
function SetCookie(name, value)//两个参数，一个是cookie的名子，一个是值
{
    //浏览器关闭，清除cookie
    document.cookie = name + "=" + escape(value) + ";expires=";
}
function GetCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
}


  //#######################   
  //     数字格式化函数   
  //     用法：本函数用来格式化数字。   
  //     参数：num（数值型）：要进行格式化的数值型变量；   
  //     decimalNum（整型） ：要保留的小数位数；   
  //     bolLeadingZero   （布尔型：true或   false）：对-1<num<1之间的数是否要添加前导数字0；   
  //     bolParens        （布尔型：true或   false）：在负号后是否使用小括号；   
  //     bolCommas        （布尔型：true或   false）：是否用“,”隔开数字位。   
  //     boolAddZero      （布尔型：true或   false）：是否在末尾补零。   
  //     返回值：经过格式化的数字字符串。   
  //#######################   
  function   getFormatString(num,decimalNum,boolLeadingZero,boolParens,boolCommas,boolAddZero){   
          if   (isNaN(parseInt(num)))   return   "NaN";   
    
          var   tmpNum   =   num;   
          var   iSign   =   num   <   0   ?   -1   :   1; //   得到数字符号   
    
          //   调整小数点位数到给定的数字。   
          tmpNum   *=   Math.pow(10,decimalNum);   
          tmpNum   =   Math.round(Math.abs(tmpNum))   
          tmpNum   /=   Math.pow(10,decimalNum);   
          tmpNum   *=   iSign; //   重新调整符号   
          var   tmpNumStr   =   new   String(tmpNum);   
    
          //   处理是否有前导0   
          if   (!boolLeadingZero   &&   num   <   1   &&   num   >   -1   &&   num   !=   0){   
                  if   (num   >   0)   
                          tmpNumStr   =   tmpNumStr.substring(1,tmpNumStr.length);   
                  else   
                          tmpNumStr   =   "-"   +   tmpNumStr.substring(2,tmpNumStr.length);   
          }   
    
          //处理是否有逗号   
          if   (boolCommas   &&   (num   >=   1000   ||   num   <=   -1000))   {   
                  var   iStart   =   tmpNumStr.indexOf(".");   
                  if   (iStart   <   0){   
                          iStart   =   tmpNumStr.length;   
                  }   
    
                  iStart   -=   3;   
                  while   (iStart   >=   1)   {   
                          tmpNumStr   =   tmpNumStr.substring(0,iStart)   +   ","   +   tmpNumStr.substring(iStart,tmpNumStr.length)   
                          iStart   -=   3;   
                  }   
          }   
    
          //   处理是否有括号   
          if   (boolParens   &&   num   <   0){   
                  tmpNumStr   =   "("   +   tmpNumStr.substring(1,tmpNumStr.length)   +   ")";   
          }   
    
          //   处理是否补零   
          if   (boolAddZero)   {   
                  var   iStart   =   tmpNumStr.indexOf(".");   
                  if   (iStart   <   0){   
                          iStart   =   tmpNumStr.length;   
                  }   
    
    
                  var   tailStrNum   =   tmpNumStr.substring(iStart).length;   
    
    
                  if(tailStrNum   ==   0){   
                          tmpNumStr   +=   ".";   
                          tmpNumStr   +=   getStrOfSameElmt("0",decimalNum);   
                  }   
                  else{   
                          tmpNumStr   +=   getStrOfSameElmt("0",decimalNum   -   tailStrNum   +   1);   
                  }   
          }   
    
          return   tmpNumStr; //   返回格式化后字符串   
  }   
    
  function   getPower(inDbl){   
          var   power   =   0;   
          var   dbl   =   Math.abs(inDbl);   
    
          if(dbl>1){   
                  while(dbl   >=   10.0){   
                          dbl   /=   10.0;   
                          power   ++;   
                  }   
          }   
          else{   
                  while(dbl   <   1.0){   
                          dbl   *=   10.0;   
                          power   --;   
                  }   
          }   
    
          return   power;   
  }   
    
  function   getScience(inDbl){   
          var   dbl;   
          var   power;   
          var   dblStr;   
    
          power   =   getPower(inDbl);   
    
          dbl   =   inDbl   /   Math.pow(10,power);   
    
          dblStr   =   getFormatString(dbl,3,true,false,true,true);   
    
          dblStr   +=   "E"   +   power;   
    
          return   dblStr;   
  }   
    
  function   getStrOfSameElmt(elmt,times){   
          var   theStr   =   "";   
          for(var   i=0;   i   <   times;   i++){   
                  theStr   +=   elmt;   
          }   
          return   theStr;   
  }
  function GetCurrencySymbol(currency)
    {
        var rtn = "";
        switch(currency)
        {
            case "RMB": 
            case "rmb": rtn = "￥";break
            case "HKD": 
            case "hkd": rtn = "HK＄";break
            case "USD": 
            case "usd": rtn = "US＄";break
        }
        return rtn;
    }
//###################################################### 公共方法结束 ###############################################################*/


/* ################################################################## 购物车相关方法开始  ############################################################### */

//购物车对象
var objCart = {
    CartItem : new Array(),
    Total: 0,
    Currency: "RMB",
    ShippingFee : 0,
    
    AddItem: function(obj){
        var exist = false;
        for(var i=0;i<this.CartItem.length;i++)
        {
            if(this.CartItem[i].Pid == obj.Pid)
            {
                exist = true;
                this.CartItem[i].Quantity +=1;
                this.CartItem[i].SubTotal = parseFloat(this.CartItem[i].Price) * parseFloat(this.CartItem[i].Quantity);
            }
        }       
        
        if(!exist)
        {
            var objCartItem = {"Pid":obj.Pid,"Name":obj.Name,"SKUCode":obj.SKUCode,"Price":obj.Price,"PicPath":obj.PicPath,"Quantity":1,"SubTotal":obj.Price,"Currency":obj.Currency};
            this.CartItem.push(objCartItem);  
            if(this.CartItem.length == 1) this.CartItem.Currency = objCartItem.Currency;       
        }
           
        this.UpdateTotal();
    },
    
    DelItem:function(pid){
        for(var i=0;i<this.CartItem.length;i++)
        {
            if(this.CartItem[i].Pid == pid)
            {
                this.CartItem.pop(this.CartItem[i]);
            }            
        }    
        
        //更新总价
        this.UpdateTotal();
        
        //更新服务器端SESSION
        DeleteCartItem(pid)
    },
    
    ModifyItem: function(pid,qty){
        for(var i=0;i<this.CartItem.length;i++)
        {
            if(this.CartItem[i].Pid == pid)
            {
                this.CartItem[i].Quantity = qty;
                this.CartItem[i].SubTotal = parseFloat(this.CartItem[i].Price) * parseFloat(this.CartItem[i].Quantity);
            }            
        }    
        this.UpdateTotal();
    },
    
    UpdateTotal: function(){
        var totalTmp = 0;
        for(var i=0;i<this.CartItem.length;i++)
        {
            this.CartItem[i].SubTotal = parseFloat(this.CartItem[i].Price) * parseFloat(this.CartItem[i].Quantity);
            totalTmp += parseFloat(this.CartItem[i].SubTotal);            
        }  
        this.Total = totalTmp;
    },
    
    RefreshPageCart : function(){
        $("#spanProductQty").text(this.CartItem.length);
        $("#spanGoodSum").text(this.CartItem.length);
        $("#spanTotalText").html(GetCurrencySymbol(this.Currency) + getFormatString(this.Total,2,true,false,true,true));
        var divHtml = "";
        $("#divCartList").empty();
        for(var i=0;i<this.CartItem.length;i++)
        {
            divHtml ='<div class="goodspic">'+                        
                         '<img src="' + this.CartItem[i].PicPath + '" border="0" alt="" /></div>'+
                         '<ul class="goodsparticular">'+
                         '<li>' + this.CartItem[i].Name + '</li>'+
                         '<li>' + this.CartItem[i].SKUCode + '</li>'+
                         '<li>'+ GetCurrencySymbol(this.CartItem[i].Currency) +getFormatString(this.CartItem[i].Price,2,true,false,true,true)+ ' x ' + this.CartItem[i].Quantity + '</li>'+
                         '<li>'+ GetCurrencySymbol(this.CartItem[i].Currency) +getFormatString(this.CartItem[i].SubTotal,2,true,false,true,true)+ '</li>'+
                         '</ul>';
                var divCartItem = document.createElement("div");
                $(divCartItem).html(divHtml).addClass("goods");
                $("#divCartList").append(divCartItem);
        }
    }
};//购物车对象结束

//调用服务器端服务：添加商品
function AddCartItem(pid)
{
//    iMaker.NeWell.NeWellWebApp.MyService.AddCartItem(pid,CartItemResponse);
    iMaker.NeWell.NeWellWebApp.MyService.AddCartItem(pid);
}

//调用服务器端服务：删除商品
function DeleteCartItem(pid)
{
    iMaker.NeWell.NeWellWebApp.MyService.DeleteCartItem(pid);
}
//客户端删除商品
function DeleteCartItemInPage(pid)
{
    objCart.DelItem(pid);
    objCart.RefreshPageCart();
}
/* ################################################################## 购物车相关方法结束  ############################################################### */

/*################################################################## 搜索相关开始  ############################################################### */
function doSearch()
{    
    var PName = $("#SearchKey").val();            //查询条件PName
    var Model = $("#ctl00_search1_ddlModel").val();            //查询条件Model
    var Collection = $("#ctl00_search1_ddlCollection").val();  //查询条件Collection
    var Color = $("#ctl00_search1_ddlColor").val();            //查询条件Color
    var Jewelry = $("#ctl00_search1_ddlJewelry").val();        //查询条件Jewelry
    var Leathers = $("#ctl00_search1_ddlLeathers").val();      //查询条件Leathers
    var Price = $("#selPriceRange").val();             //查询条件Price
    var PCategory2 = Jewelry;
    var PCategory3 = Leathers;
    var PCategory = "";    
   
    var strParam = "";
    var first = true;
    
    if(PName !="")
    {
         if(first)
         {
            strParam += "?pname="+ encodeURI(PName);
            first = false;
         }
         else
         {
            strParam += "&pname="+ encodeURI(PName);
         }
    }
    if(Model !="" && Model !="0")
    {
         if(first)
         {
            strParam += "?model="+Model;
            first = false;
         }
         else
         {
            strParam += "&model="+Model;
         }
    }
    if(Collection !="" && Collection != "0")
    {
         if(first)
         {
            strParam += "?collection="+Collection;
            first = false;
         }
         else
         {
            strParam += "&collection="+Collection;
         }
    }
    if(Color !="" && Color != "0")
    {
         if(first)
         {
            strParam += "?color="+Color;
            first = false;
         }
         else
         {
            strParam += "&color="+Color;
         }
    }
    if(advanceSearch && curSearchSelect > 1)
    {
         //给PCategory赋值,Jewelry,Leathers
         eval("PCategory = PCategory"+curSearchSelect);  
         
         if(first)
         {
            strParam += "?pcategory="+PCategory;
            first = false;
         }
         else
         {
            strParam += "&pcategory="+PCategory;
         }
    }
    if(Price !="" && Price != "0")
    {
         if(first)
         {
            strParam += "?price="+Price;
            first = false;
         }
         else
         {
            strParam += "&price="+Price;
         }
    }

        if(curSearchSelect == 1)
        {
            if(first)
             {
                strParam += "?ctype="+penCode;
                first = false;
             }
             else
             {
                strParam += "&ctype="+penCode;
             }
        }
        else if(curSearchSelect == 2)
        {
            if(first)
             {
                strParam += "?ctype="+jewelryCode ;
                first = false;
             }
             else
             {
                strParam += "&ctype="+jewelryCode ;
             }
        }
        else if(curSearchSelect == 3)
        {
            if(first)
             {
                strParam += "?ctype="+leathersCode ;
                first = false;
             }
             else
             {
                strParam += "&ctype="+leathersCode ;
             }
        }

    window.location = "search.aspx"+strParam;   
}

var curSearchSelect = 1;
var preSearchSelect = 1;
var advanceSearch = false; //是否为高级搜索状态
function SetCategory(i)
{
//    if(curSearchSelect != 0)
//    {
//        preSearchSelect = curSearchSelect;
//    }
//    else
//    {
//        //首次显示‘笔’
//        preSearchSelect = 1;
//    }

    preSearchSelect = curSearchSelect;
    curSearchSelect = i;
    
    var trSearchShow = ".trSearchSelect"+i;
    $(trSearchShow).show();
    $(".adserchcontent").show();
    if(preSearchSelect != 0 && preSearchSelect != curSearchSelect)
    {
        $(".trSearchSelect"+preSearchSelect).hide();
    }
}
/*################################################################## 搜索相关结束  ############################################################### */


/*################################################################## 菜单图片设置方法开始  ############################################################### */
//页面初始显示第一个类别图片
function SetCollectionImage()
{
    $(".cssImgCollection").hide();
    //Limited image
    $("#divLimitedImage img").hide();
    correctPNG(0);
}
//鼠标滑过显示对应图片
function ShowCateImage(index)
{
    $(".cssImgCollection").hide();
    if($(".cssImgCollection").eq(index).attr("src")!="")
    {
        $(".cssImgCollection").eq(index).show();
       correctPNG(index);
   }}
//鼠标滑过显示对应图片(Limite Edition)
function ShowLimitImage(index) {
    //Limited image
    $("#divLimitedImage>img").hide();
    if (index == -1) return;
    vshow = $("#divLimitedImage>img").eq(index);
    if (vshow.attr("src") != "") {
        vshow.show();
    }
}

//创建PNG
function correctPNG(i) // correctly handle PNG transparency in Win IE 5.5 & 6.
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5)&&(version < 7) && (document.body.filters)) 
    {
          var strIndex = i > 9 ? i : "0"+i;
          var img = document.getElementById("ctl00_menu1_rptCollection2_ctl"+strIndex+"_imgCategory");         
                
              if(img!=null&&img!=""&&img.src!=null)
              {   
                  var imgName = img.src.toUpperCase();
                  if (imgName.indexOf(".PNG") > 0)
                  {
                     var imgID = (img.id) ? "id='" + img.id + "' " : ""
                     var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                     var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "          
                     
                     var strNewHTML = "<span " + imgID + imgClass + imgTitle
                     + " style=\"width:120px;height:500px;cursor:hand;display:inline-block;"
                     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                     + "(src=\'" + img.src+ "\', sizingMethod='image');\"></span>"            
                   
                    img.outerHTML=strNewHTML;
                  }
              }
              else
              {
               return false;
              }          
    }    
}



//function correctPNG(i) // correctly handle PNG transparency in Win IE 5.5 & 6.
//{

//    var arVersion = navigator.appVersion.split("MSIE")
//    var version = parseFloat(arVersion[1])
//    if ((version >= 5.5) && (document.body.filters)) 
//    {
//         var strIndex = i > 9 ? i : "0"+i;
//          var img = document.getElementById("ctl00_rptCollection2_ctl"+strIndex+"_imgCategory");

//          var imgName = img.src.toUpperCase();
//         
//          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
//          {
//             var imgID = (img.id) ? "id='" + img.id + "' " : ""
//             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
//             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
//             var imgStyle = "display:inline-block;" + img.style.cssText 
//             if (img.align == "left") imgStyle = "float:left;" + imgStyle
//             if (img.align == "right") imgStyle = "float:right;" + imgStyle
//             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
//             var strNewHTML = "<span " + imgID + imgClass + imgTitle
//             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
//             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
//             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
//             img.outerHTML = strNewHTML;
//          }
//          
//    }    
//}

/*################################################################## 菜单图片设置方法结束  ############################################################### */
//####################### 删除商品 ##################################################################
//function delgoods()
//	         {  
//				$(".goodsdel").click(
//				function(inde){
//				$(this).parent().parent().remove();
//				//删除掉按键的爷爷！，就是删除掉这个商品所有信息。
//				carbag();//条用购物车自适应高度。
//				})
//               }
//function addgoods()//这个只是参考
//		{ 
//			$(".cargoodslist").append("<div class='goods'><div class='goodspic'><div class='goodsdel'><img src='images/goodsdelete.gif' border='0' alt='' /></div><img src='images/goodspic.gif'  /></div><ul class='goodsparticular'><li>Product name</li><li>SKU No. S0691460</li><li>RMB 80.00 x 2</li><li>RMB160.00</li></ul></div>");
//		 carbag();
//		 //曾加商品，购物车自适应曾加高度
//		 delgoods(); //调用删除，			
//		}
//	