$(document).ready(function()
{
	function checkForm()
	{
		var errors = '';
		if ($("#txtUsername").val()=='')
			errors += "- Please enter Username<br />";
		if ($("#txtPassword").val()=='')
			errors += "- Please enter Password<br />";
		if (errors=='')
		{
			//$("#errors_div").fadeOut("slow");
			return true;
		}
		else
		{
			$("#errors_div").html("<b>Errors:</b><br />"+errors);
			$("#errors_div").fadeIn("slow");
			return false;
		}
	}

	
	$("#btnPartnerLogin").click(function(){
		if(checkForm())
		{			
			$('#statusLoader').ajaxStart(function() {
				//$("#contentArea").hide();
				$(this).show();
	
			}).ajaxStop(function() {
				$(this).hide();
			});				
			$.post("ajax/index_ajax.php", {purpose:'partnerLogin',userName:$('#txtUsername').val(),userPassword:$('#txtPassword').val()}, 
				function(response){
					if(response)
					{						
						if(response.indexOf('E~R~R~O~R') != -1)
						{
							$('#txtPassword').val('');
							$('#txtUsername').focus();
							$('#btnPartnerLogin').disabled = false;
							var arrResponse = new Array();
							arrResponse = response.split('HAM~JAM');
							$("#errors_div").html(arrResponse[1]);
							$("#errors_div").fadeIn("slow");
						}
						else
						{
							//$("#errors_div").html(response);
							window.location = response;
						}
					}
				});	
		}
	});



});

