String.prototype.trim = function(){return this.replace(/(^[ |　]*)|([ |　]*$)/g, "");}
function $(v)
{
	return document.getElementById(v);
}
function checkString(id, msg)
{
	var obj = $(id);
	if(obj)
	{
		if(obj.value.trim() == "")
		{
			alert(msg);
			obj.focus();
			return false;
		}
	}

	return true;
}
function myWindow(html, title, width, height)
{
	var str = "<div style='margin-top:0px;margin-left:0px;width:100%;'><ul><li style='float:left;width:90%;'><b>"+ title +"</b></li><li style='float:left;width:10%;'><a href='javascript:closeDiv();'>X</a></li></ul></div>";
	var w = width != null ? width : 400;
	var h = height != null ? height : 250;
	var x = (window.screen.width - w) / 2;
	var y = (window.screen.height - h) / 2;

	var myBG = document.createElement("DIV");
	myBG.id = "MyBG_Div";
	myBG.style.left = 0;
	myBG.style.top  = 0;
	myBG.style.width    = document.documentElement.scrollWidth < window.screen.availWidth ? window.screen.availWidth : document.documentElement.scrollWidth - 10;
	myBG.style.height   = document.body.scrollHeight < document.body.clientHeight ? document.body.clientHeight : document.body.scrollHeight;
	myBG.style.position = "absolute";
	myBG.style.display  = "block";
	myBG.style.zIndex   = "997";
	myBG.style.filter   = "alpha(opacity=50)";
	myBG.style.opacity  = "0.5"; 
	myBG.style.backgroundColor = "#2A4A6B";
	//document.body.appendChild(myBG);
	document.body.insertBefore(myBG, document.body.firstChild);
	
	var myShadow = document.createElement("DIV");
	myShadow.id = "myShadow_Div";
	myShadow.style.left = x+5;
	myShadow.style.top  = y+5;
	myShadow.style.width    = w;
	myShadow.style.height   = h;
	myShadow.style.position = "absolute";
	myShadow.style.display  = "block";
	myShadow.style.zIndex   = "998"; 
	myShadow.style.backgroundColor = "#000000";
	myShadow.style.filter   = "alpha(opacity=20)";
	myShadow.style.opacity  = "0.2"; 
	//document.body.appendChild(myShadow);
	document.body.insertBefore(myShadow, document.body.firstChild);
	
	var myBody = document.createElement("DIV");
	myBody.id = "myMain_Div";
	myBody.style.left = x;
	myBody.style.top  = y;
	myBody.style.width    = w;
	myBody.style.height   = h;
	myBody.style.position = "absolute";
	myBody.style.display  = "block";
	myBody.style.zIndex   = "999"; 
	myBody.style.backgroundColor = "#FFFFFF";
	myBody.style.border = "1px solid #006600";
	myBody.innerHTML = str + "<div style='width:100%'>"+ html + "</div>";
	//document.body.appendChild(myBody);
	document.body.insertBefore(myBody, document.body.firstChild);
	
	closeDiv = function()
	{
		/*$('myBG_Div').style.display = 'none';
		$('myShadow_Div').style.display = 'none';
		$('myMain_Div').style.display = 'none';*/
		document.body.removeChild(myBG);
		document.body.removeChild(myShadow);
		document.body.removeChild(myBody);
	}
}
function showMenu(id)
{
	var a = $("MainNav").getElementsByTagName("li");
	for(var i=0;i<a.length;i++)
	{
		a[i].onmouseover = function() 
		{
			if(this.className!="bai_bg") this.className = "bg";
			isOverMainNav=true;
		}
		a[i].onmouseout = function() 
		{
			if(this.className!="bai_bg") this.className = "bg";
			isOverMainNav=false;
		}
	
		if(a[i].id == id) 
		{
			a[i].className = "bai_bg";
		} 
		else 
		{
			a[i].className = "bg";
		}
	}
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if ( e.type == "checkbox")
		{
			if (e.disabled)
			{
				continue;
			}
			if (!e.checked)
			{
				e.checked = true;
			}
			else
			{
				e.checked = false;
			}
		}
	}
}

function isNumber(str)
{
	var strSource ="0123456789";
	var len = str.length;
	var temp;
	var ch;
	for (var i=0;i<len;i++) 
	{
		ch = str.charAt(i);
		temp = strSource.indexOf(ch);
		if (temp == -1)
		{
			return false;
		}
	}
	return true;
}

function sw(a,b)
{
	a = $(a);
	b = $(b);

	if(a.style.display != 'block')
	{
		a.style.display = 'block';
		b.style.display = 'none';
	}
}
function checkDomain(v)
{
	var v1 = /^http:\/\//gi;
	var v2 = /^www\./gi;
	var v3 = /([^\.]+)(.com|.cn|.org|.net|.com.cn|.tv|.cc|.info|.biz|.tw|.hk|.mobi|.us|.asia)+$/gi;

	if (v.match(v1) != null)
	{
		return false;
	}
	else if (v.match(v2) != null)
	{
		return false;
	}
	else if (v.match(v3) != null)
	{
		return true;
	}
	return false;
}
function showDiv(v)
{
	var o = $(v);
	if (o.style.display == "none")
	{
		o.style.display = "block";
	}
	else
	{
		o.style.display = "none";
	}
}
window._open=window.open;
window.open=function(sURL,sName,sFeatures,bReplace){
  if(sName==undefined){sName="_blank"};
  if(sFeatures==undefined){sFeatures=""};
  if(bReplace==undefined){bReplace=false};
  var win=window._open(sURL,sName,sFeatures,bReplace);
  if(!win){
    alert('你的浏览器不支持javascript脚本，请打开限制！');
    return false;
  }
  return true;
}
function openWindow(url, width, height)
{
	width = width == undefined ? 400 : width;
	height = height == undefined ? 500 : height;

	window.open(url,"New","width="+ width +",height="+ height +",toolbar=1,status=0,location=0,menubar=0,scrollbars=0");
}