﻿/*EBDIY
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) ; .NET CLR 2.0.50727)
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1
Opera/9.64 (Windows NT 5.1; U; Edition IBIS; zh-cn) Presto/2.1.1
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.0 (KHTML, like Gecko) Chrome/3.0.182.3 Safari/531.0
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17
*/ 
/*正则表达式*/
var REG_USERNAME = /^[0-9A-Za-z_]{5,14}$/; //用户名
var REG_QQ = /^\d{5,11}$/; //QQ
var REG_EMAIL = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; // Email
var REG_TELPHONE = /^0\d{2,3}-\d{1,}$/; //电话
var REG_MOBILE = /^1\d{10}$/; // 手机
var REG_POSTCODE = /^\d{6}$/; //邮政编码
var REG_CHECKCODE = /^\d{4}$/; //验证码
var REG_ISCHINA = /^[\u4e00-\u9fa5]+$/; //是否包含汉字
var e_event, Alpha = 0;
var AjaxUp=null;
/*重定义一些函数*/
String.prototype.utf8=function(){  
	return encodeURIComponent(this.toString());
}

String.prototype.GB=function(){
	return decodeURIComponent(this.toString()).replace(/\+/g," ");
}

String.prototype.reg=function(r){
    return r.test(this.toString());
};

String.prototype.toNum=function(){
    return parseInt(this.toString());
};

String.prototype.trim=function(){
    return this.toString().replace(/^(\s+)|(\s+)$/,"");
};

String.prototype.json=function(){
	try{
		eval("var jsonStr = (" + this.toString() + ")");
	}catch(ex){
		var jsonStr = null;
	}
	return jsonStr;
};
var cookie={
    SET	: function(name, value, days) {var expires = "";if (days) {var d = new Date();d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);expires = "; expires=" + d.toGMTString();}document.cookie = name + "=" + value + expires + "; path=/";},
	GET	: function (name) {var re = new RegExp("(\;|^)[^;]*(" + name + ")\=([^;]*)(;|$)");var res = re.exec(document.cookie);return res != null ? res[3] : null;}
};

function $(){ 
    var elements = new Array(); 
    for (var i = 0; i < arguments.length; i++) 
    { 
        var element = arguments[i]; 
        if (typeof element == 'string') 
            element = document.getElementById(element); 
        if (element) {
        } else {
            element = null;
        }
        if (arguments.length == 1) {
            return element; 
        } else {
            elements.push(element); 
        }
    } 
    return elements; 
}

function E(){
	var func = E.caller;
	var args = func.arguments;
	return args[0]  ?args[0] : window.event;	
}

//===================================
// 判断浏览器类型
//===================================
function Browser(){
	var appName = window.navigator.appName.toLowerCase();
	var agent=window.navigator.userAgent;
	var reValue = "";
	switch(appName){
		case "microsoft internet explorer":
			reValue = "ie";
			break;
		case "netscape":
			reValue = "ff";
			break;
		case "opera":
			reValue = "opera";
			break;
		default:
			reValue = appName;
			break;
	}
	return reValue;
}

function ABS(a){
	a = $(a);
	var b = { x: a.offsetLeft, y: a.offsetTop};
	a = a.offsetParent;
	while (a) {
		b.x += a.offsetLeft;
		b.y += a.offsetTop;
		a = a.offsetParent;
	}
	return b;
} 

function fSetOpacity(XEle, iAlpha, per){
	if (Alpha >= 0){
    	XEle.style.opacity = iAlpha/100;
    	XEle.style.filter = 'alpha(opacity=' + iAlpha + ')';
		Alpha = (iAlpha - per);
	}else{
		XEle.parentNode.removeChild(XEle);
		clearInterval(e_event);
	}
}

function BackLight(id, sec, per){
	if ($(id)){
		e_event = setInterval
		(
		 	function(){
				fSetOpacity($(id), Alpha, per);
		 	},sec
		);
	}
}

