try{
	if(self!=top) top.location=self.location;
}catch(e)
{}

String.prototype.trim = function()
{
	return this.replace(/(^[\s]*)|([\s]*$)/g, '');
}
String.prototype.trim2 = function()
{
  var vStr = this.trim();
  vStr = vStr.replace(/(^[\s]*)|([\s]*$)/g,   '');   
  vStr = vStr.replace(/(^[　]*)|([　]*$)/g,'');
  return  vStr;
}
String.prototype.strLength = function()
{
    var vStr = this.trim().split("");
    var vLength = 0;
    
    for (i = 0 ; i < vStr.length ; i++)
    {
		vTemp = escape(vStr[i]);
		vLength += (vTemp.indexOf("%u", 0) == -1) ? 1 : 2;
    }
    
    return vLength;
}

String.prototype.isUserName = function()
{
	var vStr = this.trim();
	var vReg = /^[a-zA-Z][\w]{5,20}$/;
	//return vReg.test(vStr);
	if(vReg.test(vStr))
    {
        return true;
    }
    else
    {
        var vRegAlipay = /[@alipay]$/;
        return vRegAlipay.test(vStr);
    }
}

String.prototype.isNickName = function()
{
	var vStr = this.trim();
	var vReg = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[\w])+$/;
	
	if (vStr.strLength() < 6 || vStr.strLength() > 20)
	{
		return false;
	} else {
		return vReg.test(vStr);
	}
}

String.prototype.isEmail = function()
{
	var vStr = this.trim();
	var vReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	
	if (vStr.strLength() < 3 || vStr.strLength() > 50)
	{
		return false;
	} else {
		return vReg.test(vStr);
	}
}

String.prototype.isPassword = function()
{
	var vStr = this.trim();
	var vReg = /^[\w]{6,20}$/;
	return vReg.test(vStr);
}

String.prototype.isRealName = function()
{
	var vStr = this.trim();
	var vReg = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[\w])+$/;
	
	if (vStr.strLength() < 1 || vStr.strLength() > 20)
	{
		return false;
	} else {
		return vReg.test(vStr);
	}
}

String.prototype.isAnswer = function()
{
	var vStr = this.trim();
	var vReg = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[\w])+$/;
	
	if (vStr.strLength() < 1 || vStr.strLength() > 30)
	{
		return false;
	} else {
		return vReg.test(vStr);
	}
}

String.prototype.isZipCode = function()
{
	var vStr = this.trim();
	var vReg = /^([0-9]{6})$/;
	return vReg.test(vStr);
}

String.prototype.isTel = function()
{
	var vStr = this.trim();
	var vReg = /^[\d\-]{6,20}$/;
	return vReg.test(vStr);
}

String.prototype.isMobile = function()
{
	var vStr = this.trim();
	//var vReg = /^(13[4-9]|15(0|1|2|7|8|9))\d{8}$/;
	var vReg = /^1[3,5,8]\d{9}$/;
	return vReg.test(vStr);
}

String.prototype.isProof = function()
{
	var vStr = this.trim();
	var vReg = /^[\d]{8}\-0[\d]+\-[0-9a-fA-F]{6}$/;
	return vReg.test(vStr);
}

String.prototype.isCnum = function()
{
	var vStr = this.trim();
	var vReg = /^[0-9]{6,10}$/;
	return vReg.test(vStr);
}

String.prototype.isPost = function()
{
	var vStr = this.trim();
	var vReg = /^[0-9]{6}$/;
	return vReg.test(vStr);
}

String.prototype.isIDCard = function()
{
	var vCid = this.trim();
	var vSum = 0;
	var vReg = /^([\d]{17}[xX\d]|[\d]{15})$/;
	var vCity = '|11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|50|51|52|53|54|61|62|63|64|65|71|81|82|91|';
	
	if (!vReg.test(vCid)) return false;
	
	if(vCity.indexOf(parseInt(vCid.substr(0,2))) == '-1') return false;
	
	vCid = vCid.replace(/[xX]$/i, 'a');
	
	if (vCid.length == 18)
	{
		vBirthday = vCid.substr(6, 4) + '/' + Number(vCid.substr(10, 2)) + '/' + Number(vCid.substr(12, 2));
	} else {
		vBirthday = '19' + vCid.substr(6, 2) + '/' + Number(vCid.substr(8, 2)) + '/' + Number(vCid.substr(10, 2));
	}
	
	var vDate = new Date(vBirthday);
	
	if (vBirthday != (vDate.getFullYear() + '/' + (vDate.getMonth() + 1) + '/' + vDate.getDate())) return false;
	
	if (vCid.length == 18)
	{
		for(var i = 17 ; i >= 0 ; i--) vSum += (Math.pow(2, i) % 11) * parseInt(vCid.charAt(17 - i), 11);
  		if(vSum % 11 != 1) return false;
  	}
  	
  	return true;
}

