
//翻页 （form中一定有CurrentPage）
function GotoPage(formName,goPage)
{
	if(!isNaN(parseInt(goPage)))
	{
		document.forms(formName).CurrentPage.value=parseInt(goPage);
		document.forms(formName).submit();
	}
}

//清楚文本框内容,下拉列表框置第一列
function clearForm(formName)
{
	var elementType;
	var selectnum;
	for (var i=0;i<document.forms(formName).length;i++)
	{
		elementType=document.forms(formName).elements[i].type;	
		if (elementType=="text" || elementType=="textarea")
		{
			document.forms(formName).elements[i].value="";
		}
		
		if (elementType=="select-one")
		{
			selectnum=0;
/*			for ( var j= 0; j <document.forms(formName).elements[i].options.length; j ++)
			{
				if(document.forms(formName).elements[i].options[j].defaultSelected==true)
				{
					selectnum=j;
					break;
				}
			}*/
			document.forms(formName).elements[i].selectedIndex=selectnum;
		}
	}
}

//确认删除
function confirmDel(str)
{
	if(confirm(str))return true;
	return false;
}

//删除下拉列表的选中option
function delOption(formName,selectName)
{
	var sel=document.forms(formName).elements(selectName);
	if(sel.value=="")
	{
	alert("请选择要删除的项目!")
	return;
	}
	for(i=0;i<sel.options.length;i++)
	{
		if(sel.options(i).selected)
		{
			sel.options.remove(i)
			i--;
		}
	}
}

//显示选中下拉框 
function getSelect(formName,selName,selValue){
	document.forms(formName).elements(selName).value=selValue;
	/*
	for (var i=0;i<document.forms(formName).elements(selName).options.length;i++){
		if (document.forms(formName).elements(selName).options(i).value==selValue){
			document.forms(formName).elements(selName).options(i).selected=true;
		}
	}
	*/
}

// 检测输入项是否有空格(包含对空的检验) 
function checkBlank(s)
{
var re=/^[\s]+[\S]*[\s]*$/
if(re.exec(s) || s==""){
	return true;
	}
else{
	return false;
	}	
}

// 检测输入项是否是大于零的数字(包含对空的检验)
function checkNumber(s)
{
	if (!isNaN(s)&&!checkBlank(s))
	{
		if(s>0)
		{
			return true;
		}else
		{
			return false;
		}
		
	}else{
		return false;
	}
}

//字符串替换  
function replace(str1,str2,str3)
{
	var str="";
	var pos;
	var con=true;
	while(con)
	{
		pos=str1.indexOf(str2);
		if(pos>0)
		{
			str=str + str1.substring(0,pos);
			str=str + str3;
			str1=str1.substring(pos+str2.length,str1.length)
		}else
		{
			con=false;
		}
	}
	if(str.length>0)
	{
		return str+str1;
	}else
	{
		return str1;
	}
}

//全屏打开新窗口,没有工具条	
function openMaxWin(winUrl,winName)
{
	var x=window.screen.width-10;
	var y=window.screen.height-50;
	var win=window.open(winUrl,winName,"width=" + x + ",height=" + y + ",top=0,left=0,resizable=yes,toolbar=no,scrollbars=yes")
	win.focus();
	return;
}

//一般尺寸的窗口‘
function openNorWin(winUrl,winName,wid,hei)
{
	var win=window.open(winUrl,winName,"width=" + wid + ",height=" + hei + ",top=0,left=0,resizable=yes,toolbar=no,scrollbars=yes")
	win.focus();
	return;
}


//全选复选框 
function checkAll(formName,selSwitch,checkName){
	for (var i=0;i<document.forms(formName).length;i++){
		var a=document.forms(formName).elements[i]
		if (a.name==checkName){
			a.checked=document.forms(formName).elements(selSwitch).checked;
		}
	}
}
//前名称相同后跟数字的复选框
function checkNameAll(formName,selSwitch,checkName){
	var namelen=checkName.length;
	for (var i=1;i<=Number(document.forms(formName).totalRec.value);i++){
		var a=document.forms(formName).elements(checkName+i);
		var b=a.name;
	if (b.substring(0,namelen)==checkName){
			a.checked=document.forms(formName).elements(selSwitch).checked;
		}
	}
}

//新增,修改,删除后,刷新列表页
function refleshWin(win)
{
	if(!win.closed)
	{
		if(win.document.forms(0))
		{
			win.document.forms(0).submit();
		}
		window.focus;
	}
}

//打开选择的窗口，并且得到窗口对象
function openSelect(strLink) {
	newWin=window.open(strLink,'','width=750,height=300,top=0,left=0,resizable=yes,toolbar=no,scrollbars=yes')
}

