String.prototype.trim = function () {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};


function isEmail(email){
	var emailPattern = /^[\w.-]+@[\w]+\.[\w]+$/g;
	if (!emailPattern.test(email)) {
		return false;
	} 
	return true;
}

function isNumAndLetter(str){
	var emailPattern = /^[\w]+$/g;
	if (!emailPattern.test(str)) {
		return 0;
	} 
	 
	return str.length;
}

function isWantLength(str,min,max){
	var str1=str.trim();
	if(str1.length<min||str1.length>max) 
		return false;
	return true;
}
//ajax

var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	  xmlHttp = new XMLHttpRequest();
}
function ajaxPost(url,data)
{
	 //alert(url);
	 xmlHttp.open("POST", url, false);
	 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
			}else{
			
			}
		};
	 // 发送请求
	 xmlHttp.send(data);
	 //xmlHttp.abort();
	 return re;
}

function ajaxPostAsyn(url,data,func)
{
	 //alert(url);
	 xmlHttp.open("POST", url, true);
	 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
				func(re); 
			}else{
			
			}
		};
	 // 发送请求
	 xmlHttp.send(data);
	 //xmlHttp.abort();
}

function ajaxAbstractAsyn(url,data,action,func)
{
	 //alert(url);
	 xmlHttp.open("POST", url, true);
	 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
				func(action,re); 
			}else{
			
			}
		};
	 // 发送请求
	 xmlHttp.send(data);
	 //xmlHttp.abort();
}

function ajaxSearch(url,data,action,func)
{
	 //alert(url);
	 xmlHttp.open("POST", url, true);
	 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
				func(action,re)
			}else{
			
			}
		};
	 // 发送请求
	 xmlHttp.send(data);
	 //xmlHttp.abort();
}



function ajaxGet(url)
{
	
	 var random=Math.random();
	 //alert(xmlHttp);
	 //alert(url);
	 if(url.indexOf("?")>0)
		 xmlHttp.open("GET", url+"&r="+random, false);
	 else
		 xmlHttp.open("GET", url+"?r="+random, false); 
	 //alert(url);
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
			}
		};
	 // 发送请求
	 xmlHttp.send(null); 
	 //xmlHttp.abort();
	 return re;
}

function ajaxGetAsyn(url,func)
{
	
	 var random=Math.random();
	 //alert(xmlHttp);
	 //alert(url);
	 if(url.indexOf("?")>0)
		 xmlHttp.open("GET", url+"&r="+random, true);
	 else
		 xmlHttp.open("GET", url+"?r="+random, true); 
	 //alert(url);
	 //设置服务器响应的处理方法
	 var re="ajax error";
	 xmlHttp.onreadystatechange =function (){
			if(xmlHttp.readyState==4)
			{
				re=xmlHttp.responseText;
				func(re);
			}
		};
	 // 发送请求
	 xmlHttp.send(null); 
	 //xmlHttp.abort();
	 
}


/*
 * SAMPLE CODE AT BOTTOM!!!
 * 
 * You need to put the name and values in quotes when you call the function,
 * like this: set_cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );.
 * Don't forget to put in empty quotes for the unused parameters or you'll get
 * an error when you run the code. This makes the cookie named 'mycookie', with
 * the value of 'visited 9 times', and with a life of 30 days, and the cookie is
 * set to your root folder.
 * 
 * The Set_Cookie values for 'domain' and 'secure' are not utilized. Use
 * 'domain' on the Javascript cookie if you are using it on a subdomain, like
 * widgets.yoursite.com, where the cookie is set on the widgets subdomain, but
 * you need it to be accessible over the whole yoursite.com domain.
 * 
 * It's good practice to not assume the path to the site root will be set the
 * way you want it by default, so do this manually as a rule, '/'. If no value
 * is set for expires, it will only last as long as the current session of the
 * visitor, and will be automatically deleted when they close their browser.
 */
function set_cookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime(today.getTime());
	/*
	 * if the expires variable is set, make the correct expires time, the
	 * current script below will set it for x number of days, to make it for
	 * hours, delete * 24, for minutes, delete * 60 * 24
	 */
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));
	document.cookie = name + "=" + value
			+ ((expires) ? ";expires=" + expires_date.toGMTString() : "")
			+ ((path) ? ";path=" + path : "")
			+ ((domain) ? ";domain=" + domain : "")
			+ ((secure) ? ";secure" : "");
}
/*
 * This will retrieve the cookie by name, if the cookie does not exist, it will
 * return false, so you can do things like if ( Get_Cookie( 'your_cookie' ) ) do
 * something.
 */
