// JavaScript Document

$(document).ready(function(){

	/*
	$("#box-categorii ul li ul").hide();

	$("#box-categorii li.cusm").click(function(){
		if (!$(this).children('ul').is(':visible'))
			{
				$("#box-categorii li.cusm > ul").slideUp();
				$(this).children('ul').slideDown();
				return false;
			}
		
	});
	*/
	$(".nolink").click(function(){return false;});
	
	
	//$("#lmenu").hover(function() { $(this).addClass("iehover"); }, function() { $(this).removeClass("iehover"); });
	
	//* Meniu left
	h = $("#box-categorii").height()- 30; //alert(h);
	$("#submenu").height(h);
	$(".reset").css('margin-top', -h + 45);
	
	$("#lmenu li").hover(function(){
		var txt =  $(this).find(".submenu").html();
		var cols = $(this).attr("class");
		//alert(cols);
		
		if (txt == null) return true;
		//alert(txt);
		$("#submenu").css('width', cols * 220 + 'px');
		$("#submenu").html(txt);
		$("#submenu").fadeIn();			
	});

	$("#submenu").mouseleave(function(){
		$("#submenu").fadeOut();
	});
	//*/
	
	//Meniu personaje pe litere
	$("#personaje li").hide();
	
	$(".alfabet a").click(function(){
		var litera = $(this).attr("id");
		$("#personaje li").slideUp();
		$("#personaje li.L-" + litera).slideDown();
		return false;
	});
	
	//Newsletter abonare
	$("#bnewsletter").click(function(){
		
		var mail = $("#newsletter").val();
		if (!validateEmail(mail))
		{
			alert('Adresa de email invalida!');
			return false;
		}
		
		$.ajax({ 
			type: "POST",
			url: "js/p/ajax.php?AddNewlMail",
			data: "mail=" + mail,
			success: function(msg){
     			alert(msg);
			}
		});
		return true;
	});
	
	
	function validateEmail(elementValue){  
	   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	   return emailPattern.test(elementValue);  
	}
	
});
