/*
 * 检测一个字符串是否为空
*/
function empty (string){
	return $.trim(string)==''?true:false;
}
/*
 * 检测表单中input的空值，并标记为红色 有空 true 无 false
 * @parem class
 * @retrun boolean
*/
function check_is_empty (inpclass){
	var flg = false;
	$("." + inpclass).each(function(){
		if(empty($(this).val())){
			$(this).addClass("empty_input_val");
			flg = true;
		}
	});
	return flg;
}
/** 
 * 检查 是否 含有 特殊字符 
 *含有 返回 true 没有返回 false 
 **/
 function chkstr(str){
	for (var i = 0; i < str.length; i++){
	   if (str.charCodeAt(i) < 127 && !str.substr(i,1).match(/^\w+$/ig)){
		   return true;
	   }
	}
	return false;
}
/**
 * 检查 是否 符合 email 邮箱的规范  符合 true 不符合 false
 * @param email string
 * @return boolean
 */
function checkemail(email){
	var   pattern   =   /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
    if(!pattern.test(email)){ 
    	return false;
    }
    return true;
}
/**
 * 是否 是 一个 正确的手机号  是 true 不是 false
 * 支持 13 150 151
 * @param int mobile
 * @return boolean
 */
function is_mobile(mobile){
	var reg =/^1(3[0-9]|5[0,1,2,3,6,8,9]|8[6,8,9])[0-9]{8}$/;
    if(!reg.test(mobile)){
        return false;
    }else{
        return true;
    }
}
/*
* 消息弹窗
*/
function showNotice(msg,width){
	if(typeof(width)=="undefined"){width = '240';}
	$('div').remove('#showAjaxMsg');//先删了再来
	$("body").append('<div id="showAjaxMsg"><div style="height:40px;line-height:40px;padding:auto;">'+msg+'</div></div>');
	var top = $(window).height()/2+$(document).scrollTop()-80+'px';
    $("#showAjaxMsg").css({
								'border':'2px solid #E1562d',
								'color':'#FFF',
								'z-index':'99999999',
								'text-align':'center',
								'position':'absolute',
								'background-color':'#E1562d',
								'font-size':'14px',
								'top':top												
	})
	$("#showAjaxMsg")
		.animate({opacity: "1",height: "40", width: width}, 10)
		.animate({opacity: "1", left: "40%",height: "40", width: width},800)
		.animate({opacity: "1", left: "40%",height: "40", width: width},1000)
		.animate({opacity: "1", left: "40%",height: "40", width: width},1500)
		.animate({opacity: "0", left: "85%",height:"0",width:'0'}, 400)
		return false;
}
/** 设置为 首页 **/
function sethome(obj,url){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.sethomepage(url);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch(e){
				alert("感谢您光临本站\n\n\t您正在使用的浏览器无法正确添加到代到设为主页上\n\n\t请您手动进行设置！给您带来不便还请见谅...");
				return false;
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',url);
		}
	}
	return false;
}