﻿function getId(id)
{
	return document.getElementById(id);
}

function getName(str)
{
	return document.getElementsByName(str);
}

function getFid(id)
{
	return parent.document.getElementById(id);
}

//数字格式控制
function onlynum(obj){obj.value=obj.value.replace(/\D/g,'')}


//搜索
function Search_check(str1,str2)
{
	if (getId("keyword").value=="" || getId("keyword").value==str1)
	{
		alert(getId("keyword").value);
		getId("keyword").focus();
		return false;
	}
}

//背景色改变效果
function bgcc(obj)
{
	obj.style.backgroundColor="#efefef"
	obj.onmouseout=function(){obj.style.backgroundColor=""}
	
}

function buttonbgcc(obj)
{
	obj.className="mybuttonstyle2"
	obj.onmouseout=function(){obj.className="mybuttonstyle"}
	
}

//关键字写入录入框
function ctag(obj,str)
{
	if(getId(str).value=="")
	{
		getId(str).value=obj.innerText
	}
	else
	{
		getId(str).value=getId(str).value+ " " +obj.innerText
	}
}
//保存数据的时候，锁提交按纽
function lock_button(obj1,obj2,obj3,str)
{
	if(getId(obj1))
	{
	getId(obj1).style.display="none";
	}
	if(getId(obj2))
	{
	getId(obj2).style.display="none";
	}
	if(getId(obj3))
	{
	getId(obj3).innerHTML=str;
	}
}

//消息浮动层显示
function showMsg(str1,str2,w,top)
{
	var Fid = getFid("showMsg_Id");
	var Cid = getFid("showMsg_content");
	var Tid = getFid("showMsg_title");	
	var bgs=getFid("bgs");
	var bgs_ifr=getFid("bgs_ifr");
	if (Fid.style.display == "none")
	{		
		eval("Fid.style.display=\"\";");
		eval("Fid.style.left=\""+(screen.width-w)/2+"px\";");
		eval("Fid.style.width=\""+w+"px\";");
		eval("Fid.style.top=\""+top+"px\";");
		eval("bgs.style.left=\"0px\";");
		eval("bgs.style.width=\"100%\";");
		eval("bgs.style.height=\""+parent.document.body.clientHeight+"px\";");
		eval("bgs.style.display=\"\";");
		eval("bgs_ifr.style.display=\"\";");
		eval("Cid.style.width=\""+w+"px\";");
		eval("Tid.style.width=\""+w+"px\";");
		getFid("showMsg_title").innerHTML=str1;
		getFid("showMsg_content").innerHTML=str2;
	}
	else
	{
		eval("Fid.style.display=\"none\";");
		eval("bgs.style.display=\"none\";");
		eval("bgs_ifr.style.display=\"none\";");
		getFid("showMsg_title").innerHTML="";
		getFid("showMsg_content").innerHTML="";
	}
}


//产品详细资料处资料切换显示
function switchTab(n,a,b){
	for(var i=a;i<=b;i++){
		if(i!=n ){
			getId("ListTitle"+n)
			getId("ContentBody"+n).style.display = "";
			getId("ContentBody"+i).style.display = "none";
			getId("ListTitle"+i).className = "LinkOff";
			getId("ListTitle"+n).className = "LinkOn";
		}
	}
}

//图片按比例缩放 
var flag=false; 
function setimgs(ImgD,w,h){ 
 var image=new Image(); 
 var iwidth = w;
 var iheight = h;
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
 flag=true; 
 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; 
  }
  //ImgD.alt=image.width+"×"+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; 
  }
  //ImgD.alt=image.width+"×"+image.height; 
  } 
 } 
}

//多产品图片时的切换
function chang_img(obj)
{
	src=obj.src;
	Arry_src=src.split("propic/");
	N_src="images/propic/big/"+Arry_src[1]
	getId("big_img").src=N_src;
}

