YAHOO.namespace("example.container");
function init()
{
	function showOkContainer()
	{
		var objContainer	= document.getElementById("dialogOkContainer");
		objContainer.style.display = 'block';
	}
	function hideOkContainer()
	{
		var objContainer	= document.getElementById("dialogOkContainer");
		objContainer.style.display = 'none';
	}
	YAHOO.example.container.dialogOk = new YAHOO.widget.Panel("OkDialog", 
																				{ width : "312px",
																					height : "107px",
																				   iframe:true,
																				   fixedcenter:false,
																				   visible : false, 
																				  constraintoviewport :  true
																				 } );
	
	YAHOO.example.container.dialogOk.beforeShowEvent.subscribe(showOkContainer,YAHOO.example.container.dialogOk,true);
	YAHOO.example.container.dialogOk.hideEvent.subscribe(hideOkContainer,YAHOO.example.container.dialogOk,true);	
	YAHOO.example.container.dialogOk.render();
	
	function showConfirmContainer()
	{
		var objContainer	= document.getElementById("dialogConfirmContainer");
		objContainer.style.display = 'block';
	}
	function hideConfirmContainer()
	{
		var objContainer	= document.getElementById("dialogConfirmContainer");
		objContainer.style.display = 'none';
	}
	YAHOO.example.container.dialogConfirm = new YAHOO.widget.Panel("ConfirmDialog", 
																				{ width : "312px",
																					height : "107px",
																				   iframe:true,
																				   fixedcenter:false,
																				   visible : false, 
																				  constraintoviewport :  true
																				 } );
	
	YAHOO.example.container.dialogConfirm.beforeShowEvent.subscribe(showConfirmContainer,YAHOO.example.container.dialogConfirm,true);
	YAHOO.example.container.dialogConfirm.hideEvent.subscribe(hideConfirmContainer,YAHOO.example.container.dialogConfirm,true);	
	YAHOO.example.container.dialogConfirm.render();
	loadImage();
}
function memberLogin()
	{
		var sUrl = "post/login_post.php";
		YAHOO.util.Connect.setForm(document.frmLogin,false);
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, actionLoginCallBack);
		return false;
	}
	var handleLoginActionSuccess = function(o)
	{
			if(o.responseText == '1')
			{
				window.location.href='profile.php';
			}
			else if(o.responseText  != '')
			{
				var obMsg = eval(o.responseText);
				if(obMsg[0].msg != '')
				{
					YAHOO.example.container.dialogOk.show();
					YAHOO.util.Event.addListener("OkAction", 'click',closeOkDialog);
					document.getElementById("OkMessage").innerHTML = obMsg[0].msg;
					document.frmLogin.reset();
				}
			}
	};
function closeOkDialog()
{
	YAHOO.util.Event.removeListener("OkAction", "click"); 
	YAHOO.example.container.dialogOk.hide();
}
function closeConfirmDialog()
{
	YAHOO.util.Event.removeListener("ConfirmAction", "click"); 
	YAHOO.example.container.dialogConfirm.hide();
}
function refreshOkDialog()
{
	YAHOO.util.Event.removeListener("OkAction", "click"); 
	history.go();
}
var handleLoginActionFailure = function(o){alert('Connection error');};
var actionLoginCallBack ={upload:handleLoginActionSuccess,success:handleLoginActionSuccess,failure:handleLoginActionFailure};

function memberLogin2()
	{
			var sUrl = "post/login_post.php";
			YAHOO.util.Connect.setForm(document.frmLogin2,false);
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, actionLogin2CallBack);
			return false;
}
var handleLogin2ActionSuccess = function(o)
{	
	if(o.responseText == '1')
		{
				window.location.href='profile.php';
		}
	else if(o.responseText  != '')
	{
		var obMsg = eval(o.responseText);
		if(obMsg[0].msg != '')
		{
			YAHOO.example.container.dialogOk.show();
				YAHOO.util.Event.addListener("OkAction", 'click',closeOkDialog);
			document.getElementById("OkMessage").innerHTML = obMsg[0].msg;
			document.frmLogin2.reset();
		}
	}
}
function memberLogin3()
	{
			var sUrl = "post/login_post.php";
			YAHOO.util.Connect.setForm(document.frmLogin3,false);
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, actionLogin3CallBack);
			return false;
}
var handleLogin3ActionSuccess = function(o)
{	
	if(o.responseText == '1')
		{
				window.location.href='handicap.php';
		}
	else if(o.responseText  != '')
	{
		var obMsg = eval(o.responseText);
		if(obMsg[0].msg != '')
		{
			YAHOO.example.container.dialogOk.show();
				YAHOO.util.Event.addListener("OkAction", 'click',closeOkDialog);
			document.getElementById("OkMessage").innerHTML = obMsg[0].msg;
			document.frmLogin3.reset();
		}
	}
}
var actionLogin3CallBack ={upload:handleLogin3ActionSuccess,success:handleLogin3ActionSuccess,failure:handleLoginActionFailure};
var actionLogin2CallBack ={upload:handleLogin2ActionSuccess,success:handleLogin2ActionSuccess,failure:handleLoginActionFailure};

function doLogout()
	{
			var sUrl = "post/login_post.php";
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, actionLogoutCallBack,'frmAction=logout');
			return false;
	}
var handleLogoutActionSuccess = function(o)
{
		if(o.responseText == '1')
			{
					window.history.go();
			}
		else if(o.responseText  != '')
		{
			var obMsg = eval(o.responseText);
			if(obMsg[0].msg != '') 
			alert(obMsg[0].msg);
			document.frmLogout.reset();
		}

};
var handleLogoutActionFailure = function(o){alert('Connection error');};
var actionLogoutCallBack ={upload:handleLogoutActionSuccess,success:handleLogoutActionSuccess,failure:handleLogoutActionFailure};

function getAgendar(month,year)
{
	var sUrl = "post/agenda_fetch.php";
	var Args = 'month='+month+'&year='+year;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, actionAgenCallBack,Args);
	return false;
}
var handleAgenActionSuccess = function(o)
{
	document.getElementById("AgenPanel").innerHTML = o.responseText;
}
var actionAgenCallBack ={success:handleAgenActionSuccess,failure:handleLogoutActionFailure};
function loadImage()
{
	MM_preloadImages('images/topmenu1_over.jpg','images/topmenu2_over.jpg','images/topmenu3_over.jpg','images/topmenu4_over.jpg','images/topmenu5_over.jpg','images/topmenu6_over.jpg','images/topmenu7_over.jpg')
}
YAHOO.util.Event.onDOMReady(init);