function get_cookie(name) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length))) {
		return null;
	}
	if (start == -1) {
		return null;
	}
	var end = document.cookie.indexOf(";", len);
	if (end == -1) {
		end = document.cookie.length;
	}
	return unescape(document.cookie.substring(len, end));
}
/*
 * Here all you need to do is put in: Delete_Cookie('cookie name', '/', '') and
 * the cookie will be deleted. Remember to match the cookie name, path, and
 * domain to what you have it in Set_Cookie exactly, or you may get some very
 * hard to diagnose errors.
 */

// this deletes the cookie when called
function delete_cookie(name, path, domain) {
	if (get_cookie(name)) {
		document.cookie = name + "=" + ((path) ? ";path=" + path : "")
				+ ((domain) ? ";domain=" + domain : "")
				+ ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}
/*
 * SAMPLE CODE
 * 
 * <script type="text/javascript"> // remember, these are the possible
 * parameters for Set_Cookie: // name, value, expires, path, domain, secure
 * Set_Cookie( 'test', 'it works', '', '/', '', '' ); if ( Get_Cookie( 'test' ) )
 * alert( Get_Cookie('test')); // and these are the parameters for
 * Delete_Cookie: // name, path, domain // make sure you use the same parameters
 * in Set and Delete Cookie. Delete_Cookie('test', '/', ''); ( Get_Cookie(
 * 'test' ) ) ? alert( Get_Cookie('test')) : alert( 'it is gone'); </script>
 */



var fi={};
fi.viewport = {getWinWidth:function () {
	this.width = 0;
	if (window.innerWidth) {
		this.width = window.innerWidth - 18;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			this.width = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				this.width = document.body.clientWidth;
			}
		}
	}
}, getWinHeight:function () {
	this.height = 0;
	if (window.innerHeight) {
		this.height = window.innerHeight - 18;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			this.height = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				this.height = document.body.clientHeight;
			}
		}
	}
}, getScrollX:function () {
	this.scrollX = 0;
	if (typeof window.pageXOffset == "number") {
		this.scrollX = window.pageXOffset;
	} else {
		if (document.documentElement && document.documentElement.scrollLeft) {
			this.scrollX = document.documentElement.scrollLeft;
		} else {
			if (document.body && document.body.scrollLeft) {
				this.scrollX = document.body.scrollLeft;
			} else {
				if (window.scrollX) {
					this.scrollX = window.scrollX;
				}
			}
		}
	}
}, getScrollY:function () {
	this.scrollY = 0;
	if (typeof window.pageYOffset == "number") {
		this.scrollY = window.pageYOffset;
	} else {
		if (document.documentElement && document.documentElement.scrollTop) {
			this.scrollY = document.documentElement.scrollTop;
		} else {
			if (document.body && document.body.scrollTop) {
				this.scrollY = document.body.scrollTop;
			} else {
				if (window.scrollY) {
					this.scrollY = window.scrollY;
				}
			}
		}
	}
}, getAll:function () {
	this.getWinWidth();
	this.getWinHeight();
	this.getScrollX();
	this.getScrollY();
}}
//弹出层
/**
* _maskDIV 遮盖层 id
* indexX   层次级别
* _contentDIV 弹出外层ID
* _content 外层显示内容
*indexY 外层的层次级别
*_width 外层DIV的宽度
*_height 外层DIV的高度
**/
function shutDown(_contentDIV,_maskDIV)
{
	document.getElementById(_contentDIV).style.display="none";
	document.getElementById(_maskDIV).style.display="none";
}
function openDIV(_maskDIV, indexX, _contentDIV, indexY, _width, _heigth, _content) {
	var maskDiv = document.getElementById(_maskDIV);
	var contentDiv = document.getElementById(_contentDIV);
	if (maskDiv) {
		document.body.removeChild(maskDiv);
	}
	if (contentDiv) {
		document.body.removeChild(contentDiv);
	}
	//遮盖层
	var newMask = document.createElement("div");
	newMask.id = _maskDIV;
	newMask.style.position = "absolute";
	newMask.style.zIndex = indexX;
	var _scrollWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
	var _scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
	newMask.style.width = _scrollWidth + "px";
	newMask.style.height = _scrollHeight + "px";
	newMask.style.top = "0px";
	newMask.style.left = "0px";
	newMask.style.background = "#EEE";
	newMask.style.filter = "alpha(opacity=40)";
	newMask.style.opacity = "0.40";

	document.body.appendChild(newMask);
	//内容层	 	
	var newDiv = document.createElement("div");
	newDiv.id = _contentDIV + "";
	newDiv.style.position = "absolute";
	newDiv.style.zIndex = indexY;
	var newDivWidth = _width;
	var newDivHeight = _heigth;
	newDiv.style.overflow = "hidden";
	newDiv.style.width = newDivWidth + "px";
	newDiv.style.height = newDivHeight + "px";
	fi.viewport.getScrollY();
	newDiv.style.top = fi.viewport.scrollY + 125 + "px";
	newDiv.style.left = (document.body.scrollLeft + document.body.clientWidth / 2 - newDivWidth / 2) + "px";
	newDiv.style.background = "white";
	newDiv.style.border = "5px solid #999";
	newDiv.style.padding = "0px";
    //关闭按钮的实现
	var shutDiv = document.createElement("div");
	shutDiv.style.width = "100%";
	shutDiv.style.textAlign = "right";
	shutDiv.innerHTML = "&nbsp;<a href=\"javascript:shutDown('"+_contentDIV+"','"+_maskDIV+"');\"><img src='/images/close.png' width='20px' height='20px' border='0px'/></a>";
	newDiv.appendChild(shutDiv);
	newDiv.innerHTML += _content + "";//内容
	document.body.appendChild(newDiv);
	//	弹出层居中
	function newDivCenter() {
		fi.viewport.getScrollY();
		newDiv.style.top = fi.viewport.scrollY + 25 + "px";
		newDiv.style.top = fi.viewport.scrollY + 125 + "px";
		newDiv.style.left = (document.body.scrollLeft + document.body.clientWidth / 2 - newDivWidth / 2) + "px";
		window.onscroll = newDivCenter;
	}
    //当前页面不为空
	if (document.all) {
		window.attachEvent("onscroll", newDivCenter);
	} else {
		window.addEventListener("scroll", newDivCenter, false);
	}
}

