<!--
/***********************************************
*功能：AJAX方式验证信息前台处理角本
*作者：郑绪勇
*时间：2007-6-25 PM
*版权：上海递彩商务策划有限公司 拥有所有权
***********************************************/
var strCheck;
var http_request = false;
var sourceObj;
var PopTop=0;
var popup,execPop;
var strUrl="http://"+ document.domain +"/CheckInfo/CheckInfo.asp?Action=";
//***************************
//创建AJAX对象函数
//***************************
function CreateAjax(){
	//Mozilla 浏览器创建对象语句
	if(window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
	}
	//IE 浏览器创建对象语句
	else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		window.alert("不能创建XMLHttpRequest 对象实例.");
		return false;
	}
	//return http_request;
}
//***************************
//主AJAX验证函数
//***************************
function ShowAlert(srcObj,strAction,chgElement) {
	http_request = false;
	if(srcObj=="[object]"){
		strValue=srcObj.value;
	}else{
		strValue=srcObj.toString()
	}
	//如果未选择大分类，那么动态删除小分类所有列表项
	if(chgElement!=null && strValue==""){
		document.getElementById(chgElement.toString()).length=1;
	}
	//要处理元素的值为空，就返回不继续处理
	if (strValue==""){
		return;
	}
	CreateAjax();
	/*document.write(strUrl.toString())*/
	if(ShowAlert.arguments.length<3){
		sourceObj=srcObj;
		http_request.onreadystatechange = processTEXT;
	}else{
		sourceObj=chgElement;
		http_request.onreadystatechange = processXML;
	}
	http_request.open("GET",strUrl + strAction +"&strValue="+ strValue, false);
	http_request.send(null);
}
function ShowAjaxContent(){
	http_request = false;
	CreateAjax();
	if(ShowAjaxContent.arguments.length==0){
		setTimeout("ShowAjaxContent()",300000);
		http_request.open("GET",strUrl+"newMail", false);
		http_request.onreadystatechange = CreatePopup;
	}else{
		http_request.open("GET",strUrl+arguments[0], false);
		if(arguments[1]!=null){
			http_request.onreadystatechange =eval(arguments[1]);
		}
	}
	http_request.send(null);
}

//****************************
//处理AJAX提交数据操作
//****************************
function processAjaxSubmit(){
	if (http_request.readyState == 4&&http_request.status == 200) { // 判断对象状态
		eval(http_request.responseText);
	}
}

//***************************
//处理返回文本信息的函数
//***************************
function processTEXT() {
	if (http_request.readyState == 4&&http_request.status == 200) { // 判断对象状态
		strCheck=http_request.responseText;
		//var strAlert=http_request.responseText;
		//如果用户已存在，则弹出提示
		//eval(strAlert);
		/*if (strAlert!="YES"){
			alert("\用户注册出错，下面是产生错误的可能原因：\n\n·"+strAlert);
			sourceObj.focus();
		}*/
	}
}

//***************************
//处理返回XML信息的函数
//***************************
function processXML(){
	if (http_request.readyState == 4&&http_request.status == 200) { // 判断对象状态
		var xmlObj=http_request.responseXML;
		var xmlItem=xmlObj.getElementsByTagName("Item");
		var chgElement=document.getElementById(sourceObj.toString());
		chgElement.length=1;
		if(xmlItem.item(0).hasChildNodes){
			//var chgElement=document.getElementById(""+sourceObj+"");
			for(i=0;i<xmlItem.length;i++){
				chgElement.options.add(new Option(xmlItem[i].getElementsByTagName("ClassName")[0].firstChild.nodeValue,xmlItem[i].getElementsByTagName("ClassId")[0].firstChild.nodeValue));
			}
		}
	}
}

//******************************
//创建并定时显示Popup窗口函数
//******************************
function CreatePopup(){
//	if (http_request.readyState == 4&&http_request.status == 200) { // 判断对象状态
//		var strAlert=http_request.responseText;
//		if(strAlert!="0"){
//			popup=window.createPopup();
//			popup.document.body.innerHTML="<div style='position:absolute;width:180px;height:189px;background-image:url(/user/images/message.gif);border:1px solid #666600;font-size:12px;'><div style='padding:5px;line-height:150%;margin:62px 0px 0px 12px;'>厕所产品联盟提醒您<br/>"+ strAlert +"</div><div style=\"margin-top:25px;margin-left:12px;width:96px;height:22px;cursor:pointer;\" onClick=\"parent.window.open(\'/user/YesterdayVisitor.html\');\"></div></div>";
//			execPop=setInterval("showPop()",50);
//			setTimeout("hidePop()",9000);
//		}
//	}
}

