var xmlHttp = null;
try{
	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(err1){
	try{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(err2){
		xmlHttp = new XMLHttpRequest();
	}
}

String.prototype.trim1 = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function check_get(url,strOnHandler){
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = eval(strOnHandler);
	xmlHttp.send(null);
}

function getRequestBody(sFormItemIds){
	var aFormItemId = sFormItemIds.split(",");
	var aParams=new Array();
	for(var i=0;i<aFormItemId.length;i++){
		var oFormItem=document.getElementsByName(aFormItemId[i]);
		for(var j=0;j<oFormItem.length;j++){
			var sParam=escape(aFormItemId[i]);
			sParam+="=";
			if(oFormItem[j].type.toLowerCase() == "radio" || oFormItem[j].type.toLowerCase() =="checkbox"){
				if(oFormItem[j].checked){
					sParam+=escape(oFormItem[j].value.trim1());
					aParams.push(sParam);
					if(oFormItem[j].type.toLowerCase() == "radio"){break;}
				}
			}
			else{
				sParam+=escape(oFormItem[j].value.trim1());
				aParams.push(sParam);
			}
		}
	}
	return aParams.join("&");
}
function check_post(url,strOnHandler,sFormItemIds){
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = eval(strOnHandler);
	var sBody=getRequestBody(sFormItemIds);
	xmlHttp.send(sBody);
}

function check_login(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid.substr(0,5) == "产生错误："){
				document.getElementById("loading").innerHTML=isValid;
				setTimeout("hidden_login_dialogBox();document.getElementById('accounts').focus();document.getElementById('accounts').select();",2000);
			}
			else if(isValid == "未激活摄影空间"){
				document.getElementById("loading").innerHTML=isValid;
				setTimeout("hidden_login_dialogBox();window.top.location.href='/activation.aspx';",2000);
			}
			else{
				document.getElementById("loading").innerHTML="您登录成功！";
				setTimeout("hidden_login_dialogBox();try{document.getElementById('LoginTd').innerHTML='"+isValid+"';}catch(e){}",1000);

				try{document.getElementById('iframe_login').contentWindow.replace_page();}catch(e){}
			}
		} 
		else{
			//alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
			document.getElementById("loading").innerHTML="抱歉，装载数据失败。";
			setTimeout("hidden_login_dialogBox();",2000);
		} 
	}
}

function check_login1(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid.substr(0,5) == "产生错误："){
				document.getElementById("error").innerHTML=isValid.replace("<br />","");
				document.getElementById('accounts').focus();
				document.getElementById('accounts').select();
			}
			else if(isValid == "未激活摄影空间"){
				document.getElementById("error").innerHTML=isValid;
				setTimeout("hidden_login_dialogBox();window.top.location.href='/activation.aspx';",2000);
			}
			else if(isValid == "刷新窗口"){
				document.getElementById("error").innerHTML="您登录成功！";
				try{document.getElementById('iframe_login').contentWindow.replace_page();}catch(e){}
				try{setTimeout("hidden_login_dialogBox();window.location.reload();",2000);}catch(e){};
				return;
			}
			else{
				document.getElementById("error").innerHTML="您登录成功！";
				setTimeout("hidden_login_dialogBox();try{document.getElementById('LoginTd').innerHTML='"+isValid+"';}catch(e){}",1000);

				try{document.getElementById('iframe_login').contentWindow.replace_page();}catch(e){}
			}

			try{document.getElementById('commentframe').contentWindow.freash_page();}catch(e){}
		} 
		else{
			//alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
			document.getElementById("error").innerHTML="抱歉，装载数据失败。";
			setTimeout("hidden_login_dialogBox();",2000);
		} 
	}
}

