String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.Mid = function(start,len){return this.substr(start,len);}

function check()
{
	md=document.hash.md.value;
	md=md.trim();
	
	if (md== "")
	{
		window.alert("请输入MD5值！");
		document.hash.md.focus();
		return false;
	}

	if (md.length!=32 && md.length!=16 && md.length!=40 && md.Mid(md.length-1,1)!='=' )
	{
		window.alert("请输入32位或16位或40位的MD5值！");
		document.hash.md.focus();
		return false;
	}
}

function md5show(str)
{
	var md = hex_md5(str);
	var md16 = md.substr(8, 16);
	var html = 'md5('+str+', 32) = ' + md +'<br>md5('+str+', 16) = ' + md16;

	var url = "/SNS/common/_gen.php";
	$.post(
		url,
		{str:str}, 
		function(data)
		{
			html += '....';
		}
	);

	md=document.hash.md.value;
	md=md.trim();

	document.getElementById("md5show").innerHTML = html;
}


function md5showNotice(str)
{
	var md = hex_md5(str);
	var md16 = md.substr(8, 16);
	var html = 'md5('+str+', 32) = ' + md +'<br>md5('+str+', 16) = ' + md16;

	var url = "/SNS/common/_gen.php";
	$.post(
		url,
		{str:str}, 
		function(data)
		{
			document.getElementById("md5show").innerHTML = '<span class=count>' + str + '</span> 输入成功';
		}
	);
}

function changetitle()
{
	var title=hex_md5(str);
	var md16=md.substr(8,16);
	var html='md5('+str+', 32) = '+md+'<br>md5('+str+', 16) = '+md16;
}

var Md5InputFocus=false;

function md5focus()
{
	if(!Md5InputFocus)
	{
		document.hash.md.select();
		Md5InputFocus=true;
	}
}

function md5unfocus()
{
	Md5InputFocus=false;
}