/**
*是否为空
*/
function isBlank(value)
{
	var w_space = String.fromCharCode(32);
	if(value.length < 1)
	{
		return true;
	}
	var v_length = value.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length)
	{
		if(value.charAt(iTemp) != w_space)
		{
			return false;
		}
		iTemp = iTemp + 1;
	} //End While
	return true;
} //End Function

function deal_play()
{
	try
	{
		top.document.getElementById("play").controls.stop();
		top.document.getElementById("mod_bgmusic").innerHTML = "";
	}
	catch(err)
	{

	}
}
function later_reload()
{
	//deal_play();
	window.setTimeout(function(){top.location.reload();}, 1000);
}
function go_login(forward)
{
	var url_array = location.hostname.split("dm72");
	top.location.href= "http://user.dm72" + url_array[1] + "/user/user_login.php?com_url=" + forward;
}
//验空的函数
function check_blank(id)
{
	ele = document.getElementById(id);
	len = bytes(ele.value);
	if(len==0)
	{
		return false;
	}
	else
	{
		return true;
	}
}
//验字节数多于
function check_bytem(id, smax)
{
	ele=document.getElementById(id);
	len=bytes(ele.value);
	if(len > smax)
	{
		return false;
	}
	else
	{
		return true;
	}
}
//验证字节数少于
function check_bytes(id, smin)
{
	ele=document.getElementById(id);
	len=bytes(ele.value);
	if(len < smin)
	{
		return false;
	}
	else
	{
		return true;
	}
}
//验证字节数多于和少于
function check_byte_all(id,smin,smax)
{
	ele=document.getElementById(id);
	len=bytes(ele.value);
	if((len < smin)||(len > smax))
	{
		return false;
	}
	else
	{
		return true;
	}
}
//获取字节数目针对中英文和数字
function bytes(str)
{
	if(typeof(str)!='string')
	{
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++)
	{
		if(str.charCodeAt(i) > 127)
		{
			len++;
		}
		len++;
	}
	return len;
}
//去除左右空格
function trimlr(id)
{
	var str=document.getElementById(id).value;
	for(i=0;str.charAt(i)==" "|| str.charAt(i)=="　";i++)
	{
	}
	str=str.substring(i,str.length);
	for(i=str.length-1;str.charAt(i)==" "|| str.charAt(i)=="　";i--)
	{
	}
	str=str.substring(0,i+1);
	return str;
}

function 	ajustImage(imageId, xLimit, yLimit) {
	var imageObj = (typeof imageId == 'string') ? document.getElementById(imageId) : imageId;;
	if (!imageObj) {
		return false;
	}
	var image	=	new	Image();
	image.src = imageObj.src;
	if ((xLimit > 0) && (yLimit > 0) &&
	(image.width > xLimit) && (image.height > yLimit)) {
		imageObj.width = (xLimit < image.width * (yLimit / image.height)) ?
		xLimit : (image.width * (yLimit / image.height));
		imageObj.height = (yLimit < image.height * (xLimit / image.width)) ?
		yLimit : (image.height * (xLimit / image.width));
	}
	else if ((xLimit > 0) && (image.width > xLimit)) {
		imageObj.width = xLimit;
		imageObj.height = image.height * (xLimit / image.width);
	}
	else if ((yLimit > 0) && (image.height > yLimit)) {
		imageObj.height = yLimit;
		imageObj.width = image.width * (yLimit / image.height);
	}
	else {
		if (xLimit !== 'undefined') {
			imageObj.width = image.width;
		}
		if (yLimit !== 'undefined') {
			imageObj.height = image.height;
		}
	}
}

