﻿//得到控件的ID
function GetObj(objName)
{
  var Name = objName.replace("_", "$")
  if(document.getElementById)
  {
    return eval('document.getElementById("' + Name + '")');
	
  }
  else if(document.layers)
  {
    return eval("document.layers['" + Name +"']");
  }
  else
  {
    return eval('document.all.' + Name);
  }
}


 function checkWeb(web)
 {   
     if(/^http:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.exec(web)==null)
	 {   
        return   false;   
      }
	  else
	  {
		  return true;
	  }
  
}   

function chkEmail(str)
{
    return str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==0?true:false
}


function is_mobile(str){
	if(str.trim()==""){
		return false;
	}
	exp=/^(13|15)([0-9]{9})$/g;   
	if(str.search(exp)==-1){		
		return false;   
	}   
	return true;  
}



String.prototype.trim= function()  
{  
    // 用正则表达式将前后空格  
    // 用空字符串替代。  
    return this.replace(/(^\s*)|(\s*$)/g, "");  
}

function is_number(str){
	if(trim(str)==""){
		return false;
	}
	exp=/[^0-9()-]/g;   
	if(str.search(exp)!=-1){		
		return false;   
	}   
	return true;   
}



function getPhone(str){
 
	exp = /^010[2-9]\d{7}$/g;
	if(str.search(exp)!=-1){		
		return str.substring(0,3) +"-"+ str.substring(3,str.length);   
	}  
	
	exp = /^02[0-9][2-9]\d{6,7}$/g;
	if(str.search(exp)!=-1){		
		return str.substring(0,3) +"-"+ str.substring(3,str.length);   
	}  

	exp = /^0[3-9]\d{2}[2-9]\d{6,7}$/g;
	if(str.search(exp)!=-1){		
		return str.substring(0,4) +"-"+ str.substring(4,str.length);   
	}  

	return "";	
}


/**
 * 定义ForceWindow类构造函数
 * 无参数
 * 无返回值
 */
function ForceWindow ()
{
  this.r = document.documentElement;
  this.f = document.createElement("FORM");
  this.f.target = "_blank";
  this.f.method = "post";
  this.r.insertBefore(this.f, this.r.childNodes[0]);
}


/**
 * 定义open方法
 * 参数sUrl：字符串，要打开窗口的URL。
 * 无返回值
 */
ForceWindow.prototype.open = function (sUrl)
{
  this.f.action = sUrl;
  this.f.submit();
}