//QQ自由移动层控制
var Obj=''
var index=10000;
function MDown(obj)
{
	if (Ym)clearTimeout(Ym);
	obj.setCapture();	
	obj.setCapture()
	px=obj.offsetLeft-event.x;
	py=obj.offsetTop-event.y;	
	obj.onmousemove=function()
	{
		if(obj)
		{
 			obj.style.left=event.x+px;
 			obj.style.top=event.y+py;			
 		}
	}
	obj.onmouseup=function()
	{
		if (obj)
		{
			var p;
			if (window.innerHeight)p = window.pageYOffset;
  			else if (document.documentElement && document.documentElement.scrollTop)p = document.documentElement.scrollTop;
  			else if (document.body)p = document.body.scrollTop;
			theTop=obj.offsetTop-p;
			theTop=theTop<0?0:theTop;
			obj.releaseCapture();obj=null;initFloatTips();			
		}
	}
}


//控制层移动MDown2(obj)
var Obj2=''
var index2=10000;
document.onmouseup=MUp2
document.onmousemove=MMove2
function MDown2(Object){
Obj2=Object.id
document.all(Obj2).setCapture()
pX=event.x-document.all(Obj2).style.pixelLeft;
pY=event.y-document.all(Obj2).style.pixelTop;
}
function MMove2(){
if(Obj2!=''){
 document.all(Obj2).style.left=event.x-pX;
 document.all(Obj2).style.top=event.y-pY;
 }
}
function MUp2(){
if(Obj2!=''){
 document.all(Obj2).releaseCapture();
 Obj2='';
 }
}

//全选操作
function sel(name){ 
obj=getName(name)
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].checked)
		{
			obj[i].checked=false;  
		}
		else
		{
			obj[i].checked=true;
		}
	}
	
}

//层显示与关闭
function showmenu(menuid)
{
	obj=getId("menuid"+menuid)	
	if (obj.style.display == "none")
	{
		obj.style.display = "";
	}
	else
	{
		obj.style.display = "none";
	}
}

//翻页跳转
function gotopage(obj){
	var jmpurl=obj.value;
	if(jmpurl!='')
	{
		location.href=jmpurl;
	}
	else
	{
		this.selectedindex=0;};
	}

//新窗口打开页面
function newin(fname,w,h){
var win = null;
var myname="";
var scroll="yes";
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(fname,myname,settings)
}

//操作判断
function confirm_do(){
	if (confirm("您确定如此操作吗？")){
		return true;
	}
	return false;
}

//后台版面控制
forumpath="../"
function DvMenuCls(){
	var MenuHides = new Array();
	this.Show = function(obj,depth){
		var childNode = this.GetChildNode(obj);
		if (!childNode){return ;}
		if (typeof(MenuHides[depth])=="object"){
			this.closediv(MenuHides[depth]);
			MenuHides[depth] = '';
		};
		if (depth>0){
			if (childNode.parentNode.offsetWidth>0){
				childNode.style.left= childNode.parentNode.offsetWidth+'px';
				
			}else{
				childNode.style.left='100px';
			};
			
			childNode.style.top = '-2px';
		};
		childNode.style.display ='block';
		MenuHides[depth]=childNode;
	
	};
	this.closediv = function(obj){
		if (typeof(obj)=="object"){
			if (obj.style.display!='none'){
			obj.style.display='none';
			}
		}
	}
	this.Hide = function(depth){
		var i=0;
		if (depth>0){
			i = depth
		};
		while(MenuHides[i]!=null && MenuHides[i]!=''){
			this.closediv(MenuHides[i]);
			MenuHides[i]='';
			i++;
		};
	
	};
	this.Clear = function(){
		for(var i=0;i<MenuHides.length;i++){
			if (MenuHides[i]!=null && MenuHides[i]!=''){
				MenuHides[i].style.display='none';
				MenuHides[i]='';
			}
		}
	}
	this.GetChildNode = function(submenu){
		for(var i=0;i<submenu.childNodes.length;i++)
		{
			if(submenu.childNodes[i].nodeName.toLowerCase()=="div")
			{
				var obj=submenu.childNodes[i];
				break;
			}
		}
		return obj;
	}
}


