String.prototype.trim = function() { 
	var str = this, 
	str = str.replace(/^\s\s*/, ''), 
	ws = /\s/, 
	i = str.length; 
	while (ws.test(str.charAt(--i))); 
	return str.slice(0, i + 1); 
}

function verifyUserName(userName){
	var myreg = /^[a-zA-Z0-9]*$/g;
	if(!myreg.test(userName.value.trim())) {
		alert('用户名必须是数字和字母！');
		userName.focus();
		userName.select();
		return false;
	}
	return true;
} 

function verifyMobile(mobile){
	var myreg = /^(((13[0-9]{1})|159|(15[0-9]{1}))+\d{8})$/;
	if(!myreg.test(mobile.value.trim())) {
		alert('请输入合法的手机号码！');
		mobile.focus();
		mobile.select();
		return false;
	}
	return true;
}

function isPostalCode(postCode){
	var pattern =/^[0-9]{6}$/;
	if(!pattern.exec(postCode.value.trim())){
		alert('请输入正确的邮政编码');
		postCode.focus();
		postCode.select();
		return false;
	}
	return true;
}


function isEmail(email){
	var pattern =/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
	if(!pattern.exec(email.value.trim())){
		alert('请输入正确的邮箱地址');
		email.focus();
		email.select();
		return false;
	}
	return true;
}

function ShowIframe(id) //显示iframe
{
	//alert(id);
	var str = document.getElementById(id).innerHTML;
	str = str.replace(/\pushBook.action/g,"pushBook.action?bookId="+id);
	var strHtml = '<div align="center" class="Content" id="'+id+'"  bgcolor="#e6e6e6">'+
		str
		'</div>';
    var pop=new Popup({
    	contentType:2,
    	isReloadOnClose:false,
    	width:340,
    	height:230
    });
    pop.setContent("contentHtml",strHtml);
    pop.setContent("title","图书介绍");
    pop.build();
    pop.show();
}


