$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});
	
	$("#login_form").submit(function()
	{
		$.post("ajax_login.php",{ user_name:$('#log').val(),password:$('#pwd').val(),rand:Math.random() } ,function(data)
        {
		  if(jQuery.trim(data) == 'yes') //if correct login detail
		  {
		  	 //redirect to secure page
			 document.location='secure.php';
		  }
		  else //if (jQuery.trim(data) == 'no')		  
		  {
		  		//redirect to secure page
				document.location='login1.html';
          }
        });
 		return false; //not to post the  form physically
	});		
});
