

$(document).ready(function() 
{


	if ($(".produs").length)
	{
		$('#mycarousel').jcarousel({
			auto: 5,
			wrap: 'last',
			animation: 'slow',
			initCallback: mycarousel_initCallback
		});
	$("a[rel^='prettyPhoto']").prettyPhoto({allow_resize: true, theme: 'light_square',overlay_gallery: false});

	// stergerea butoanelor pentru inainte si inapoi daca sunt sub 5 poze
	if ($(".jcarousel-clip").length) {
		if ($("#mycarousel .yoxview").length<5){
			$(".jcarousel-next").css('display', 'none');
			$(".jcarousel-prev").css('display', 'none');
			}
		if (!$("#mycarousel .yoxview").length){
			 $(".jcarousel-skin-tango").css('display', 'none');
		};
	};

    };
	if ($(".parteneri").length)
	{
		$('#mycarousel').jcarousel({
			auto: 5,
			wrap: 'last',
			animation: 'slow',
			initCallback: mycarousel_initCallback
		});
		
		if ($(".jcarousel-clip").length) {
			if ($("#mycarousel .yoxview").length<3){
				$(".jcarousel-next").css('display', 'none');
				$(".jcarousel-prev").css('display', 'none');
			}
			if (!$("#mycarousel .yoxview").length){
				$(".jcarousel-skin-tango").css('display', 'none');
			};
		};
    };

});

$(function () {
	if ($(".center_right_content_accesibile").length) {
		// Add pdf icons to pdf links
		$(".center_right_content_accesibile a[href$='.pdf'], .center_right_content_accesibile a[href$='.PDF']").addClass("pdf");
 
		// Add txt icons to document links (doc, rtf, txt)
		$(".center_right_content_accesibile a[href$='.doc'], .center_right_content_accesibile a[href$='.docx'], .center_right_content_accesibile a[href$='.txt'], .center_right_content_accesibile a[href$='.rtf'],.center_right_content_accesibile a[href$='.DOC'],.center_right_content_accesibile a[href$='.DOCX'], .center_right_content_accesibile a[href$='.TXT'], .center_right_content_accesibile a[href$='.RTF']").addClass("txt");
 
		// Add zip icons to Zip file links (zip, rar)
		$(".center_right_content_accesibile a[href$='.zip'], .center_right_content_accesibile a[href$='.ZIP']").addClass("zip"); 

		// Add zip icons to Zip file links (zip, rar)
		$(".center_right_content_accesibile a[href$='.rar'], .center_right_content_accesibile a[href$='.RAR']").addClass("rar");  
	};
	// Add email icons to email links
	//$("a[href^='mailto:']").addClass("email");
	if ($(".center_right_content_1").length) {
		// Add .tabel la tabel
		$(".center_right table, .center_right TABLE").addClass("tabel");
		// editarea tabelelor
		$(".center_right_content_1 table").each(function(){
			$("tr:gt(0):even").addClass("table_even");
		});
		$(".center_right_content_1 table").each(function(){
			$("tr:gt(0):odd").addClass("table_odd");
		});

//		$(".center_right_content_1 table tr:gt(0):even").addClass("table_even");
//		$(".center_right_content_1 table tr:gt(0):odd").addClass("table_odd");
		$(".center_right_content_1 table tr:first-child").addClass("table_header");
//		$(".center_right_content_1 table tr:first-child td:first-child").addClass("table_header_st");

	};

	if ($(".center_right_content_2").length) { 
          	
		if ( $.browser.msie ) {
			$(".center_right_content_2 li a img").css("border-color", "#fff");
			ie6catch = $.browser.msie + $.browser.version;
 			if (ie6catch.indexOf("true6") == -1) {
					$(".center_right_content_2 li a img").attr('src', 'assets/images/suport2.png');
 			}else{
					$(".center_right_content_2 li a img").attr('src', 'assets/images/suport2.gif');
			}

		}
	};



	//$(".center_right_content_1 table tr:first td:first, .center_right_content_1 table tr:first th:first").css({backgroundColor: '#ffe'});
	// meniu right
	$('.Nav_right ul li').each(function () {

		var seAfiseaza = false;
		var Afisat = false;
		var ascundeTimer = false;

		var link = $('a:first', this);
		var list = $('ul', this);

		jQuery(this).mouseover(function () {

			if (ascundeTimer) clearTimeout(ascundeTimer);

			if(seAfiseaza || Afisat) {
				return;
			} else {
				seAfiseaza=true;
				jQuery(link).addClass('selected');
				jQuery(list.get(0)).fadeIn('fast',function(){
					seAfiseaza=false;
					Afisat=true;
				});
			}

		}).mouseout(function () {

			if (ascundeTimer) clearTimeout(ascundeTimer);

			ascundeTimer=setTimeout(
				function () {
					ascundeTimer=true;
					jQuery(list.get(0)).fadeOut('fast',function(){
						jQuery(link).removeClass('selected');
						Afisat=false;
					});
				}
			, 100);

		});

	});


// meniu produse cu imagini
	$('.image_menu_produse li a').each(function () {

		var seAfiseaza = false;
		var Afisat = false;
		var ascundeTimer = false;

		var link = $('a:first', this);
		var list = $('img', this);
		
		jQuery(this).mouseover(function () {
		list.css({ opacity: 0.8 });


		}).mouseout(function () {
		list.css({ opacity: 1 });


		});

	});


$(".submenu_a_top").hover(function(){
    $(this).animate({
        'padding-top': '+=10px'
    }, "normal");
}, function(){
    $(this).animate({
        'padding-top': '-=10px'
    }, "normal");
});

//= functionalitate sitemap ==============

if ($("#sitemap_produse_box").length) { 
        $("#sitemap_produse_elements")
    .appendTo("#sitemap_produse_box");
	};
});