//==============================================
// source: 源对象 target: 目标对象 
// offSetX, offSetY 偏移量
//==============================================
function Drag(source, target, offSetX, offSetY){
	source = typeof(source) == "object" ? source : document.getElementById(source);
	target = typeof(target) == "object" ? target : document.getElementById(target);
	var x0 = 0, y0 = 0, x1 = 0, y1 = 0, moveable = false, NS = (navigator.appName == 'Netscape');
	offSetX = typeof offSetX == "undefined" ? 0 : offSetX;
	offSetY = typeof offSetY == "undefined" ? 0 : offSetY;
	source.onmousedown = function(e){
		e = e ? e : (window.event ? window.event : null);
		if(e.button == (NS) ? 0 : 1)  {
			if(!NS){
				this.setCapture()
			}
			x0 = e.clientX ;  
			y0 = e.clientY ;  
			x1 = parseInt(ABS(target).x);  
			y1 = parseInt(ABS(target).y);    
			moveable = true;  
		}  
	};   
	source.onmousemove = function(e){
		e = e ? e : (window.event ? window.event : null);  
		if(moveable){  
			target.style.left = (x1 + e.clientX - x0 - offSetX) + "px";  
			target.style.top  = (y1 + e.clientY - y0 - offSetY) + "px";  
			this.style.cursor = "move";
		}  
	};  
	source.onmouseup = function (e){
		if(moveable)  {
			if(!NS){
				this.releaseCapture();
			}
			moveable = false;  
			this.style.cursor = "default";
		}  
	};
}