function showorder(order)
{
whichEl = eval("order" + order);
if (whichEl.style.display == "none")
{eval("order" + order + ".style.display=\"\";");getId("order_look"+order).innerHTML='<font color=red>关闭</font>'}
else
{eval("order" + order + ".style.display=\"none\";");getId("order_look"+order).innerHTML='查看'}
}

//购物车系统
var _i=Math.random();
function pro_zc(id)
{
++_i;
var responseText=$.ajax({ url:"shopcart/zc.asp?id="+id+"&a="+_i, async: false }).responseText;
	if(responseText.substring(0,1)=="1")
	{
	getId('zc').style.display="";
	getId('zc').style.top=event.y+document.body.scrollTop-getId('zc').offsetHeight;
	getId('zc').style.left=event.x-getId('zc').offsetWidth/2;
	getId('carturl_1').style.display="";
	getId('carturl_2').style.display="none";
	getId('seczc').innerHTML="<img src='images/sec.jpg' align='absmiddle' />暂存成功！";
	getId('cartname').innerHTML="购物车"
	getId('nums_pro').innerHTML=responseText.substring(1,10)
	}
	else if(responseText.substring(0,1)=="0")
	{
	getId('zc').style.display="";
	getId('zc').style.top=event.y+document.body.scrollTop-getId('zc').offsetHeight;
	getId('zc').style.left=event.x-getId('zc').offsetWidth/2;
	getId('carturl_1').style.display="";
	getId('carturl_2').style.display="none";
	getId('seczc').innerHTML="<img src='images/sec2.jpg' align='absmiddle' /><font color=red>暂存失败，此商品已在购物车中！</font>";
	getId('cartname').innerHTML="购物车"
	getId('nums_pro').innerHTML=responseText.substring(1,10)
	}
	else
	{
	alert('您未登陆或登陆超时！');
	}
}
function pro_sc(id)
{
++_i;
var responseText=$.ajax({ url:"shopcart/sc.asp?id="+id+"&a="+_i, async: false }).responseText;
	if(responseText.substring(0,1)=="1")
	{	
	getId('zc').style.display="";
	getId('zc').style.top=event.y+document.body.scrollTop-getId('zc').offsetHeight;
	getId('zc').style.left=event.x-getId('zc').offsetWidth/2;
	getId('carturl_2').style.display="";
	getId('carturl_1').style.display="none";
	getId('seczc').innerHTML="<img src='images/sec.jpg' align='absmiddle' />收藏成功！";
	getId('cartname').innerHTML="收藏夹"
	getId('nums_pro').innerHTML=responseText.substring(1,10)
	}
	else if(responseText.substring(0,1)=="0")
	{
	getId('zc').style.display="";
	getId('zc').style.top=event.y+document.body.scrollTop-getId('zc').offsetHeight;
	getId('zc').style.left=event.x-getId('zc').offsetWidth/2;
	getId('carturl_2').style.display="";
	getId('carturl_1').style.display="none";
	getId('seczc').innerHTML="<img src='images/sec2.jpg' align='absmiddle' /><font color=red>收藏失败，此商品已在收藏夹中！</font>";
	getId('cartname').innerHTML="收藏夹"
	getId('nums_pro').innerHTML=responseText.substring(1,10)
	}
	else
	{
	alert('您未登陆或登陆超时！');
	}
}

function closeseczc()
{
	getId('zc').style.display="none";
}


