//jQuery.noConflict();
// Preload Images
img1 = new Image(16, 16);  
img1.src="images/modal/spinner.gif";
img2 = new Image(220, 19);  
img2.src="images/modal/ajax-loader.gif";

$(document).ready(function(){
						   
	$("#reg_link").click(function(){ $('#reg_form').modal(); });

	// When the form is submitted							
	$("#status_reg > form").submit(function(){  							
		// Hide 'Submit' Button						
		$('#submit').hide();						
		// Show Gif Spinning Rotator						
		$('#ajax_loading').show();						
		// 'this' refers to the current submitted form  						
		var str = $(this).serialize();  						
		// -- Start AJAX Call --						
		$.ajax({  						
			type: "POST",					
			url: "/do-reg.php",  // Send the login info to this page					
			data: str,  					
			success: function(msg){  					
				$("#status_reg").ajaxComplete(function(event, request, settings){  				
					 // Show 'Submit' Button			
					$('#submit').show();			
					// Hide Gif Spinning Rotator			
					$('#ajax_loading').hide();  			
								
					if(msg == 'OK') { // REGISTRATION OK?			
						 var reg_response = '<div id="logged_in">' +		
							 '<div style="width: 350px; float: left; margin-left: 70px;">' + 	
							 '<div style="width: 40px; float: left;">' +	
							 '<img style="margin: 10px 0px 10px 0px;" align="absmiddle" src="images/modal/ajax-loader.gif">' +	
							 '</div>' +	
							 '<div style="margin: 10px 0px 0px 10px; float: right; width: 300px;">'+ 	
							 "Registrace proběhla úspěšně! <br /> Přesměrovávám stránku...</div></div>";  	
						$('a.modalCloseImg').hide();  		
						$('#simplemodal-container').css("width","500px");		
						$('#simplemodal-container').css("height","120px");		
						$(this).html(reg_response); // Refers to 'status'		
						setTimeout('go_to_private_page()', 1000); // After 1 seconds redirect the 		
					 }  			
					 else { // ERROR?			
						 var reg_response = msg;		
						 $('#reg_response').html(reg_response);		
					 }  			
				 });  				
			}  					
		});  						
		// -- End AJAX Call --						
		return false;						
	}); // end submit event							

});

// When DOM is ready
$(document).ready(function(){

	// Launch MODAL BOX if the Login Link is clicked
	$("#login_link").click(function(){ $('#login_form').modal(); });

	// When the form is submitted
	$("#status_login > form").submit(function(){  
		// Hide 'Submit' Button
		$('#submit').hide();
		// Show Gif Spinning Rotator
		$('#ajax_loading').show();
		// 'this' refers to the current submitted form  
		var str = $(this).serialize();  
		// -- Start AJAX Call --
		$.ajax({  
			type: "POST",
			url: "do-login.php",  // Send the login info to this page
			data: str,  
			success: function(msg){  
				$("#status_login").ajaxComplete(function(event, request, settings){  
					 // Show 'Submit' Button
					$('#submit').show();
					// Hide Gif Spinning Rotator
					$('#ajax_loading').hide();  
					
					if(msg == 'OK') { // LOGIN OK?
						 var login_response = '<div id="logged_in">' +
							 '<div style="width: 350px; float: left; margin-left: 70px;">' + 
							 '<div style="width: 40px; float: left;">' +
							 '<img style="margin: 10px 0px 10px 0px;" align="absmiddle" src="images/modal/ajax-loader.gif">' +
							 '</div>' +
							 '<div style="margin: 10px 0px 0px 10px; float: right; width: 300px;">'+ 
							 "Přihlášení proběhlo úspěšně! <br /> Přesměrovávám stránku...</div></div>";  
						$('a.modalCloseImg').hide();  
						$('#simplemodal-container').css("width","500px");
						$('#simplemodal-container').css("height","120px");
						$(this).html(login_response); // Refers to 'status'
						setTimeout('go_to_private_page()', 1000); // After 1 seconds redirect the 
					 }  
					 else { // ERROR?
						 var login_response = msg;
						 $('#login_response').html(login_response);
					 }  
				 });  
			}  
		});  
		// -- End AJAX Call --
		return false;
	}); // end submit event
});

function go_to_private_page() { window.location = 'private.php'; } // Members Area 