//检查numeric型数据小数
function checkNumeric(strNumeric,leftLen,rightLen)
{
	var pos,len;
	len=strNumeric.length
	pos=strNumeric.indexOf('.');
	if (pos>-1){
		if (pos>leftLen){
			return('整数不能超过'+leftLen+'位！');
		}else if((len-pos-1)>rightLen){
			return('小数不能超过'+rightLen+'位！');
		}
	}else{
		if (len>leftLen){
			return('整数不能超过'+leftLen+'位！');
		}
	}	
	return('');		
}

//显示\隐藏一个页面元素
function openClose(EleName)
{
	if(EleName.style.dispaly=="")
	{
		EleName.style.dispaly="none"
	}else
	{
		EleName.style.dispaly=""
	}
}

function PicLimit(IncludeName,sLength)
//限制所有图片显示尺寸
//参数: IncludeName--字符串,所有图片包含的名称
//	sLength: 限制的宽度或长度,取最大的作限制,等比缩小图片
{
	var imgs=document.images;

	for(i=0;i<imgs.length;i++)
	{
		if(imgs(i).name.indexOf(IncludeName)!=-1)
		{
			if(imgs(i).height>imgs(i).width)
			{
				if(imgs(i).height>sLength){imgs(i).height=sLength}
				
			}else
			{
				if(imgs(i).width>sLength){imgs(i).width=sLength}
			}
		}
	}
}

function PicLimitX(IncludeName,sLength,WidthOrHeight)
//限制所有图片显示尺寸
//参数: IncludeName--字符串,所有图片包含的名称
//	sLength: 限制的宽度或长度,取最大的作限制,等比缩小图片
{
	var imgs=document.images;

	for(i=0;i<imgs.length;i++)
	{
		if(imgs(i).name.indexOf(IncludeName)!=-1)
		{
			if(WidthOrHeight=="height")
			{
				imgs(i).height=sLength;
				
			}else
			{
				imgs(i).width=sLength;
			}
		}
	}
}

function Round(a_Num , a_Bit) 
{ 
if (!isNaN(a_Num))
	return( Math.round(a_Num * Math.pow (10 , a_Bit)) / Math.pow(10 , a_Bit)) ; 
else
	return 0;
} 

function isEmail(email)
{
        invalidChars = " /;,:{}[]|*%$#!()`<>?";
        if (email == "")
        {
                return false;
        }
        for (i=0; i< invalidChars.length; i++)
        {
                badChar = invalidChars.charAt(i)
                if (email.indexOf(badChar,0) > -1)  {
                        return false;
                }
        }
        atPos = email.indexOf("@",1)
        if (atPos == -1)  {   return false;  }
        if (email.indexOf("@", atPos+1) != -1) {   return false;  }
        periodPos = email.indexOf(".",atPos)
        if(periodPos == -1) {
                return false;  // and at least one "." after the "@"
        }
        if ( atPos +2 > periodPos)  {
                return false;  // and at least one character between "@" and "."
        }
        if ( periodPos +3 > email.length)  {   return false;  }
        return true;
}

function trim(str) {
	regExp1 = /^ */;
	regExp2 = / *$/;
	return str.replace(regExp1,'').replace(regExp2,'');
}

function GetCookie(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}
	return "";
}


function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px';
}

//document.oncontextmenu=eventfalse;
//document.onselectstart=eventfalse;

function eventfalse()
{
	window.event.returnValue=false;
}

var currentpos,timer; 
function initialize() 
{ 
	timer=setInterval("scrollwindow()",50); 
}

function sc(){ 
	clearInterval(timer); 
} 

function scrollwindow() 
{ 
	currentpos=document.body.scrollTop; 
	window.scroll(0,++currentpos); 
	if (currentpos != document.body.scrollTop) 
	sc(); 
} 
//document.onmousedown=sc 
//document.ondblclick=initialize 



//控制原始模板LOGO的显示尺寸
function DrawImage1(ImgD){  
   var flag=false;
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*1.2){  
     if(image.width>125){    
     ImgD.width=125;  
     ImgD.height=(image.height*125)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>105){    
     ImgD.height=105;  
     ImgD.width=(image.width*105)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   }

//控制原始模板BOSS的显示尺寸
function DrawImage2(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height*0.9){ 
   if(image.width>155){ 
   ImgD.width=155; 
                      }
                                  }
else{
   if(image.height>=170){
     ImgD.height=170; 
                        }
    }
}

