﻿/*
 *  公用JS
 *  Author: slimboy
 *  Created Date: 2007-10-12
 */


function trim(obj){
	trim_str=obj.split(/^\s+|\s+$/)[0];
	return trim_str;
}

//去掉空格
function DropSpace(str)
{
	return str.replace(/^\s+$/,'');
}
//返回实际长度
String.prototype.lengthB   = 
  function(){return   this.replace(/[^\x00-\xff]/g,"**").length;}   

//获取控件ID
function GetObject(id) 
{
	if(document.getElementById(id)) 
	{
		return document.getElementById(id);
	}
	else if(document.all)
	{
		return document.all[id];
	}
	else if(document.layers)
	{
		return document.layers[id];
	}
}

//验证邮件地址
function IsMail(mail) 
{ 
    return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
}

//定时跳转页面
function jump(url,waitMinute)
{
    var iWaitSecond = waitMinute*1000;
setTimeout(function(){go(url);}, iWaitSecond); 
}
function go(url)
{
document.location.href = url;
}
function OpenMainIframe(WhatPage,WinTitle,WinHeight,WinWidth)
{
/*************************************************************
* 根据情况打开操作窗口
**************************************************************/
	var OpenParams=new Array();
	OpenParams["WhatPage"]=WhatPage;
	OpenParams["WinTitle"]=WinTitle;
	var ReturnValue=new Array();
	ReturnValue=window.showModalDialog(WhatPage,OpenParams,"dialogHeight:" + WinHeight +"px; dialogWidth:" + WinWidth + "px;edge: Raised; center: Yes; help: No; resizable: No; status: No; Target:_self");
	return ReturnValue;
}