//= abonare newsletter ==============
function adaugareAbonat(denumire) {
	//$('#sterge_'+id).attr('class','loading');

//	if(confirm("Sunteti sigur ca doriti sa stergeti acest element ?")) {
	
	mail = $(denumire).attr("value");
	validation = mail_validation(mail);
	if(validation==0)
	{
		$.post('assets/newsletter/ajax.php?a=adaugareAbonat',
			{
				cat: "newsletter_abonati",
				mail_: mail
			}   ,function(data){
     				//alert("Data Loaded: " + data);
					if (data==1)
					{
						$(".steluta").html("* <span style='color:#090;'>adresa de mail a fost inregistrată</span>");
					}
					else if (data==2)
					{
						$(".steluta").html("* <span style='color:#090;'>adresa de mail exista deja in baza de date</span>");
					}
					else
					{
						$(".steluta").text("* adresa de mail nu a putut fi inregistrată");
					}					
   				}/*,
			function(data)
			{
				$('#lid_'+id).slideUp('fast',function(){

					// -1 la total produse
					var nr = parseInt($('#nr_art').text());
					$('#nr_art').text(nr-1);

					// -1 la activ/inactiv
					nr = $('#status_'+id).attr('class');
					if(nr=='activ') {
						nr = parseInt($('#art_a').text());
						$('#art_a').text(nr-1);
					} else {
						nr = parseInt($('#art_i').text());
						$('#art_i').text(nr-1);
					}

					$('#lid_'+id).remove();
					reColored();

				});
			}*/
		);
	}
	else if (validation==1)
	{
		$(".steluta").text("* Introduceti adresa de mail");

	}
		else if (validation==2)
	{
		$(".steluta").text("* adresa de mail este incorecta");

	}

	//} else $('#sterge_'+id).attr('class','delete');

}
function mail_validation(mailField) 
{
	$(".error").hide();
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var returnar = 0;
	 
	var emailaddressVal = mailField;
	if(emailaddressVal == '') {
		//$(mailField).after('<span class="error">Please enter your email address.</span>');
		//hasError = true;
		returnar = 1;
	}	 
	else if(!emailReg.test(emailaddressVal)) {
		//$("#UserEmail").after('<span class="error">Enter a valid email address.</span>');
		//hasError = true;
		returnar = 2;
	};
	 
/*	if(hasError == true)
	{
		 returnar = false;
	}; 
*/
	return returnar;
};
//exact ce scrie
function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}

