$((function(){
			
			enterFunction = function(){
				$(this).html('ACTIVE');
			}
			leaveFunction = function(){
				$(this).html('inactive');
			}
			$('.accordion1').hSlides({
				totalWidth: 572, 
				totalHeight: 333, 
				minPanelWidth: 36, 
				maxPanelWidth: 500,
				easing: 'easeOutBounce'
			});
		}
		));
		
$(document).ready(function()
{
	$("#login_form").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Autentificare....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajax_login.php",{ m:$('#m').val(),p:$('#p').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='05') 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Redirectionare in curs.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 window.location.reload();
				 //document.location='secure.php';
			  });
			  
			});
		  }
		   else if(data=='00') // eroare
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Completati email si parola').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else if(data=='01') // eroare
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Momentan sistemul este inactiv').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else if(data=='02') // ok dar eroare
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() 
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Va rugam sa confirmati adresa de email (din email-ul primit).').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Nu va putem autentifica...').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#p").blur(function()
	{
		$("#login_form").trigger('submit');
	});

$("#autentificarein").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox2").removeClass().addClass('messagebox').text('Autentificare....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajax_login.php",{ m:$('#m2').val(),p:$('#p2').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='05') 
		  {
		  	$("#msgbox2").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Redirectionare in curs.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 document.location='secure.php';
			  });
			  
			});
		  }
		   else if(data=='00') // eroare
		  {
		  	$("#msgbox2").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Completati email si parola').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else if(data=='01') // eroare
		  {
		  	$("#msgbox2").fadeTo(200,0.1,function()  
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Momentan sistemul este inactiv').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else if(data=='02') // ok dar eroare
		  {
		  	$("#msgbox2").fadeTo(200,0.1,function() 
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Va rugam sa confirmati adresa de email (din email-ul primit).').addClass('messageboxerror').fadeTo(900,1);
              
			});
		  }
		  else 
		  {
		  	$("#msgbox2").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Nu va putem autentifica...').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});
});