function mycheck2()
{	
	if (getId("proid").value!="" && isNaN(getId("proid").value))
	{
		alert("请输入正确商品编号！");
		getId("proid").focus();
		return false;
	}
	if (getId("price1").value!="" && isNaN(getId("price1").value))
	{
		alert("请输入数字格式！");
		getId("price1").focus();
		return false;
	}
	if (getId("price11").value!="" && isNaN(getId("price11").value))
	{
		alert("请输入数字格式！");
		getId("price11").focus();
		return false;
	}
	if (getId("price2").value!="" && isNaN(getId("price2").value))
	{
		alert("请输入数字格式！");
		getId("price2").focus();
		return false;
	}
	if (getId("price22").value!="" && isNaN(getId("price22").value))
	{
		alert("请输入数字格式！");
		getId("price22").focus();
		return false;
	}
	
	if (getId("price1").value!="" &&getId("price11").value=="")
	{
		alert("请输入完整的价格区间！");
		getId("price11").focus();
		return false;
	}
	if (getId("price2").value!="" &&getId("price22").value=="")
	{
		alert("请输入完整的价格区间！");
		getId("price22").focus();
		return false;
	}
}

//搜索订单
function search_Order()
{

	if (getId("order_search").value=="" ||getId("order_search").value=="请输入订单编号")
	{
		alert("请输入订单编号");
		getId("order_search").focus();
		return false;
	}
	if (getId("order_search").value=="" || isNaN(getId("order_search").value)==true || getId("order_search").value.length!=11)
	{
		alert("请输入正确的订单编号！");
		getId("order_search").focus();
		return false;
	}	
}

function del_order(obj)
{
	if(confirm("确定执行？"))
	{
	obj.checked=true;	
	}
	else
	{
	obj.checked=false;	
	}
}


function getvoteids()
{
	var ids="";
	var votelist=document.getElementsByName("voteids")
	for(i=0;i<votelist.length;i++)
	{
		if(votelist[i].checked)
		{
			ids+=votelist[i].value+',';	
		}
	}
	ids=ids.substring(0,ids.length-1)	
	if (ids==""){alert("请选择投票选项！"); return;}
	myvoteajax(ids);
	for(i=0;i<votelist.length;i++)
	{
		votelist[i].checked=false;
	}
}

function myvoteajax(id)
{
++_i;
var responseText=$.ajax({ url:"fun/vote/alz_vote_do.asp?id="+id+"&a="+_i, async: false }).responseText;
	if(responseText=="0")
	{
		alert('此投票已经过期，无效投票！');
	}	
	else if(responseText=="1")
	{	
		alert('此IP已经投过票，感谢您热情的参与！');
	}
	else if(responseText=="2")
	{
		alert('投票成功，感谢您的参与！');
	}	
	else
	{
	alert('投票时间间隔为'+responseText.substring(1,5)+'分钟');
	}
}

function getvoteids2()
{
	var ids="";
	var votelist=document.getElementsByName("voteids")
	for(i=0;i<votelist.length;i++)
	{
		if(votelist[i].checked)
		{
			ids+=votelist[i].value+',';	
		}
	}
	ids=ids.substring(0,ids.length-1)	
	if (ids==""){alert("请选择投票选项！"); return;}
	myvoteajax2(ids);
	for(i=0;i<votelist.length;i++)
	{
		votelist[i].checked=false;
	}
}

function myvoteajax2(id)
{
++_i;
var responseText=$.ajax({ url:"alz_vote_do.asp?id="+id+"&a="+_i, async: false }).responseText;
	if(responseText=="0")
	{
		alert('此投票已经过期，无效投票！');
	}	
	else if(responseText=="1")
	{	
		alert('此IP已经投过票，感谢您热情的参与！');
	}
	else if(responseText=="2")
	{
		alert('投票成功，感谢您的参与！');
	}	
	else
	{
	alert('投票时间间隔为'+responseText.substring(1,5)+'分钟');
	}
}

function AutoIframe(obj)
{
	if(document.readyState!='complete')
	{
		setTimeout( function(){AutoIframe(obj);},25 );
		return;
	}
	else
	{
	   obj.height= obj.contentWindow.document.body.scrollHeight;
	}
}

window.onerror=function (){return true;}
