/* 
判断指定的内容是否为空，若为空则弹出 警告框 
*/ 
function isEmpty(theValue, strMsg){ 
if(theValue==""){ 
alert(strMsg+"不能为空!"); 
return true; 
} 
return false; 
} 
function errpic(thepic){
	thepic.src="pic/default.gif"  //pic_err.gif is the picture which you want to show onerror
}

/* 
中文判断函数，允许生僻字用英文“*”代替 
返回true表示是符合条件，返回false表示不符合 
*/ 
function isChinese(str){ 
var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
badChar += "abcdefghijklmnopqrstuvwxyz"; 
badChar += "0123456789"; 
badChar += " "+"　";//半角与全角空格 
badChar += "`~!@#$%^&()-_=+]\\\\|:;\\\\\'<,>?/";//不包含*或.的英文符号 
if(""==str){ 
return false; 
} 
for(var i=0;i<str.length;i++){ 
var c = str.charAt(i);//字符串str中的字符 
if(badChar.indexOf(c)<0){ 
return false; 
} 
} 
return true; 
} 
/* 
数字判断函数，返回true表示是全部数字，返回false表示不全部是数字 
*/ 
/*function isNumber(str){ 
if(""==str){ 
return false; 
} 
var reg = /\\D/; 
return str.match(reg)==null; 
} */

function isNumber(str)
{
	if(str=="")
	{return false;}
	if(str*1+""=="NaN")
	{return false;}
	return true;
}
/* 
判断给定的字符串是否为指定长度的数字 
是返回true，不是返回false 
*/ 
function isNumber_Ex(str,len){ 
if(""==str){ 
return false; 
} 

if(str.length!=len){ 
return false; 
} 

if(!isNumber(str)){ 
return false; 
} 
return true; 
} 

function checkEmail(EmailAddress){
//--------------------------------------------------------------------------------
//  Name				Mode		Description
//	EmailAddress		Input		the email address
//
//  Return Value        :   true/false
//	Return Type         :   boolean
//--------------------------------------------------------------------------------	
	var i=0;
	var chr;
	var len;
	var Numbers="0123456789";
	var UpperLetters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var LowerLetters="abcdefghijklmnopqrstuvwxyz";
	var EmailChar= Numbers + UpperLetters + LowerLetters + "@-_.";
	
	len=EmailAddress.length;
	
	//validate all characters
	for(i=0;i<len;i++){
		chr=EmailAddress.charAt(i);
		if(EmailChar.indexOf(chr)==-1){			
			return false;
		}
	}
	
	//Email address must include "@"
	if(EmailAddress.indexOf("@")==-1) return false;		
	//Email address must include "."
	if(EmailAddress.indexOf(".")==-1) return false;	
	//Email address must include only one "@"
	if(EmailAddress.lastIndexOf("@")!=EmailAddress.indexOf("@")) return false;
	//"@" must not be the first or last character
	if(EmailAddress.indexOf("@")==0 || EmailAddress.lastIndexOf("@")==len-1 ) return false;
	if(EmailAddress.indexOf("@.")>-1) return false;
	//"." must be not the first or last character
	if(EmailAddress.indexOf(".")==0 || EmailAddress.lastIndexOf(".")==len-1 ) return false;
	//OK
	return true;
}
/*
图片缩放函数
参数说明：
	ImgD --图片地址
	width --目标宽度
	height --目标高度
*/
var flag=false;
function DrawImage(ImgD,width,height){
    var image=new Image();
    var iwidth =width;  //定义允许图片宽度
    var iheight =height;  //定义允许图片高度
    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;
        }
    }
} 

/*
函数:Allcheck
作用：用于（全选/取消全选）
参数说明：form --表单名
*/
function Allcheck(form)
{
  for(var i=0;i<form.elements.length;i++)
  {
   var e=form.elements[i];
    if(e.name!="checkall")
	{
	  e.checked = form.checkall.checked;
	}
  }
}

/*
函数：ChangeImage
参数说明：
imgpath --图片地址
2005-6-9 郭立江
*/
var imagego=false;
function ChangeImage(imgpath)
  {
  	var image=new Image();
	image.src=imgpath;
	if((image.width>0)&&(image.height>0))
	{
		if((image.width>500)||(image.height>400))
		{
			alert("为了保证您的信息能被访问者迅速找到，建议您上传的图片大小不要超过500*400，\n该图片大小为："+image.width+"*"+image.height);
			imagego=false;
		}
		else
		{
			 var arrstr=new Array();
			 arrstr=imgpath.split(".")
			 var len=arrstr.length;
			 var strext=arrstr[len-1].toLowerCase();
			 if(strext=="gif"||strext=="jpg")
			 {
				imagego=true;
			 }
			 else
			 {
				alert("图片格式不正确，只允许上传JPG或GIF图片");
				imagego=false;
			 }
		}
	}
	else
	{
		imagego=false;
	}
	return imagego;
  }


var checkimg=false;
function CheckImage(imgpath)
  {
  	var image=new Image();
	image.src=imgpath;
	if((image.width>0)&&(image.height>0))
	{
		if((image.width>160)||(image.height>116))
		{
			alert("为了保证您的信息能被访问者迅速找到，建议您上传的图片大小不要超过160*116，\n该图片大小为："+image.width+"*"+image.height);
			imagego=false;
		}
		else
		{
			 var arrstr=new Array();
			 arrstr=imgpath.split(".")
			 var len=arrstr.length;
			 var strext=arrstr[len-1].toLowerCase();
			 if(strext=="gif"||strext=="jpg")
			 {
				checkimg=true;
			 }
			 else
			 {
				alert("图片格式不正确，只允许上传JPG或GIF图片");
				checkimg=false;
			 }
		}
	}
	else
	{
		checkimg=false;
	}
	return checkimg;
  }



var Chkgo=false;
function CheckWord(filepath)
{
	if(filepath!="")
	{
		lowerext=filepath.substring(filepath.length-4,filepath.length);
		lowerext=lowerext.toLowerCase();
		if ((lowerext!=".doc")&&(lowerext!=".txt"))
		{
			alert("上传格式不正确，只允许上传doc或txt图片");
			Chkgo=false;
		}
		else
		{
			Chkgo=true;
		}
	}
	return Chkgo;
}
/*
函数：CheckDel()
作用：用于确定是否删除
*/
function CheckDel()
{
	if(confirm("你确定要删除吗？"))
	{
		return true;
	}
	else
	{
		return false;
	}
}

















































