$(function(){
	if ($(".loadpic img").length)
	{
	$(".loadpic img").LoadImage(true,110,103,"/images/loading.gif");
	}
});
function MoveDiv(){
	var d = document.getElementById(arguments[0]);
	var e = reEvent();
	if (document.all){
		d.style.left = document.documentElement.scrollLeft + e.clientX - 110;
	  	d.style.top = document.documentElement.scrollTop + e.clientY - 50;
		//alert("step 1 - " + d.style.left + "|" + d.style.top)
  	}else{
  		d.style.left = (e.pageX - 110) + 'px';
	  	d.style.top = (e.pageY - 50) + 'px';
		//alert("step 2 - " + d.style.left + "|" + d.style.top)
  	}
  	d.style.display = 'block';
}
function reEvent() {
	//Event
	return window.event ? window.event : (function (o) {
		do {
			o = o.caller;
		} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
		return o.arguments[0];
	})(this.reEvent);
}
function commentlogin(){
	if ($('#essusername').val() == ""){
		alert('請填寫用戶名');
		$('#essusername').focus();
		return false;
	}
	if ($("#esspassword").val() == ""){
		alert("請填寫密碼");
		$("#esspassword").focus();
		return false;
	}
}
function gocheckuser(){
commentlogin();
$("#loginformdiv").css("display","none");
$("#usertop").html("登陸中...");
	$.ajax({
	url:"/users/include/memLogin.asp",
	type:"post",
	data:"essusername=" + $('#essusername').val() + "&esspassword=" + $('#esspassword').val(),
	success:function(msg){
	$("#usertop").html(msg);
	ForUserNameContent();
	}
	});
}
function logoutaccount(){
$("#usertop").html("登出中...");
	$.ajax({
	url:"/users/include/memLogin.asp",
	type:"post",
	data:"action=logout",
	success:function(msg){
	$("#usertop").html(msg);
	}
	});
}
function ForUserNameContent(){
	if ($("#unforusername").length)
	{
		if ($("#username").length){
		var un = $("#unforusername").text();
		$("#username").val(un);
		$("#logina").remove();
		}
	}
}

function wd(id){
	$.ajax({
		url:"/program/recommend.asp",
		type:"post",
		data:"id=" + id,
		success:function(msg){
			if (msg==0)
			{
				var p = $("#" + id).text();
				$("#" + id).text(parseInt(p) + 1);
			}else if(msg == -1){
				alert("您已經推薦過這個節目了");
			}
		}
	});
}