﻿function T(id,n){ getId(id).style.fontSize=n+"px";}

function ajax(url,urlcs,secid)
{  
	var responseStr=$.ajax({ url:url+"?"+urlcs, async: false}).responseText;
	if(getId(secid)){getId(secid).innerHTML=responseStr;}
	return responseStr;
}

function showclass(id)
{
	for(i=1;i<100;i++)
	{
		if(getId("class"+i)){getId("class"+i).style.display="none"	}
	}
	
	if(getId("class"+id).style.display=="")
	{
		getId("class"+id).style.display="none"	
	}
	else
	{
		getId("class"+id).style.display=""
	}
}

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=\""+(document.body.scrollTop+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,str){
	for(var i=a;i<=b;i++){
		if(i!=n ){
			getId("ContentBody"+n).style.display = "";
			getId("ContentBody"+i).style.display = "none";
			getId("ListTitle"+i).className = str+"off";
			getId("ListTitle"+n).className = str+"on";
		}
	}
}


//图片按比例缩?
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 newwinow(url,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(url,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;
	}
}

//拖动对象
var move_obj={o:null,z:0,x:0,y:0}
function move_(e)
{ 
    e=window.event||e;
    var oDragHandle = e.target || event.srcElement; 
    var topElement = "HTML"; 
    while (oDragHandle.tagName != topElement && oDragHandle.className != "alt_")
    { 
        oDragHandle =oDragHandle.parentNode||oDragHandle.parentElement; 
    } 
    if (oDragHandle.className=="alt_")
    { 
        isdrag = true; 
        move_obj.o = oDragHandle;
        move_obj.z=move_obj.o.style.zIndex;
        move_obj.o.style.zIndex=999;
        y = e.clientY-parseInt(move_obj.o.style.top+0); 
        x = e.clientX-parseInt(move_obj.o.style.left+0); 
        document.onmousemove=function moveMouse(e)
        {
            e=window.event||e;
            if (move_obj.o)with(move_obj.o.style)
            {
                var yy=e.clientY-y;if (yy<0)yy=0;else if (yy+move_obj.o.offsetHeight>document.body.clientHeight)yy=document.body.clientHeight-move_obj.o.offsetHeight;
                var xx=e.clientX-x;if (xx<0)xx=0;else if (xx+move_obj.o.offsetWidth>=document.body.clientWidth)xx=document.body.clientWidth-move_obj.o.offsetWidth;
                top=yy+"px";left=xx+"px";return false;
            }
        } 
        move_obj.o.onmouseup=function(){if(move_obj.o){document.onmousemove=null;move_obj.o.style.zIndex=move_obj.z;}move_obj.o=null;}
        return false; 
    } 
}

function show() {
  var d = new Date();
  var iYear = d.getYear()
  var iMonth = d.getMonth()
  var iDay = d.getDate()
  var sWeek = d.getDay()
  var sHour  = d.getHours()
  var sMinute = d.getMinutes()
  var sSecond = d.getSeconds()
  if(sWeek == 0) sWeek = "<font color=#ff0000 title=周末愉快>星期?/font>";
  if(sWeek == 1) sWeek = "星期一";
  if(sWeek == 2) sWeek = "星期?;
  if(sWeek == 3) sWeek = "星期?;
  if(sWeek == 4) sWeek = "星期?;
  if(sWeek == 5) sWeek = "星期?;
  if(sWeek == 6) sWeek = "<font color=#ff0000 title=周末愉快>星期?/font>";
  if(sHour <= 9) sHour = "0" + sHour;
  if(sMinute <= 9) sMinute = "0" + sMinute;
  if(sSecond <= 9) sSecond = "0" + sSecond;
  sClock = iYear + "? + (iMonth + 1) + "? + iDay + "?" 
    + " " + sHour + ":" + sMinute + ":" + sSecond + "&nbsp;"+sWeek;
getId("clock").innerHTML = sClock;
setTimeout("show()", 1000);
}

function eshow() {
  var d = new Date();
  var iYear = d.getYear()
  var iMonth = d.getMonth()
  var iDay = d.getDate()
  var sWeek = d.getDay()
  var sHour  = d.getHours()
  var sMinute = d.getMinutes()
  var sSecond = d.getSeconds()
  if(sWeek == 0) sWeek = "<font color=#ff0000 title='Happy weekend'>sunday</font>";
  if(sWeek == 1) sWeek = "monday";
  if(sWeek == 2) sWeek = "tuesday";
  if(sWeek == 3) sWeek = "wednesday";
  if(sWeek == 4) sWeek = "thursday";
  if(sWeek == 5) sWeek = "friday";
  if(sWeek == 6) sWeek = "<font color=#ff0000 title='Happy weekend'>saturday</font>";
  if(sHour <= 9) sHour = "0" + sHour;
  if(sMinute <= 9) sMinute = "0" + sMinute;
  if(sSecond <= 9) sSecond = "0" + sSecond;
  sClock = (iMonth + 1) + "/" + iDay + "/" + iYear 
    + " " + sHour + ":" + sMinute + ":" + sSecond + "&nbsp;"+sWeek;
getId("eclock").innerHTML = sClock;
setTimeout("eshow()", 1000);
}

window.onerror=function (){return true;}