var ShowHtmlBox = {	
	Show : function(vhtml){
				if($("ebdiy_Html_Dialog")){
					$("ebdiy_Html_Dialog").parentNode.removeChild($("ebdiy_Html_Dialog"));
					clearInterval(e_event);
				}
				var page = document.body;
				if (!(document.compatMode && document.compatMode.indexOf('Back') == 0)) {
					page = page.parentNode;
				}	
				
				Dialog = document.createElement("div");
				Dialog.id = "ebdiy_Html_Dialog"
				document.body.appendChild(Dialog);
				Dialog.innerHTML = vhtml;
				
				Dialog.style.cssText = "display:block;position: absolute;border: 2px solid #9E9E9E; background-color:#F7F7F7; padding: 5px 15px 5px 15px;max-width:800px; height:auto;";
				
				var p_top = parseInt((parseInt(page.clientHeight) - Dialog.offsetHeight) / 2);
				var p_left = parseInt((parseInt(page.clientWidth) - Dialog.offsetWidth) / 2);
				
				Dialog.style.top=p_top + "px";
				Dialog.style.left=p_left + "px";
		  
			},
	Hide : function(){
				if($("ebdiy_Html_Dialog")){
					$("ebdiy_Html_Dialog").parentNode.removeChild($("ebdiy_Html_Dialog"));
					clearInterval(e_event);
				}
			}
}
var RBox;
var Book ={
	ShowReplay:function(_this,id){
		var o = $("replay_" + id);
		if(o.style.display=="none"){
			o.style.display = "block";
			_this.innerHTML = "隐藏回复";
		}else{
			o.style.display = "none";
			_this.innerHTML = "显示回复";
			return;
		}
		RBox = _this.parentNode.parentNode;
		Ajax({
			url:"Action.asp?action=loadreplay",
			method:"POST",
			content:"msgid=" + id,
			oncomplete:function(obj){
				var data = obj.responseText.json();
				if(data.error == 2){
					o.innerHTML=data.msg;
				}else if(data.error==0){
					var msgs = data.list;
					var str = "管理员回复：<br />";
					for(var i= 0;i<msgs.length;i++){
						str += (i+1) + "、回复于 " + msgs[i].RDate;
						str += "<div style=\"margin-left:18px;margin-top:3px;\">" + msgs[i].RContent + "</div>";
					}
					o.innerHTML = str;
				}
			},
			ononexception:function(obj){
			}
		});
	},
	ShowMessageBox:function(_this){
		if($("ebdiy_dialog_post")){return;}
		var MsgBox = document.createElement("div");
		var ps = GetCenterPS();
		MsgBox.id = "ebdiy_dialog_post";
		MsgBox.style.cssText="font-size:12px;display:block;position:absolute;width:400px;height:auto;padding:10px;top:" + ps.y + "px;left:" + ps.x + "px;background-color:#FFF;border:2px solid #DDD;padding:5px;";
		MsgBox.innerHTML = "您的名字:<input type=\"text\" id=\"MsgUser\" size=\"20\" maxlength=\"50\" class=\"Input_Text\" /> <font color=\"red\">*</font>不超过50个字符<br />";
		MsgBox.innerHTML += "<br />留言内容:<br /><textarea cols=\"60\" rows=\"8\" id=\"MsgContent\" class=\"Input_TextArea\" style=\"width:390px;\"></textarea><br />";
		MsgBox.innerHTML += "&nbsp; &nbsp; <input type=\"button\" value=\"现在留言\" onclick=\"Book.DoAction();\" class=\"Input_Button\" />&nbsp; &nbsp; <input type=\"button\" value=\"关闭\" class=\"Input_Button\" onclick=\"document.body.removeChild($('ebdiy_dialog_post'));Cover.hide();\" />";
		document.body.appendChild(MsgBox);
		//Drag(MsgBox,MsgBox);
	},
	ShowReplayBox:function(_this,id){
		if($("ebdiy_dialog_replay")){return;}
		var MsgBox = document.createElement("div");
		var ps = GetCenterPS();
		MsgBox.id = "ebdiy_dialog_replay";
		MsgBox.style.cssText="font-size:12px;display:block;position:absolute;width:400px;height:auto;padding:10px;top:" + ps.y + "px;left:" + ps.x + "px;background-color:#FFF;border:2px solid #DDD;padding:5px;";
		MsgBox.innerHTML = "<input type=\"hidden\" id=\"MsgID\" size=\"20\" maxlength=\"50\" value=\"" + id + "\"/>";
		MsgBox.innerHTML += "回复内容:<br /><textarea cols=\"60\" rows=\"8\" id=\"MsgReplayContent\" class=\"Input_TextArea\" style=\"width:390px;\"></textarea><br />";
		MsgBox.innerHTML += "&nbsp; &nbsp; <input type=\"button\" value=\"现在回复\" onclick=\"Book.DoReplay(" + id + ");\" class=\"Input_Button\" />&nbsp; &nbsp; <input type=\"button\" value=\"关闭\" class=\"Input_Button\" onclick=\"document.body.removeChild($('ebdiy_dialog_replay'));Cover.hide();\" />";
		document.body.appendChild(MsgBox);
	},
	DoReplay:function(id){
		var content = $("MsgReplayContent").value.trim();
		if(content==""){
			alert("回复内容不能为空,谢谢。");
			return;
		}
		var Data = "id=" + id + "&content=" + content.utf8();
			Ajax({
				url:"ajaxAction.asp?action=postreply",
				method:"POST",
				content:Data,
				oncomplete:function(obj){
					var data = obj.responseText.json();
					if(data.error == 0){
						alert("回复成功.");
					}else if(data.error==1){
						alert("管理员未登录，不能回复");
					}
					document.body.removeChild($('ebdiy_dialog_replay'));
					Cover.hide();
				},
				ononexception:function(obj){
				}
			});
	},
	DoAction:function(){
		var user = $("MsgUser").value.trim();
		var content = $("MsgContent").value.trim();
		if(user == "" || content == ""){
			alert("名字和内容都不能为空,谢谢。");
			return;
		}else{
			var Data = "name=" + user.utf8() + "&content=" + content.utf8();
			Ajax({
				url:"Action.asp?action=postmessage",
				method:"POST",
				content:Data,
				oncomplete:function(obj){
					var data = obj.responseText.json();
					var Str="";
					alert(data.msg);
					document.body.removeChild($('ebdiy_dialog_post'));
					if(data.error == 0){
						Str += "<div class=\"Div_MsgList\">";
						Str += "<div class=\"Div_MsgBody\" id=\"Div_MsgBody_-1\">";
						Str += "<b>" + user + "</b> 留言于 " + data.d + "";
						Str += "<a href=\"javascript:void(0);\" onclick=\"Book.ShowReplay(this,-1);\">查看回复</a>";
						Str += "<br />";
						Str += "<div class=\"Div_MsgContent\">" + content + "</div>";
						Str += "</div>";
						Str += "<div class=\"Div_Replay\" style=\"display:none;\" id=\"replay_-1\"></div>";
						Str += "</div>";
						$("Div_BookList").innerHTML = Str + $("Div_BookList").innerHTML;
					}
					Cover.hide();
				},
				ononexception:function(obj){
				}
			});
		}
	}
};

