function fetchObject(idname)
{
	if (document.getElementById) {
		return document.getElementById(idname);
	} else if (document.all) {
		return document.all[idname];
	} else if (document.layers) {
		return document.layers[idname];
	} else {
		return null;
	}
}

function fetchOpenerObject(idname)
{
	if (window.opener.document.getElementById) {
		return window.opener.document.getElementById(idname);
	} else if (window.opener.document.all) {
		return window.opener.document.all[idname];
	} else if (window.opener.document.layers) {
		return window.opener.document.layers[idname];
	} else {
		return null;
	}
}

function GetObjValue(objName)
{
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else{
		return eval('document.all.' + objName);
	}
}

//去除空格
function Trim(tmpString) { 
    return tmpString.replace(/(^\s*)|(\s*$)/g, ""); 
} 

function LTrim(tmpString) { 
    return tmpString.replace(/(^\s*)/g, ""); 
} 

function RTrim(tmpSting) { 
    return tmpString.replace(/(\s*$)/g, ""); 
} 
  
//ReplaceAll
String.prototype.ReplaceAll = strReplaceAll; 
function strReplaceAll(findText, replaceText) {
  var str = new String(this);
  while (str.indexOf(findText)!=-1) {
    str = str.replace(findText, replaceText);
  }
  return str;
}   

//ResumeDocument
function ResumeDocument(tmpString){
    return tmpString.ReplaceAll("\n","<br>").ReplaceAll("  ","&nbsp;&nbsp;");
}

//判定email是否合法<return 1 :error>
function CheckEmail(tmpstr){
	var str = tmpstr;
	var patn = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
	if(patn.test(str)){
		
		return 0;
	}else{
		return 1; //incorrect format
	}
}

function CheckMobile(tmpmobile){
	var str = tmpmobile;
	var patn = /^13\d{9}$/;
	if(patn.test(str)){return 0;}
	var patn01 = /^15\d{9}$/;
	if(patn01.test(str)){return 0;} 
	return 1; 	
}

function CheckPhone(tmpphone){
    var str=tmpphone;
    var patn=/(\d+-)?(\d{4}-?\d{7}|\d{3}-?\d{8}|^\d{7,8})(-\d+)?/;
    if(patn.test(str)){return 0;}
	return 1; 	
}

function CheckPhone1(tmpphone1,tmpphone2){
    var str=tmpphone1+"-"+tmpphone2;
    var patn=/(\d+-)?(\d{4}-?\d{7}|\d{3}-?\d{8}|^\d{7,8})(-\d+)?/;
    if(patn.test(str)){return 0;}
	return 1; 	
}

function isNumber(str) {
	var patn = new RegExp("^\\d{1,15}$"); 
	if (patn.test(str)) {
		return 0;
	} else {
		return 1; 	
	}
}

function getTime(){
    var now = new Date();
    now = now.getYear()+"-"+(1+now.getMonth())+"-"+now.getDate()+"  "+ now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
	return now;
}

function creatediv(id,left,top,width,height,alpha,index,htmlDiv){

	var doc=document;
	var p = doc.createElement("div");

	p.id = "DIV_"+id;
	p.style.position = "absolute";
	p.style.setAttribute("left",left+"px");
	p.style.setAttribute("top",top+"px");
	p.style.setAttribute("width",width+"px");
	p.style.setAttribute("height",height+"px");

	p.style.setAttribute("border","0 solid");
	p.style.setAttribute("filter","alpha(opacity="+alpha+")");
	p.style.setAttribute("z-index",index);
	p.innerHTML = htmlDiv;

	document.body.appendChild(p);
}

function removediv(id){
	document.body.removeChild(document.getElementById("DIV_"+id));
}