//分页
function Show_gl(z)
{
	var gs=document.getElementById("Whatever");
	if (gs==null)
	return;
	gs=gs.gs;
	var obj;
	
   if (z==0)
   {
     for(var i=0;i<gs;i++) //合部打开
	{
	   obj=document.getElementById("page_bt_"+i);
	   if (obj==null)
	   return;
	   obj.className="";
	   obj=document.getElementById("page_nr_"+i);
	   if (obj==null)
	   return;
	   obj.style.display="block";
	 
	  
	}
	obj=document.getElementById("page_bt_0");
	if (obj==null)
	   return;
	
	obj.className="Selected";
    return;
   }
   for(var i=0;i<gs;i++)
	{
	   if (i==z)//打开
	   {
	   obj=document.getElementById("page_bt_"+i);
	  
	  
	   if (obj==null)
	   return;
	   obj.className="Selected";
	   obj=document.getElementById("page_nr_"+i);
	   //alert("page_nr_"+i+":"+obj);
	   if (obj==null)
	   return;
	   obj.style.display="block";
	  
	   
	   }
	   else
	   {
	     
	     obj=document.getElementById("page_bt_"+i);
	     if (obj==null)
	      return;
	     obj.className="";
		 obj=document.getElementById("page_nr_"+i);
		 if (obj==null)
	     return;
	     obj.style.display="none";
		 
	   }
	}
	
	
}	

//页框
//说明:页框基数,页框对像,页框长度,行,列,分类,模版,参数,长度,栏目
function ggdk(ks,n,len,wj)
{

   var ob=ob_re("page_gg_"+ks);
   var mli;

   if (ob==null) return;
   var tli=ob.getElementsByTagName("li");
   for(i=0;i<len;i++)
   {
       mli=ob_re("page_nr_"+ks+"_"+i);
      
       if (tli[i]==null || mli==null) return;
	   if (i==n)
	   {
	     tli[i].className="current";
             mli.style.display="block";
		 if (mli.load==null)
         {
	          //标识,文件,更新对像
		      ajax.get("/Pos/ajax.aspx?1=get^"+wj+"^page_nr_"+ks+"_"+i,ggdk_get);
          }
	   }
	   else
	   {
	     tli[i].className="";
             mli.style.display="none";
	   }
		
     }
  
}
//-------------------------------------------------返回
function ggdk_get(z)
{
   z=z.responseText;
  
   var z1=z.split("^");
  
   var ob=ob_re(z1[1]);
   
   
   if (ob==null) return;  
   ob.innerHTML=z1[0];
   ob.load="1";
  
}

//-------------------------------------------------
function tc(z1,z2)
{
	
    
    ajax.get("Pos/ajax.aspx?1=sc^"+z1+"^"+z2,re_tr);
      
   
}
function re_tr(z)
{
	alert("感谢你的收藏,你可以在浏览的下方可以看到你的收藏");
}
//----------------收藏夹商家
function get_sc(z1,z2)
{
//var i9=document;
window.external.addFavorite("http://www.i9gou.com/list`1"+z1+".shtm","云南特产网爱就购-"+z2)
}


//----------------------------------申请定阅邮
function sq_em(ob)
{ 
        
	var kj=ob.split("|");
        var ob1,z="",z1="";
        for (var i=0;i<kj.length;i++)
        {
	  ob1=document.getElementById(kj[i]);
          if (ob1!=null)
             z1=ob1.value;
          if (z1=="")
          {
            alert("此处不能为空")
            ob1.focus();
            return false;
          }
          z=z+z1+"|";
        if (i==0)
	{
          var s=isEmail(z);
	  if (s!=true)
	  {
	     alert("错误:"+s);
	     return false;
	  }
        }
       }
       
       ajax.get("/Pos/ajax.aspx?1=sq_em^"+z,sq_em_re);

	
}
function sq_em_re(z)
{
     z=z.responseText;
     
     if (z=="0")
        alert("感谢您的定阅!");
     else
        alert("操作失败,请在社区留言或请与我们在线客服联系");
}

