//******************************************
//* 文件名：main.js　　　　　　 　　　　　　    *
//* 设计：　　　　　　　　 　　　　　　    *
//* 测试:     　　　　　　　　 　　　　　　     *
//* 时间:2002-8-01 　　　　　　　　 　　　    *
//* 修改:2002-8-11 　　　　　　　　 　　　    *
//* 版本: version 1.1 　　　　　　　　 　　    *
//* 单位：本公司 　　　　　　　　 　　　　       *
//* 描述：项目用到                            *
//       的所有javascript函数 　　　　　　　　 *
//* 制作：
//* 类型：javascript函数 　　　　　　   　     *
//* 参数说明:（详见各函数）     　　　   　     *
//* 调用方法:（详见各函数） 　　    　   　     *
//* 内码: logo:000005;banner:000009; 　 　　 *
//*******************************************
//<SCRIPT LANGUAGE="JavaScript" SRC="main.js"></SCRIPT>
///////////////////  开新窗口函数，
////调用方法    事件如(href,OnClick)="javascript:openwd('query_one.asp?user_no=<%=rs("user_no")%>','query',',10,10,450,400')"
var newWindow = null
	function OpenWind(fileName,windowName,theTop,theLeft,theWidth,theHeight)  //再次点击时不刷新
	{
		if (! newWindow || newWindow.closed)
		{
			newWindow=window.open(fileName,windowName,"width="+theWidth+",height="+theHeight,"toolbar=0,location=0,directories=1,status=0,menubar=0,top="+theTop+",left="+theLeft+",scrollbars=0");
		}else	{
			newWindow.focus();
		}

	}

	function OpenWin(fileName,windowName,theTop,theLeft,theWidth,theHeight)//再次点击时刷新
	{
                //alert("test");
		newWindow=window.open(fileName,windowName,"width="+theWidth+",height="+theHeight,"toolbar=0,location=1,directories=0,status=0,menubar=0,top="+theTop+",left="+theLeft+",scrollbars=0");
		newWindow.focus();
	}

	function OpenW(fileName,windowName,theTop,theLeft,theWidth,theHeight)  //再次点击时不刷新
	{
		if (! newWindow || newWindow.closed)
		{
			newWindow=window.open(fileName,windowName,"width=640,height=520,toolbar=0,location=0,directories=0,status=0,Scrollbars=1,menubar=0,top="+theTop+",left="+theLeft+"");
		}else	{
			newWindow.focus();
		}

	}

		function OpenW_news(fileName,windowName,theTop,theLeft,theWidth,theHeight)  //再次点击时不刷新
	{
		if (! newWindow || newWindow.closed)
		{
			newWindow=window.open(fileName,windowName,"width=600,height=500,toolbar=0,location=0,directories=0,status=1,Scrollbars=1,menubar=0,top="+theTop+",left="+theLeft+"");
		}else	{
			newWindow.focus();
		}

	}


//打开一个div
			function opendiv(div){
				//alert(div+"_close");
				document.all["div_"+div+"_close"].style.clip="rect(0 0 0 0)";
				//alert("hi");
				document.all["div_"+div+"_close"].style.display="block";
				document.all["div_"+div+"_open"].style.display="none";
			}
//关闭一个div
			function closediv(div){
				document.all["div_"+div+"_open"].style.clip="rect(0 0 0 0)";
				document.all["div_"+div+"_open"].style.display="block";
				document.all["div_"+div+"_close"].style.display="none";
			}



//打开一个BBSdiv，更新计数
			function openBBSdiv(div,ID){
				//alert(div+"_close");
				document.all["div_"+div+"_close"].style.clip="rect(0 0 0 0)";
				//alert("hi");
				document.all["div_"+div+"_close"].style.display="block";
				document.all["div_"+div+"_open"].style.display="none";

				ifID.counts.countID.value=ID;
                ifID.counts.submit()
			
//				parent.frames['topFrame'].document.forms['counts'].ID.value=ID;
//				parent.frames['topFrame'].document.forms['counts'].submit();
			}

