$(function(){ 
	
	$(".sigla_wrapper_hover").animate({ "opacity": 0 }); 
	
	/************EFECT NEWSLETTER************/
	$("input.newsletter_text").focus(
		function(){
			var text = $(this).val(); 
			if (text=="adresa de email") {
				$(this).val("").css("font-style", "normal").css("background", "url('./img/icon_mail.gif') no-repeat 3px center #FFFFFF");   
			}
		}
	); 
	$("input.newsletter_text").blur(
		function(){
			var text = $(this).val(); 
			if (text=="") {
				$(this).val("adresa de email").css("font-style", "italic").css("background", "url('./img/icon_mail.gif') no-repeat 3px center #FFFFFF");    
			}
		}
	);
	
	/************EFECT SEARCH************/
	$("input.search").focus(
		function(){
			var text = $(this).val(); 
			if (text=="cuvinte cheie") {
				$(this).val("").css("font-style", "normal").css("background", "url('./img/icon_search.png') no-repeat 3px center #FFFFFF");   
			}
		}
	); 
	$("input.search").blur(
		function(){
			var text = $(this).val(); 
			if (text=="") {
				$(this).val("cuvinte cheie").css("font-style", "italic").css("background", "url('./img/icon_search.png') no-repeat 3px center #FFFFFF");    
			}
		}
	);
	 
	/************EFECT SIGLA************/
	$(".sigla_wrapper").hover(
		function(){  
			$(this).find(".sigla_wrapper_hover").stop().animate({ "opacity": 1 });  
		},
		function(){
			$(this).find(".sigla_wrapper_hover").stop().animate({ "opacity": 0 });
		}
	);
	
	/************EFECT MENIU************/
	$("#menu_wrapper a").hover(
		function(){  
			$(this).find(".menu_txt02").fadeOut(0, function(){
				$(this).parent().find(".menu_txt01").stop().animate({fontSize: "20px"}, 0);
			});  
		},
		function(){
			$(this).find(".menu_txt01").stop().animate({fontSize: "16px"}, 0, function(){
				$(this).parent().find(".menu_txt02").fadeIn(0); 
			});  
		}
	);
	
	/************EFECT COS************/
	$("#cos_label").click(function(){
		if ( $(this).parent().attr("class")=="opened" ) {
			$(this).parent().stop().animate({"right": "0px"}, 100, function(){ 
				$(this).animate({"right": "-200px"}, 150, function(){
					$(this).addClass("closed");
					$(this).removeClass("opened");
				});
			});
		} else {
			$(this).parent().stop().animate({"right": "-205px"}, 100, function(){ 
				$(this).animate({"right": "-5px"}, 150, function(){
					$(this).addClass("opened");
					$(this).removeClass("closed");
				});
			});
		}
	});
	
	/************* ORDONARE PRODUSE ***************/
	$("select.order_select").change(function(){
		window.location = $(this).attr("page") + $(this).val();		
	}); 
	
	/************ NEWSLETTER ****************/
	$("#newsletter_button").live("click", function(){
		$("input.newsletter_text")
		.css("background", "url('./img/ajax_load_newsletter.gif') no-repeat 3px center #FFFFFF");
		 
		$.ajax({ 
			url: "_ajax_newsletter.php",
			type: "POST",
			data: {
				email : $("input.newsletter_text").val()
			},  
			success: function(data, txtStatus, xmlHttpRequest){   
				
				exploded = data.split("*");
				header = exploded[0];
				response = exploded[1];

				$("#newsletter_response").html(response);
				$("input.newsletter_text")
					.css("background", "url('./img/icon_mail.gif') no-repeat 3px center #FFFFFF");
				
				if (header==1) { 
					$("#newsletter_wrapper_div").hide(500, function(){
						$(this).remove();
					});
				}
			}
		});  
		
	});
	
});

/************* SEARCH ***************/
function checkForSearch() {
	if ( $("#search_input").val()=="" || $("#search_input").val()=="cuvinte cheie" ) return false;
	return true;
}