//----------------------------------
function div_gb(th,obj)
{
 
  
 if (document.getElementById(obj).style.display=="block")
 {
   document.getElementById(obj).style.display="none";
   th.src="images/lyb/expand.gif";
 
 }
 else
 {
   document.getElementById(obj).style.display="block"
   th.src="images/lyb/collapse.gif";
   
 
 }

}
function div_gb1(th,obj)
{
  
 if (document.getElementById(obj).style.display=="block")
 {
   document.getElementById(obj).style.display="none";
   th.src="images/lyb/pic_dp_menu_max.gif";
 
 }
 else
 {
   document.getElementById(obj).style.display="block"
   th.src="images/lyb/pic_dp_menu_min.gif";
   
 
 }

}
//---------------------------打开关闭
function div_kq(obj)
{

 var kj=document.getElementById(obj);
 if (kj==null)
 {
 
  return false;
 }
 if (kj.style.display=="block")
 {
    kj.style.display="none";
   
 }
 else
 {
   kj.style.display="block"

 }

}
//-----------------------------
//email
 function isEmail(z){
  var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
    if (!pattern.exec(z)) return "必须符合电子邮件地址格式";
    return true;
 }
function rz_k(z)
{
  var obj=document.getElementById(z);
  if (obj==null)
  return ;
  if (obj.value=="")
  {
  alert("填写不能为空");
  obj.focus();
  return false;
  }
  return true;
}
//返回编码后的字符串
function setAscII(str){
	var re = "",i;
	for(i = 0;i < str.length;i++){
		re += str.charCodeAt(i) + "!"
	}
	if(re.length > 2){
		re = re.substring(0,re.length - 1)
	}
	return re;
}

//收藏
function sc(id,fl)
{
ajax.get("/Pos/ajax.aspx?1=ls^"+id+"^"+fl,sc_re);
}
function sc_re(z)
{
     z=z.responseText;
     if (z=="-1")//你没有登陆,请先登陆再进行收藏
     { 
      if (confirm("你还没有登陆,是否登陆"))
      {
        window.location="/Login_zc.aspx?http="+setAscII(window.location.href);
      }
      else 
      {return false;}
      
      
     
     }
     alert("操作完毕")
 
}
//------------------把物品放入购物车同时弹出数量
function gwc_tj_sl(id)
{


var sl=prompt("请输入购买数量:", "1"); //数量
if (!isDecimal(sl))
{
 alert("您输入的购买数量错误，所输入的必须是数字");
 return;
}

ajax.get("/Pos/ajax.aspx?1=gwc^"+id+"^"+sl,gwc_tj_re);

}
//------------------购物车
function gwc_tj()
{
var ob=document.getElementById("gmc_sl");
if (ob==null)
{
alert("对像为空请重试");
return;
}
var sl=ob.options[ob.selectedIndex].value; //数量
var id=document.getElementById("gwc_id"); //商品
if (id==null)
{
 alert("取不到所选商品");
 return;
}
id=id.value; //id
ajax.get("/Pos/ajax.aspx?1=gwc^"+id+"^"+sl,gwc_tj_re);

}
//---------------------------------购物车返回处理
function gwc_tj_re(z)
{
    z=z.responseText;
    if (z=="-1")//你没有登陆,请先登陆再进行购物
     { 
      window.location="/Login_zc.aspx?http="+setAscII(window.location.href);
      return;
     
     }
     if (z=="-2")
     {alert("加入购物车失败,请重试");return false;}
    
     alert("已经将物品放入了购物车,请继续购物");
}
function ob_re(z)
{
	if (document.getElementById(z)==null)
	    return document.getElementsByName(z);
	else
		return document.getElementById(z);
}

function img_auto_size(ImgD,iwidth,iheight)//参数(图片,允许的宽度,允许的高度)
{
    
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
   
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
      
        }
    }
} 
//函数名：isDecimal
//功能介绍：检查是否为数字   
//参数说明：要检查的数字   
//返回值：true,false
function  isDecimal(NUM)   
  {   
    var   i,j,strTemp;   
    strTemp="0123456789.";   
    if   (   NUM.length==   0)   
      return   0   
    for   (i=0;i<NUM.length;i++)   
    {   
      j=strTemp.indexOf(NUM.charAt(i));     
      if   (j==-1)   
      {   
        return false
      }   
    }   
    //说明是金额
    return true;
  }   
  
 function myhomepage()
 {
  this.homepage.style.behavior='url(#default#homepage)';
  this.homepage.sethomepage(window.location.href);
 }
 function set_sy()
 {
  var i9=document;
  window.external.addFavorite(i9.location.href,i9.title);
 }