function GetCenterPS(){
		var page = document.body;
		var ps ={x:0,y:0};
		var obj=document.getElementById("bottomMsg");
		if (!(document.compatMode && document.compatMode.indexOf('Back') == 0)) {
			page = page.parentNode;
		}
		ps.y = parseInt((parseInt(page.clientHeight) + parseInt(page.scrollTop) - 170)/2);
		ps.x = parseInt((parseInt(page.clientWidth) + parseInt(page.scrollLeft) - 420)/2);
		return ps;
}

function GetWH(){
		var page = document.body;
		var ps ={w:0,h:0};
		if (!(document.compatMode && document.compatMode.indexOf('Back') == 0)) {
			page = page.parentNode;
		}
		ps.h = parseInt(page.scrollHeight) + parseInt(page.scrollTop);
		ps.w = parseInt(page.scrollWidth) + parseInt(page.scrollLeft);
		return ps;
}

var RegisterAgreeList = "<iframe src='Common/RegisterAgreeList.html' FRAMEBORDER=0 allowtransparency=true width='100%'></iframe>";
var RegisterpagesList = "<iframe src='Common/RegisterpagesList.html' FRAMEBORDER=0 allowtransparency=true width='100%' height='180'></iframe>";

var RegisterBox = {
	open : function(){
		var Str = "";
		Str += "<div style='width:500px; font-size:11px;'>";
		Str += "<div style='text-align:right;line-height:25px;'><span style='float:left;'>注册新用户</span><a style='color:#666;' href='javascript:void(0);' onclick='Cover.hide();ShowHtmlBox.Hide()'>关闭</a></div>";
		Str += "<div style='line-height:25px;'>" + RegisterAgreeList + "</div>";
		Str += "<div style='text-align:center;line-height:25px; margin-top:10px;'><input type='button' value='同意' onclick='RegisterBox.Write()'><input type='button' value='不同意' onclick='Cover.hide();ShowHtmlBox.Hide()'></div>";
		Str += "</div>";
		ShowHtmlBox.Show(Str);
	},
	Write : function(){
		var Str = "";
		Str += "<div style='width:500px; font-size:11px;'>";
		Str += "<div style='text-align:right;line-height:25px;'><a style='color:#666;' href='javascript:void(0);' onclick='Cover.hide();ShowHtmlBox.Hide()'>关闭</a></div>";
		Str += "<div style='line-height:25px;'>"+RegisterpagesList+"</div>";
		Str += "</div>";
		ShowHtmlBox.Show(Str);
	},
	CheckUserName : function(name, eb){
		if (name.length == 0){
			$(eb).innerHTML = "<font color=red>用户名不能为空.</font>";
			Regire = "0," + Regire.split(",")[1];
			return;
		}else{
			Regire = "1," + Regire.split(",")[1];
		}
		Ajax({
				url:"../Action.asp?action=CheckUserName&name=" + name,
				method:"GET",
				content:"",
				oncomplete:function(obj){
					var data = obj.responseText;
					if (parseInt(data) == 1){
						$(eb).innerHTML = "<font color=blue>可以注册,请继续.</font>";
						Regire = "1," + Regire.split(",")[1];
					}else{
						$(eb).innerHTML = "<font color=red>用户名已存在,请更换用户名.</font>";
						Regire = "0," + Regire.split(",")[1];
					}
				},
				ononexception:function(obj){
				}
			});
	},
	CheckPassWord : function(eb1, eb2, eb3){
		$(eb3).innerHTML = "";
		if (!REG_USERNAME.test($(eb1).value)){
			$(eb3).innerHTML = "<font color=red>密码长度应为5到16位</font>";
			Regire = Regire.split(",")[1] + ",0";
			return;
		}
		if(eb2==''){return;}
		if ($(eb1).value == $(eb2).value){
			$(eb3).innerHTML = "<font color=blue>两次输入的密码相同</font>";
			Regire = Regire.split(",")[1] + ",1";
			return;
		}else{
			$(eb3).innerHTML = "<font color=red>两次输入的密码不相同</font>";
			Regire = Regire.split(",")[1] + ",0";
			return;
		}
	},
	Submit : function(){
		if (($("mUserName").value.length == 0) || ($("mpassword").value.length == 0) || ($("mRepass").value.length == 0)){
			alert("所有选项不能为空!");
			return false;
		}
		if (Regire != "1,1"){
			alert("错误信息,无法提交!")
			return false;
		}
	}
}

