    	

$(document).ready(function() {
						   
	// ---------------------------------------------------- LOGIN JS FUNCTIONS

		function MemberZoneContainerDataLoad()
		{
			$.ajax({
					method: "get",url: "login/memberzone.php",data: "p=home",
					success: function(html){ //so, if data is retrieved, store it in html
					$("#MemberZoneContainerData").html('<br />'); //show the html inside .content div
					$("#MemberZoneContainerData").html(html); //show the html inside .content div
					 }
				 }); //close $.ajax(
		};
	
		$.post("login/logincheck.php", function(data)
        {
		  if(data=='false')
		  {
				$('#h_member').fadeIn(300 , function()
						{ 
							$('#LogInContainer').slideDown(1500);
						});	
		  };
		  
		  if(data=='true')
		  {
			  
				MemberZoneContainerDataLoad();
				 
				$('#h_member').fadeIn(300 , function()
						{ 
							$('#MemberZoneContainer').slideDown(1500);
						});	
		  };
		});
				
	
	$("#login_form").submit(function()
	{
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);

		$.post("login/login.php",{ user_name:$('#user_name').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes')
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()
			{ 
			  $(this).html('Logging in...').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
				//document.location='loggedinpage.php';
				MemberZoneContainerDataLoad();
				$(this).html('Logged In').addClass('logged in').fadeTo(900,1);
				$('#LogInContainer').slideUp(800);
				$("#msgbox").fadeOut(600, function()
				{
					$('#MemberZoneContainer').slideDown(1000);				
				});

				

			  });
			  
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()
			{ 
			  //$(this).html('Uw gebruikersnaam of passwoord was niet correct...').addClass('messageboxerror').fadeTo(900,1);
			  $(this).html(data).addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});

	
		$('.linker_memberzone').click(function() {
				
				$.ajax({
							method: "get",url: "login/session_destroy.php",data: "",
							success: function(html){
							$("#MemberZoneContainer").slideUp(800,function(){
																	$("#LogInContainer").slideDown(1000); //animation
																	});
					 }
				 });

				
						
         });


	// ---------------------------------------------------- SITE PAGE SWITCH

		$("#container").fadeIn("slow");	 

			$.ajax({
					method: "get",url: "switch.php",data: "p=home",
					beforeSend: function(){$("#loading").fadeIn("slow");},
					complete: function(){ $("#loading").fadeOut("slow");},
					success: function(html){ 
					$("#m_content_placeholder").html('<br />');
					$("#m_content_placeholder").html(html); 
					$("#m_content_placeholder").slideDown("slow");
					 }
				 }); //close $.ajax(

		$('.linker_main').click(function() { 
										 
		 				$("#m_content_placeholder").slideUp("slow");
						 var content_show = $(this).attr("title"); 
							$.ajax({
							method: "get",url: "switch.php",data: "p="+content_show,
							beforeSend: function(){$("#loading").fadeIn("slow");}, 
							complete: function(){ $("#loading").fadeOut("slow");}, 
							success: function(html){ 
							$("#m_content_placeholder").html('<br />');
							$("#m_content_placeholder").html(html); 
							$("#m_content_placeholder").slideDown("slow");
													 }
								 }); //close $.ajax
        		 }); //close click

/*		$('.linker_main').click(function() { 
										 var content_show = $(this).attr("title"); 

										 $("#m_content_placeholder").load("switch.php?p="+content_show); 

										 });*/

});