///////////////////复选框全部选定与取消
		function SelectAll(FormName)
		{

		  for (var i=0;i<document.forms[FormName].elements.length; i++)
		  {
		  var e=document.forms[FormName].elements[i];
		  e.checked=document.forms[FormName].selectstatus.checked;
		  }

		}

	///////////////////
	//功能：退出或删除前提示一下
	function DelQuit(Msg,Url)
	{
		if(confirm(Msg))
		{
			location.href=Url
		}else
		{
			history.go(1)
		}
	}





/////////////////// 上下翻页 
/////////参数说明:page       要显示第几页
/////////参数说明:FormName   表单名
		function PageUpDown(FormName,Page)
		{
		  if (Page!=null){
			document.forms[FormName].Page.value=Page;

			}
			document.forms[FormName].submit();
		}

		function GoPage(FormName,MaxPage)
		{
			if ( isNaN(gopage.Page.value) )
				{
				alert("页面必须为数字！");		
				gopage.Page.focus();
				return (false);
				}
			if (gopage.Page.value=="")
				{
				alert("页码输入不能为空，请重新输入。");
				gopage.Page.focus();
				return (false)
				}
			if(gopage.Page.value>=1&&gopage.Page.value<=MaxPage)
			{
//			    document.forms[FormName].Page.value=gopage.Page.value;
				PageUpDown(FormName,gopage.Page.value)				
			}else
	   	    {
				alert("页码超出范围");
				return false;
//	            history.go(-1) 

			}

		}


		function RefuseEnter()
		{
			alert("请点击GO！");		
//            document.gopage.bt.focus()
//            history.go(-1) 
			return (false);
		}

/////////////////// 上下翻页用于 同一页面include另一个FORM

		function PageUpDown_Form1(Page,SearchWord)
		{
		  if (Page!=null){
			document.forms[1].Page.value=Page;

			}
		  if (SearchWord!=null){
			document.forms[1].SearchWord.value=SearchWord;
			}
			document.forms[1].submit();
		}

		function MessageBox(Msg)
		{
		  alert(Msg);
		  history.go(-1);
		}

//////////////////////////////////////////////////
//////显示与隐藏某个DIV
//////////////////////////////////////////////////
	function ShowHidden(divid,formid)
	{
		if (document.forms[formid].help.value==0){
			document.all[divid].style.display='';
			document.forms[formid].help.value=1
		}else{
			document.all[divid].style.display='none';
			document.forms[formid].help.value=0
		}
	}


//函数名：CheckDate
//功能介绍：检查是否为日期
//参数说明：要检查的字符串
//返回值：0：不是日期  1：是日期
function CheckDate(datestr){
	var lthdatestr;
	if (datestr != ""){
		lthdatestr= datestr.length ;
	}else{
		lthdatestr=0;
	}
	var tmpy="";
	var tmpm="";
	var tmpd="";
	var status;
	status=0;
	if ( lthdatestr== 0){
		return 1;         //允许空为1，否则为0
	}
	for (i=0;i<lthdatestr;i++){
		if (datestr.charAt(i)== '-'){
			status++;
		}
		if (status>2){
			return 0;
		}
		if ((status==0) && (datestr.charAt(i)!='-')){
			tmpy=tmpy+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!='-')){
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!='-')){
			tmpd=tmpd+datestr.charAt(i)
		}
	}
	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2)){
		return 0;
	}
	if (!((1<=month) && (12>=month) && (31>=day) && (1<=day))){
		return 0;
	}
	if (!((year % 4)==0) && (month==2) && (day==29)){
		return 0;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31)){
		return 0;
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31)){
		return 0;
	}
	if ((month==2) && (day==30)){
		return 0;
	}
	return 1;
}




///////////下拉框改变时提交FORM
function ChangeSelect(FormName)
{

		document.forms[FormName].submit();
}


function goUrl(sUrl)
{
   top.document.location.href=sUrl;
}

function goUrlSelf(sUrl)
{
   self.document.location.href=sUrl;
}



function Msg(msg)
{
		window.MsgBox.innerText = msg;	
		window.MsgBox.style.visibility = "visible";
}