function check_quit(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			try{document.getElementById('iframe_logout').contentWindow.replace_page();}catch(e){}

			var isValid = xmlHttp.responseText;
			if(isValid == "刷新窗口"){
				try{setTimeout("window.location.reload();",1000);}catch(e){};
				return;
			}

			try{document.getElementById("LoginTd").innerHTML=isValid;}catch(e){}

			try{
				document.getElementById('accounts').focus();
				document.getElementById('accounts').select();
			}
			catch(e){}

			try{document.getElementById('commentframe').contentWindow.freash_page();}catch(e){}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_show(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你还未登录，登录后才能申请影展！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "无权申请"){
				ret = confirm("管理员不能申请影展！\n\n你要进入管理吗？");
				if(ret == true){
					window.top.location.href="/manage/WorkFrame/";
				}
			}
			else{
				window.top.location.href="/manage/WorkFrame/?o=sq";
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_favor(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你还未登录，登录后才能收藏图片！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "无权收藏"){
				ret = confirm("管理员不能收藏图片！\n\n你要进入管理吗？");
				if(ret == true){
					window.top.location.href="/manage/WorkFrame/";
				}
			}
			else if(isValid == "图片不存在"){
				alert("收藏未成功！\n\n原因是此图片不存在！");
			}
			else if(isValid == "已收藏图片"){
				alert("你已经收藏过此图片！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else{
				alert("成功收藏此图片！");
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_good(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你还未登录，登录后才能发好友邀请！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "无权发送"){
				ret = confirm("管理员不能发好友邀请！\n\n你要进入管理吗？");
				if(ret == true){
					window.top.location.href="/manage/WorkFrame/";
				}
			}
			else if(isValid == "不能加自己"){
				alert("不能向自己发好友邀请！");
			}
			else if(isValid == "会员不存在"){
				alert("你要发邀请的会员不存在！");
			}
			else if(isValid == "会员被冻结"){
				alert("你要发邀请的会员已经被冻结！");
			}
			else if(isValid == "会员未激活"){
				alert("你要发邀请的会员尚未激活！");
			}
			else if(isValid == "已经是好友"){
				alert("你要发邀请的会员已经是你的好友！");
			}
			else if(isValid == "已经发过好友邀请"){
				alert("你已经向此会员发过好友邀请。\n\n此会员正在处理中，请勿重复发送！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else{
				alert("成功发送好友邀请！");
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_private(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你还未登录，登录后才能发私密信息！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "无权发送"){
				ret = confirm("管理员不能发私密信息！\n\n你要进入管理吗？");
				if(ret == true){
					window.top.location.href="/manage/WorkFrame/";
				}
			}
			else if(isValid == "会员不存在"){
				alert("你要发私密信息的会员不存在！");
			}
			else if(isValid == "不能给自己发"){
				alert("不能向自己发私密信息！");
			}
			else{
				window.showModalDialog("/general/private.aspx?accounts=" + isValid,"","dialogWidth=500px;dialogHeight=313px;status:no;scroll:no;help:no;"); 
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_comment(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你选择的不是匿名发表评论，登录后才能发表评论！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "无权评论"){
				ret = confirm("管理员不能发表评论！\n\n你要进入管理吗？");
				if(ret == true){
					window.top.location.href="/manage/WorkFrame/";
				}
			}
			else if(isValid == "会员不存在"){
				alert("你要发邀请的会员不存在！");
			}
			else if(isValid == "会员被冻结"){
				alert("你要发邀请的会员已经被冻结！");
			}
			else if(isValid == "会员未激活"){
				alert("你要发邀请的会员尚未激活！");
			}
			else if(isValid == "主题不存在"){
				alert("你要发表评论的主题不存在！");
			}
			else if(isValid == "评论内容为空"){
				alert("你要发表评论的内容不能为空！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else if(isValid == "操作出错"){
				alert("你操作出错了！");
			}
			else{
				alert("成功发表评论！");
				document.getElementById("comment").value = "";
				var objCommentTable = document.getElementById("CommentTable");
				objCommentTable.style.display = "";
				var objCommentFrame = document.getElementById("commentframe");
				objCommentFrame.contentWindow.freash_page();
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_comment_delete(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "未登录"){
				ret = confirm("你还未登录，登录后才能删除评论！\n\n你要登录吗？");
				if(ret == true){
					show_login_dialogBox();
				}
			}
			else if(isValid == "会员不存在"){
				alert("你要发邀请的会员不存在！");
			}
			else if(isValid == "会员被冻结"){
				alert("你要发邀请的会员已经被冻结！");
			}
			else if(isValid == "会员未激活"){
				alert("你要发邀请的会员尚未激活！");
			}
			else if(isValid == "无权删除"){
				alert("你无权删除此评论！");
			}
			else if(isValid == "评论不存在"){
				alert("你要删除的评论不存在！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else if(isValid == "操作出错"){
				alert("你操作出错了！");
			}
			else{
				alert("成功删除评论！");
				var objCommentFrame = document.getElementById("commentframe");
				objCommentFrame.contentWindow.freash_page();
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function hidden_login_dialogBox(){
	try{document.getElementById("error").innerHTML = "&nbsp;";}catch(e){};

	try{document.getElementById("accounts").value = "";}catch(e){};

	try{document.getElementById("password").value = "";}catch(e){};

	document.getElementById("dialogBoxDisabled").style.display="none";
	document.getElementById("loading").style.display="none";
}

function show_login_dialogBox(){
	document.getElementById("dialogBoxDisabled").style.display="";
	document.getElementById("loading").style.display="";

	try{
		document.getElementById('dialogBoxDisabled').style.height = window.document.body.scrollHeight;
		document.getElementById('loading').style.top = document.body.scrollTop + (document.body.clientHeight - 315)/2;
	}
	catch(e){};

	try{document.getElementById("error").innerHTML = "&nbsp;";}catch(e){};

	try{
		document.getElementById("accounts").value = "";
		document.getElementById('accounts').focus();
		document.getElementById('accounts').select();
	}
	catch(e){};

	try{document.getElementById("password").value = "";}catch(e){};
}