$(document).ready(function(){
/* $('ul.links li:last').addClass('last'); */
	$("ul.links li ul").hide();
	$('ul.links li').hover(
		function () {
			$('ul', this).effect("slide", { direction: "up" }, "slow");
		}, 
		function () {
			$('ul', this).effect("slide", { direction: "up", mode: "hide" });	
		}
	);

/* $("div#box_select_language").hide();
 $("#box_select_language").hide().effect("slide", { direction: "up" }, "slow");
	$("div#options_location").hide();
	$("div#change_location a").click(function() {
		$("#change_location").fadeOut();
		$(this).effect("slide", { direction: "up", mode: "hide" });
		$("div#options_location").effect("slide", { direction: "left" }, "", function() {
			$("a#why-close").effect("slide", { direction: "up" });
		});
	});
	$("a#why-close").click(function() {
		$(this).fadeOut();
		$("div#why-container").effect("slide", { direction: "up", mode: "hide" });
		$("a#why-open").effect("slide", { direction: "up" }, "slow");
	});
	
	$("#fast-search").hide();
	$("#menu-links li ul").hide();
	$("#fast-search").show().effect("slide", { direction: "up" }, "slow");
	 $(function() {
		$(".box-articol").selectable();
	}); */
	$(".ilsn_box_ajutor").fancybox({
			'hideOnContentClick': false,
			'showNavArrows'			: false,
			'frameWidth'			:540,
			'frameHeight'			: 330,
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
			});

		
		swapValues = [];
    $(".schimba").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });
	
	$(".go_zz_lsn").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: false,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
			});

	
	$("#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("http://www.2xperience.ro/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();
			  });
			  
			});
		  }
		   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("http://www.2xperience.ro/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
				 window.location.reload();
			  });
			  
			});
		  }
		   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
	});
	
	$("#inregistrare").submit(function(){ inregistrare(); return false; });
	$("#recup_parola").submit(function(){ recuperare_parola(); return false; });
});