function mOvr(src, cOvr) 
{if (!src.contains(event.fromElement)) {src.style.cursor = "default";src.bgColor = cOvr;}}
function mOut(src, cOut) 
{if (!src.contains(event.toElement)) {src.style.cursor = "default";src.bgColor = cOut;}}



function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
    for (i=0;i<theform.length;i++){
	var tempobj=theform.elements[i]
		if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
		//disable em
		tempobj.disabled=true
		}
	}
}

var flag=false;
function DrawImage(ImgD){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= 130/130){
     if(image.width>130){  
     ImgD.width=130;
     ImgD.height=(image.height*130)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>130){  
     ImgD.height=130;
     ImgD.width=(image.width*130)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    }
} 


var flag1=false;
function DrawImage1(ImgD){
   var image1=new Image();
   image1.src=ImgD.src;
   if(image1.width>0 && image1.height>0){
    flag1=true;
    if(image1.width/image1.height>= 580/580){
     if(image1.width>580){  
     ImgD.width=580;
     ImgD.height=(image1.height*580)/image1.width;
     }else{
     ImgD.width=image1.width;  
     ImgD.height=image1.height;
     }
     ImgD.alt=image1.width+"×"+image1.height;
     }
    else{
     if(image1.height>580){  
     ImgD.height=580;
     ImgD.width=(image1.width*580)/image1.height;     
     }else{
     ImgD.width=image1.width;  
     ImgD.height=image1.height;
     }
     ImgD.alt=image1.width+"×"+image1.height;
     }
    }
} 

var flag2=false;
function DrawImage2(ImgD2){
   var image2=new Image();
   image2.src=ImgD2.src;
   if(image2.width>0 && image2.height>0){
    flag2=true;
    if(image2.width/image2.height>= 250/250){
     if(image2.width>250){  
     ImgD2.width=250;
     ImgD2.height=(image2.height*250)/image2.width;
     }else{
     ImgD2.width=image2.width;  
     ImgD2.height=image2.height;
     }
     ImgD2.alt=image2.width+"×"+image2.height;
     }
    else{
     if(image2.height>250){  
     ImgD2.height=250;
     ImgD2.width=(image2.width*250)/image2.height;     
     }else{
     ImgD2.width=image2.width;  
     ImgD2.height=image2.height;
     }
     ImgD2.alt=image2.width+"×"+image2.height;
     }
    }
} 

var flag3=false;
function DrawImage3(ImgD2){
   var image2=new Image();
   image2.src=ImgD2.src;
   if(image2.width>0 && image2.height>0){
    flag3=true;
    if(image2.width/image2.height>= 300/225){
     if(image2.width>300){  
     ImgD2.width=300;
     ImgD2.height=(image2.height*300)/image2.width;
     }else{
     ImgD2.width=image2.width;  
     ImgD2.height=image2.height;
     }
     ImgD2.alt=image2.width+"×"+image2.height;
     }
    else{
     if(image2.height>225){  
     ImgD2.height=225;
     ImgD2.width=(image2.width*225)/image2.height;     
     }else{
     ImgD2.width=image2.width;  
     ImgD2.height=image2.height;
     }
     ImgD2.alt=image2.width+"×"+image2.height;
     }
    }
} 
//-->


today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i]  }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
//document.write(
//"<font size=2> ",
//today.getYear(),"年",
//today.getMonth()+1,"月",
//today.getDate(),"日　",
//d[today.getDay()+1],
//"</font>" ); 


function openbag(id,language) { 
	window.open("basket.asp?language="+language+"&prodid="+id,"","height=400,width=600,left=100,top=50,resizable=yes,scrollbars=auto,status=no,toolbar=no,menubar=no,location=no");
	  } 
function openScript(url, width, height,left,top){
	window.open(url,"","width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",resizable=yes,scrollbars=auto,status=no,toolbar=no,menubar=no,location=no");
}
function openbag2(filename,language) { 
	window.open(filename+".asp?language="+language,"","height=400,width=600,left=100,top=50,resizable=yes,scrollbars=auto,status=no,toolbar=no,menubar=no,location=no");
	  } 
