$(document).ready(function()
{
	var question = $("#question");
	var reg = $("#reg");
	$("#showlogin").click(function()
	{
		$.blockUI(question,{width:"230px",height:"100px"});
	});
	$("#register").click(function()
	{
		$.blockUI(reg,{width:"230px",height:"auto"});
	});
	$("#yes").click(function()
	{
		$.unblockUI();
	});
	$("#cannel").click($.unblockUI);
	$("#btncannel").click($.unblockUI);
	$("#btnLogin").click(function()
	{
		var name = mf("txtname");
		var pwd = mf("txtpwd");
		$.get("../reg.aspx",{login:name.value,userkey:pwd.value},function(data)
		{
			if(data == "true")
			{
				window.location.reload();
			}
			else
			{
				alert("用户名密码错误或账号还未激活！");
			}
		});
	});
	$("#divbtnLogin").click(function()
	{
		var name = mf("divtxtname");
		var pwd = mf("divtxtpwd");
		$.get("../reg.aspx",{login:name.value,userkey:pwd.value},function(data)
		{
			if(data == "true")
			{
				window.location.reload();
			}
			else
			{
				alert("用户名密码错误或账号还未激活！");
			}
		});
	});
	$("#logout").click(function()
	{
		$.get("../reg.aspx",{Logout:"logout"},function(data)
		{
			if(data == "true")
			{
				window.location.reload();
			}
			else
			{
				alert("退出失败！");
			}
		});
	});
	$("#btnReg").click(function()
	{
		var strError;
		var name = mf("UserName");
		var pwd1 = mf("pwd1");
		var pwd2 = mf("pwd2");
		var cname = mf("TrueName");
		var address = mf("Address");
		var telephone = mf("Telephone");
		var email = mf("Email");
		$.get("../reg.aspx",
				{
					reg:name.value,
					pwd1:pwd1.value,
					pwd2:pwd2.value,
					cname:cname.value,
					address:address.value,
					telephone:telephone.value,
					email:email.value
				},
				function(data)
				{
					if(data == "true")
					{
						name.value = "";
						pwd1.value = "";
						pwd2.value = "";
						cname.value = "";
						address.value = "";
						telephone.value = "";
						email.value = "";
						$.unblockUI();
						window.location.reload();
					}
					else
					{
						alert(data);
					}
				});
	});
	function mf(id)
	{
		return document.getElementById(id);
	}
});

function ThumbImg(e,w,h)
{
	var ow = $(e).width();
	var oh = $(e).height();
	var bw = ow/w;
	var bh = oh/h;
	if(bw >= bh)
	{
		$(e).width(w);
		$(e).height(oh/bw);
	}
	else
	{
		$(e).width(ow/bh);
		$(e).height(h);
	}
}

function setIframeHeight(iframe)
{
	if (document.getElementById)
	{
		if (iframe && !window.opera)
		{
			if (iframe.contentDocument && iframe.contentDocument.body.offsetHeight)
				iframe.height = iframe.contentDocument.body.offsetHeight;
			else if(iframe.Document && iframe.Document.body.scrollHeight)
				iframe.height = iframe.Document.body.scrollHeight;
		}
	}
}