﻿///<reference path="../jQuery/JQueryIntellisense.js />
var VirtualPath = "/";
$("document").ready(function(){

	$("#frmLogin").ajaxForm({
		url: VirtualPath + 'login.aspx',
		dataType: 'xml',
		beforeSubmit: function(){
			if( $("#txtUserName").val() == '' ) 
			{
				alert("You must enter a username");
				$("#txtUserName").focus();
				return false;
			}
			else
			{
				if( $("#txtPassword").val() == "" )
				{
					alert("You must enter a password");
					$("#txtPassword").focus();				
					return false;
				}
				else
				{
					return true;
				}
			}
		},
		success: function( xml ){
			if( $(xml).find("Login").attr("Success") == "true" )
			{
				alert("Login Successful");
				$("#cmdLogin").click();
			}
			else
			{
				alert("Login failed : " + $(xml).find("Login").attr("Reason") + " incorrect");
			}
		}
	});

	/// Bind event to the login img
	$("#imgLogin").click( function(){
		$(this).toggleFunction({func1: function(){$("#imgLogin").parent().find("table").animate({'width': '100%'}, "fast" );},func2: function(){$("#imgLogin").parent().find("table").animate({'width': 0}, "fast", function(){ $(this).hide(); } );}});
	});
});