String.prototype.isInt = function()
{
	var vStr = this.trim();
	var vReg = /^([1-9]+)([0-9]*)$/;
	return vReg.test(vStr);
}

String.prototype.isMoney = function()
{
	var vStr = this.trim();
	var vReg = /^\d+(\.\d{1,2})?$/;
	return vReg.test(vStr);
}

String.prototype.isEnglish = function()
{
	var vStr = this.trim();
	var vReg = /^[A-Za-z]+$/;
	return vReg.test(vStr);
}

String.prototype.isChinese = function()
{
	var vStr = this.trim();
	var vReg = /^[\u0391-\uFFE5]+$/;
	return vReg.test(vStr);
}

String.prototype.isCardNo = function()
{
	var vStr = this.trim();
	var vReg = /^[0-9A-Z]{2}[\d]{14}$/;
	return vReg.test(vStr);
}

String.prototype.isCardPwd = function()
{
	var vStr = this.trim();
	var vReg = /^[\d]{8,12}$/;
	return vReg.test(vStr);
}

String.prototype.isSzxCardNo = function()
{
	var vStr = this.trim();
	var vReg = /^[\d]{17}$/;
	return vReg.test(vStr);
}

String.prototype.isSzxCardPwd = function()
{
	var vStr = this.trim();
	var vReg = /^[\d]{18}$/;
	return vReg.test(vStr);
}

function $(vId)
{
	if (typeof(vId) == 'object') return vId;
	return document.all ? document.all[vId] : document.getElementById(vId);
}

function keepSameHeight()
{
	var vAct = action.split('.');
	
	try
	{
		$('rightContent').style.height = ($('sideBar').clientHeight - $('navBar').clientHeight - 60) + 'px';
	} catch (e) {}
}

function showBox(vHTML)
{
	$('MsgBoxBackground').style.height = document.body.scrollHeight + 'px';
	$('MsgBoxBackground').style.width = document.body.scrollWidth + 'px';
	$('MsgBoxContent').innerHTML = vHTML;
	$('MsgBoxContent').style.top = (document.documentElement.scrollTop + 
		(document.documentElement.clientHeight - $('MsgBoxContent').clientHeight) / 2) + 'px'; 
	$('MsgBoxContent').style.left = (document.documentElement.scrollLeft + 
		(document.documentElement.clientWidth - $('MsgBoxContent').clientWidth) / 2) + 'px'; 
	
	var allSelects = document.getElementsByTagName('SELECT');
	
	for (i = 0 ; i < allSelects.length ; i++)
	{
		allSelects[i].style.visibility = 'hidden';
	}
	
	$('MsgBoxBackground').style.visibility = 'visible';
	$('MsgBoxContent').style.visibility = 'visible';
}

function hideBox()
{
	$('MsgBoxContent').innerHTML = '';
	$('MsgBoxContent').style.top = '0px';
	$('MsgBoxContent').style.left = '0px'; 
	
	var allSelects = document.getElementsByTagName('SELECT');
	
	for (i = 0 ; i < allSelects.length ; i++)
	{
		allSelects[i].style.visibility = 'visible';
	}
	
	$('MsgBoxBackground').style.visibility = 'hidden';
	$('MsgBoxContent').style.visibility = 'hidden';
}

function changeVerify()
{
	try
	{
		$("verifyImg").src = './?act=index.verify&r=' + Math.random();
	} catch (e) {}
}

function checkLogin(vForm)
{
	if (!vForm.elements['username'].value.isUserName() && !vForm.elements['username'].value.isEmail())
	{
		alert('请输入正确的用户名！');
		vForm.elements['username'].focus();
		return false;
	}
	
	if (vForm.elements['verify']===undefined)
	{
	}
	else if(vForm.elements['verify'].value.length != 4 || !vForm.elements['verify'].value.isInt())
	{
	    alert('请输入正确的验证码！');
		vForm.elements['verify'].focus();
		return false;
	}
	
	return true;
}

function add2Favorite()
{	
	try{
		
		if (window.sidebar) { 
			window.sidebar.addPanel(document.title, location.href,""); 
		} else if( document.all ) {
			window.external.AddFavorite( location.href,document.title);
		}
		
	}catch(e){}

}