//验证字符串是否是money格式
function isMoney(str){
 str=replaceAll(str,",","");
 if(isFloat(str)){
	return true;
 }else{
	return false;
 }
}
//验证是否是整数
function isInt(str){
 //alert(str);
 if(str.match("^\[-]?[0-9]+\$")){
	return true;
 }else{
	return false;
 }
}
//验证是否是浮点数
function isFloat(str){
 if(str.match("\^[-]?[0-9]+([.][0-9]*)?\$")){
        return true;
 }else{
        return false;
 }
}
//验证是否为空
function isEmpty(str){
	if(str.match("\^\$")){
		return true;
	}else{
		return false;
	}
}
//验证单选钮或复选钮是否选中
function isCheck(obj){
   	var len = 0;
   	try{
      		len = obj.length;
   	}catch(e){return false;}
	if(obj.length==undefined){
		return obj.checked;
	}else{
		for(var i=0;i<obj.length;i++){
			if(obj[i].checked==true){
				return true;
			}
		}
	}
	return false;
}
//替换字符串
function replaceAll(str,regex,replacement){
   while(str.indexOf(regex)!=-1){
      str=str.replace(regex,replacement);
   }
   return str;
}
//检查下拉菜单是否选中非第一项
function isSelect(obj_Op){
			var obj=obj_Op.options;
			//alert()
			if(obj.length=="undefined"){
			 return true;
			}
			var len=obj.length;
			var i=0;
			for( i=0;i<len;i++){
				//alert(obj_Op.options[i].selected);
			if(obj_Op.options[i].selected==true){
			 break;
			}
			}
			//alert("len:"+len+" selected:"+i);
			if(i==0){
			return false;
			}
			else{
			return true;
			}
					
}
/**
 * 鼠标离开按钮上时 切换样式
 *
 * @param btn 网页上的按钮对象
 */

function btnOut(btn)
{
  btn.className = "buttonOut";
  btn.blur();
}

/**
 * 鼠标移动到按钮上时 切换样式
 *
 * @param btn 网页上的按钮对象
 */
function btnMove(btn)
{
  btn.className = "buttonMove";
}
/*
返回同名的checkBox选中的个数
*/

function getCheckedCount(obj){
	
	var count=0;
	var len=0;
	//try{
		len=obj.length;
	/*	}catch(e){
		return count;
		}*/
		//alert(len);
	if(len==undefined){
		//alert(obj.checked);
		if(obj.checked==true){
			return 1;
			}
		else{
			return 0;
			}
		}
		for(var i=0;i<len;i++){
	            if(obj[i].checked==true)
				count++;
			}
	return count;
}
function showFullSize(){
	
	try{
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth, screen.availHeight);
	}catch(e){}

	
}
//选中单选钮
function getChecked(obj,Value){
	
	var len = 0;
   	try{
      		len = obj.length;
   	}catch(e){return false;}
	if(obj.length==undefined){
		obj.checked="checked";
	}else{
		for(var i=0;i<obj.length;i++){
			if(obj[i].value==Value){
				obj[i].checked="checked";
				return ;
			}
		}
	}
	
}
//检查电话号码

function checkPhome(str){
	if(str==''){
		return true;
		}
	var pho=str.split("-");
	//alert();
	if(pho.length!=2){
		
		alert("输入电话号码请以：区号-电话号码的格式");
		return false;
		}
	if(!isInt(pho[0])){
			alert("区号必须是数字");		
			return false;
		}
	if(!isInt(pho[1])){
			
			alert("电话号码必须是数字");
			return false;
		}
		return true;
	}
	//电话号码不对得话提示清空
function testphone(obj){
	//alert();
	
	if(!(checkPhome(obj.value))){
		//obj.focus();
		obj.value="";
		obj.focus();
		
		}
	
	
	
	}

function checkTime(start_time, end_time){
	
	reVal = /^([1-2]\d{3})[\/|\-](0?[1-9]|10|11|12)[\/|\-]([1-2]?[0-9]|0[1-9]|30|31)$/;
	if(start_time.value != '') 
	{
		if(!reVal.test(start_time.value))
		{
			alert("您的时间输入格式有误");
			return false;
		}
		
	}
	
	if(end_time.value != '') 
	{
		if(!reVal.test(end_time.value))
		{
			alert("您的时间输入格式有误");
			return false;
		}
		
	}
	
	if(start_time.value != '' && end_time.value != '')
	{
		if(start_time.value>end_time.value)
		{
			alert("您输入的开始时间大于结束时间，请更正:)");
			return false;
		}
	}
	
	return true;
	
}






/************按比例约束图片的大小 zhanzhijian 20060910************/

function ResizeImage(imageid,limitWidth,limitHeight) 
{     
    var image = new Image(); 
    image.src = imageid.src; 
     
    if(image.width <= 0 && image.height <= 0) return; 
     
    if(image.width/image.height >= limitWidth/limitHeight) 
    { 
        if(image.width > limitWidth) 
        { 
            imageid.width = limitWidth; 
            imageid.height = (image.height*limitWidth)/image.width; 
        } 
    } 
    else if(image.height > limitHeight) 
    { 
            imageid.height = limitHeight; 
            imageid.width = (image.width*limitHeight)/image.height;      
    } 
     /*
    if (imageid.parentElement.tagName != "A") 
    { 
        imageid.onclick = function(){window.open(this.src);} 
        imageid.style.cursor = "hand"; 
    } */
}


 
//判断邮箱是否正确
function checkUserEmail(email) {
var re = /\w+@\w+\.\w+/;
 if (re.test(email)){
   return true;
   }
 else{
   return false;
}
}

//判断手机

  function checkUserMoblie(moblie)
       {
           if(moblie.length!=11)
			{
			 return false;
			}			
			if(!isInt(moblie))
		  {
			 return false;				
		  }
		 
         return true;
          
       }