function OpenVisitor(){
	parent.location.href='user\MailList.html';
}

//******************************
//显示Popup窗口函数
//******************************
function showPop(){
	PopTop+=5;
	popup.show(screen.width-200,screen.height,180,PopTop);
	if(PopTop>=190){
		//clearInterval(execPop);
		PopTop=186;
	}
}

//******************************
//隐藏Popup窗口函数
//******************************
function hidePop(){
	clearInterval(execPop);
	PopTop=0;
	popup.hide();
}

//******************************
//默认下拉列表选择项
//******************************
function DefaultItem(strId,strValue,strType){
	var strId=document.getElementById(strId.toString());
	for(i=0;i<strId.length;i++){
		if(arguments.length>2){
			if(strId[i].text==strValue){
				strId[i].selected=true;
				return;
			}
		}else{
			if(strId[i].value==strValue){
				strId[i].selected=true;
				return;
			}
		}
	}
}

//******************************
//文本域输入字数限制函数
//******************************
function textLimitCheck(thisArea, maxLength){
	if (thisArea.value.length > maxLength){
		alert(maxLength + ' 个字限制. \r超出的将自动去除.');
		thisArea.value = thisArea.value.substring(0, maxLength);
		thisArea.focus();
	}
	/*回写span的值，当前填写文字的数量*/
	messageCount.innerText = thisArea.value.length;
}

//******************************
//会员登录验证和处理函数
//******************************
function on_forgetpwd(){
	var obj=document.Login;
	if(obj.user.value==""){
		alert("用户登录出错，下面是产生错误的可能原因：\n\n·登录用户名不能为空！")
		obj.user.focus();
		return false;
	}
	if(obj.pass.value==""){
		alert("用户登录出错，下面是产生错误的可能原因：\n\n·登录密码不能为空！")
		obj.pass.focus();
		return false;
	}
	if(obj.regjm.value==""){
		alert("用户登录出错，下面是产生错误的可能原因：\n\n·验证码不能为空！")
		obj.regjm.focus();
		return false;
	}
	//获取来源页地址
	var strPrevious=parent.location.href.toLowerCase();
	if(strPrevious.indexOf("/user_login.html")==-1){
		if(obj.PreviousUrl.value==""){
			obj.PreviousUrl.value=strPrevious;
		}
	}else{
		obj.PreviousUrl.value="";
	}
	if(isIE()){
		var strChk=obj.Typ(0).checked;
	}else{
		var strChk=obj.Typ[0].checked;
	}
	if(strChk){
		obj.action="/individual/Chkadmin.html";
	}else{
		obj.action="/user/Chkadmin.html";
	}
	obj.submit();
	return false;
}

//**************************************
//根据下拉列表选择，动态改变当前页地址
//**************************************
function ChangePage(obj){
	var tmpVal=obj.options[obj.selectedIndex].value;
	if(arguments.length==2){
		location.href=arguments[1]+tmpVal;
	}else{
		location.href=tmpVal;
	}
}

//**************************************
//动态更改图像的大小，图像自动缩放
//**************************************
function ChangeImgSize(srcObj,intSize){
	var obj=document.getElementById(srcObj.toString()).childNodes;
	for(var i=0;i<obj.length;i++){
		if(obj.item(i).nodeName=="IMG"){
			if(parseInt(obj.item(i).width)>intSize){
				obj.item(i).width=intSize;
			}
		}
	}
}

//*************************************
//判断浏览类型，IE返回true否则返回false
//*************************************
function isIE(){
	if(navigator.appName=="Microsoft Internet Explorer"){
		return true;
	}else{
		return false;
	}
}

//*************************************
//获取元素相对于浏览器窗口的绝对位置
//*************************************
function getAbsXY(obj){
	//方式一
	var x,y,o;
	x=obj.offsetLeft;
	y=obj.offsetTop;
	o=obj;
	while(o=o.offsetParent){
		x+=o.offsetLeft;
		y+=o.offsetTop;
	}
	return {left:x,top:y};
	//方式二
	//return {left:obj.getBoundingClientRect().left,top:obj.getBoundingClientRect().top}
}

function ShowTest(obj){
	alert(obj.value);
}
//-->