var Cover=window.Cover={
	ele:null,size:null,zindex:999,currentO:0,
	show:function(){
		this.ele.style.display="block";
		if(this.currentO < 30) 
		{ 
			this.currentO+=20;
			this.ele.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.currentO + ")"; 
			this.ele.style.opacity=this.currentO/100;
			window.setTimeout("Cover.show()", 20); 
		}
		return this;
	},
	hide:function(){
		if(this.currentO >= 0) 
		{ 
			this.currentO-=30;
			this.ele.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.currentO + ")";
			this.ele.style.opacity=this.currentO/100; 
			window.setTimeout("Cover.hide()", 20); 
		}else{
			this.ele.style.display="none";
		}
		return this;
	},
	init:function(obj){
		if(!obj){
			this.size=GetWH();
		}else{
			this.size.w=obj.offsetWidth;
			this.size.h=obj.offsetHeight;
		}
		if(!this.ele){
			var vele=document.createElement("div");
			this.ele=vele;
			document.body.appendChild(this.ele);
		}
		this.ele.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.currentO + ")";
		this.ele.style.opacity=this.currentO/100;
		this.ele.style.position="absolute";
		this.ele.style.backgroundColor="#000";
		this.ele.style.left="0px";
		this.ele.style.top="0px";
		this.ele.style.width=this.size.w + "px";
		this.ele.style.height=this.size.h + "px";
		this.ele.style.display="none";
		this.ele.style.zindex=this.zindex;
		//window.onscroll=function(){if(Cover.ele.style.display!="none"){Cover.init().show();}}
		return this;
	}
};

function ViewOrder(obj1,id){
	Ajax({
		url:"../Action.asp?action=getorder",
		method:"POST",
		content:"orderid=" + id,
		oncomplete:function(obj){
			var OrderBox = document.createElement("div");
			OrderBox.id="ebdiy_orderBox";
			document.body.appendChild(OrderBox);
			OrderBox.style.cssText="display:block;position:absolute;border:2px #eee solid;padding:5px;width:300px;background-color:#eee;line-height:16px;";
			OrderBox.innerHTML = obj.responseText;
			var ps = ABS(obj1);
			OrderBox.style.left = (ps.x - 310) + "px";
			OrderBox.style.top = (ps.y + 16) + "px";
		},
		ononexception:function(obj){
		}
	});
}


var QString=function (searchStr){
	var url=window.location.search;
	if(url.indexOf("?")>=0){
		url=url.substr(1);
		var varis=url.split("&");
		for(var i in varis){
			var Ary=varis[i].split("=");
			if(Ary[0].toLowerCase()==searchStr.toLowerCase()){
				return Ary[1];
			}
		}
		return "";
	}else{return "";}
}

function showFlash(w,h,images){	
	var focus_width=w;
	var focus_height=h;
	var text_height=0;
	var swf_height = focus_height+text_height;
	var pics=typeof(images)=="object"?images.join("|"):images;
    var texts=typeof(texts)=="object"?texts.join("|"):texts;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
	document.write('<param name="movie" value="images/pixviewer.swf"> <param name="quality" value="high"><param name="bgcolor" value="#EBEBEB">');
	document.write('<param name="menu" value="false"><param name="wmode" value="transparent">');
	document.write('<param name="FlashVars" value="pics='+pics+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
	document.write('<embed src="images/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.write('</object>');
}

function Ask(message){
	message = message ? message : "操作不可恢复，请谨慎操作。\n确定要这样做么？"
	return window.confirm(message);
}