//控制原始模板CORP的显示尺寸
function DrawImage3(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height*2.2){ 
   if(image.width>370){ 
   ImgD.width=370; 
                      }
                                  }
else{
   if(image.height>=170){
     ImgD.height=170; 
                        }
    }
}


//控制模板一LOGO的显示尺寸
function DrawImage1_1(ImgD){  
   var flag=false;
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*2){  
     if(image.width>120){    
     ImgD.width=120;  
     ImgD.height=(image.height*120)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>60){    
     ImgD.height=60;  
     ImgD.width=(image.width*60)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   } 

//控制模板一BOSS的显示尺寸
function DrawImage1_2(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height*1.4){ 
   if(image.width>170){ 
   ImgD.width=170; 
                      }
                                  }
else{
   if(image.height>=120){
     ImgD.height=120; 
                        }
    }
}

//控制模板一CORP的显示尺寸
function DrawImage1_3(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height*2.9){ 
   if(image.width>535){ 
   ImgD.width=535; 
                      }
                                  }
else{
   if(image.height>=185){
     ImgD.height=185; 
                        }
    }
}

//控制模板二LOGO的显示尺寸
function DrawImage2_1(ImgD){  
   var flag=false;
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*1.1){  
     if(image.width>110){    
     ImgD.width=110;  
     ImgD.height=(image.height*110)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>100){    
     ImgD.height100;  
     ImgD.width=(image.width*100)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   } 

//控制模板二BOSS的显示尺寸
function DrawImage2_2(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height){ 
   if(image.width>128){ 
   ImgD.width=128; 
                      }
                                  }
else{
   if(image.height>=128){
     ImgD.height=128; 
                        }
    }
}

//控制模板二CORP的显示尺寸
function DrawImage2_3(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>image.height*3.1){ 
   if(image.width>355){ 
   ImgD.width=355; 
                      }
                                  }
else{
   if(image.height>=115){
     ImgD.height=115; 
                        }
    }
}


//控制模板三LOGO的显示尺寸

function DrawImage3_1(ImgD){ 
   var flag=false;   
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*1.6){  
     if(image.width>125){    
     ImgD.width=125;  
     ImgD.height=(image.height*125)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>80){    
     ImgD.height=80;  
     ImgD.width=(image.width*80)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   }   


//控制模板三BOSS的显示尺寸
function DrawImage3_2(ImgD){  
   var flag=false;
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*1.3){  
     if(image.width>145){    
     ImgD.width=145;  
     ImgD.height=(image.height*145)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>110){    
     ImgD.height=110;  
     ImgD.width=(image.width*110)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   }   


//控制模板三CORP的显示尺寸
function DrawImage3_3(ImgD){  
   var flag=false;
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*1.5){  
     if(image.width>240){    
     ImgD.width=240;  
     ImgD.height=(image.height*240)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>160){    
     ImgD.height=160;  
     ImgD.width=(image.width*160)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   }   
//控制模板系列五LOGO的显示尺寸
//控制模板三LOGO的显示尺寸

function DrawImage5(ImgD){ 
   var flag=false;   
   var image=new Image(); 
   image.src=ImgD.src;  
   if(image.width>0 && image.height>0){  
    flag=true;  
    if(image.width>image.height*2.2){  
     if(image.width>175){    
     ImgD.width=175;  
     ImgD.height=(image.height*175)/image.width;  
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    else{  
     if(image.height>80){    
     ImgD.height=80;  
     ImgD.width=(image.width*80)/image.height;       
     }else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
     }  
    }  
   }   
//模板tradeB1控制logo的尺寸
function DrawImage6(ImgD){ 
 var image=new Image(); 
 image.src=ImgD.src; 
  if(image.height>50){    
     ImgD.height=50;  
     ImgD.width=(image.width*50)/image.height;       
     }
	else{  
     ImgD.width=image.width;    
     ImgD.height=image.height;  
     }  
}
//控制登陆的提交键
function login()
{
	var f=document.VIP;
	if (f.txtUser.value == "")
	{
		alert("用户名不可为空！");
		f.txtUser.focus();
		return ;
	}

	if (f.txtPassword.value == "")
	{
		alert("密码不可为空！");
		f.txtPassword.focus();
		return ;
	}
	f.submit();
}


//控制登陆的提交键（英文）
function loginen()
{
	var f=document.VIP;
	if (f.txtUser.value == "")
	{
		alert("Username cannot be null!");
		f.txtUser.focus();
		return ;
	}

	if (f.txtPassword.value == "")
	{
		alert("Password cannot be null!");
		f.txtPassword.focus();
		return ;
	}
	f.submit();
}