function display_user_agree()
{
	  var html="<div style=\"font-size:14px;text-align:center;font-weight:bold;\">源信创想-用户协议</div>"+
	  "<div style=\"font-size:12px;text-align:left;margin-left:10px;margin-right:10px;\"><br/>请仔细阅读以下文字<br/>"+
    "欢迎来到北京源信创想信息技术有限公司（以下简称源信、源信创想、我公司）网站，为了更好地为您提供服务，我们请求您遵守以下使用条例。当您注册并访问该网站时，表明您已经知晓并同意这些条例。请注意该条例可能会被不断更新，所以请在适当的时候重新阅读这些条例文字。本条例可能还会出现在其他印刷文档中，那么例如“网站”这样的文字将被解释为“文档”，条文依然适用。"+
    "<br/><br/>资料使用的限制<br/>"+
    "只要您保留版权和其他财产权声明信息，在www.fountainfo.com上的信息资料可以被单个地下载用于个人和商务用途。对于源信网原创的信息资料，请注明来源于源信网，如果您转载或者印刷出版，请取得我公司（北京源信创想信息技术有限公司）的书面同意。对于源信搜索提供的信息，请遵守原有信息来源的版权申明，源信概不承担此类信息的法律责任。"+
    "<br/><br/>知识产权声明<br/>"+
    "本网站和软件可能包含第三方的商标权，版权或其他知识产权的物件，所有这些权利都归属于相应的权利所有人。除非获得相关的权利人书面许可，否则法律禁止用户修改，复制，发行，转发，展示，出版，销售，授权与他人，创造雷同作品或在任何商业及公开的场合使用本网站内容。"+
    "<br/><br/>服务的暂停和中止<br/>"+
    "源信公司有权因各种系统维修的需要而暂时停止信息软件服务，但服务暂停时间不应该超过整个订阅期限的5%。源信在服务合同期内，客户未违约的情况下未取得客户事先书面许可的情况下不得随意中止服务的提供。"+
    "<br/><br/>使用账号<br/>"+
    "除非有其他的说明，本订单提供给客户的使用账号只限于客户企业和在其工作地点的员工使用。部分源信产品允许客户的下属企业和办事处直接使用，但应当参考该产品的声明资料。"+
    "<br/><br/>法律监管<br/>"+
    "无论用户所在地在哪里，本条例受中华人民共和国法律的监管，用户同意将与本条例相关的争议提交中国境内的仲裁机构仲裁或向合同签署地人民法院提起诉讼。"+
    "</div>"; 
    
	  openDIV("main_mask", 150, "user_agreement", 151, 600, 500, html); 
}

