/***** COMMON JQUERY *****/
//FB SHARE				
	function fbs_click(u,t) {
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;
	}
	
	function copyInputText(from,to) {
		 var fromR = document.getElementsByName(from).item(0);
		 var toR = document.getElementsByName(to).item(0);
		 if (toR.value=="") {
			toR.value = fromR.value;
		 }
	}
	
	function checkDataClick(from,to) {
		 var fromR = document.getElementsByName(from).item(0);
		 var toR = document.getElementsByName(to).item(0);
		 if (fromR.value == toR.value) {
			fromR.value = "";
		 } 
		

	}
	
	function checkDataClickOut(from,to) {
		 var fromR = document.getElementsByName(from).item(0);
		 var toR = document.getElementsByName(to).item(0);
		 if (fromR.value=="") {
			fromR.value = toR.value;
		 }
	}	
	
	
// FUNCTIONS BEGIN //
	
	function showDropDown(e){
		var p = e.position();
		
		if(e.children("a").hasClass("first")) {
			e.children(".mm").addClass("active-first");
		} else {
			e.children(".mm").addClass("active");
		}
		
		e.children(".dd").css("top", p.top + 40);
		e.children(".dd").css("left", p.left);
		e.children(".dd").show();
	}
	
	function hideDropDown(e){
		e.children("a").removeClass("active-first");
		e.children("a").removeClass("active");
		e.children('.dd').hide();
	}
	
	function showCatDropDown(e){
		var pos = e.position();
		e.children(".cdd").css("top", pos.top + 34);
		e.children(".cdd").css("left", pos.left);
		e.children(".cdd").show();
	}
	
	function hideCatDropDown(e){
		e.children(".cdd").hide();
	}
	
	function setExpressShipping( obj ){
		if ( obj.checked == true ) document.getElementById('shippingExprData').value = 1;
		else document.getElementById('shippingExprData').value = -1;
		document.getElementById('shippingExprForm').submit();
	}
// FUNCTIONS END //

// MAIN JQUERY BEGIN //

	$(document).ready(function() {
		
		$(window).load(function() {
			$.getScript("/js/orbit/jquery.orbit.min.js", function() {
				$(".slider").orbit({
					timer: 1,
					captions: true,
					bullets: 1,
					captionAnimationSpeed: 0,
					directionalNav: false
				});
			});
			
			$(".cat-product-list").jcarousel({
				scroll	: 5
			});
			
			$("#sac").parent().parent().find(".jcarousel-container").hide();
		});

		$("#tags").autocomplete({
			minLength: 2,
			source: '/ajax',
			select: function(e, ui) {
				document.location.href = ui.item.value;
			},
			open: function(event, ui) { $(".ui-autocomplete").css("z-index", 9999); },
			close: function(event, ui) { $(".ui-autocomplete").css("z-index", 2); }
		});
		
		$("#searchForm").submit(function(e){
			e.preventDefault();
			document.location = '/scr?pat='+encodeURI($('#tags').val());
		});

		
		$(".tabbed-content").hide();
		$("#tab0").show();
		
		//$(".packaging").parent().parent().find("td:not(.name)").css("visibility", "hidden");
		
		$("#parfum-desc").click(function(){
			var pos = $(".tabbed-menu").position();
			$("html,body").animate({scrollTop: pos.top}, "slow");
			return false;
		});
		
		$("#add").click(function() {
			$.getScript("/js/jquery.lightbox_me.js", function() {
				$('.mybasket-box').lightbox_me({
					closeSelector : ".btnclose"
				});
			});
			return false;
		});
		
		$(".packaging").change(function(e) {
			if ( $(this).parent().parent().find("td:not(.name)").css("visibility") == "hidden") {
				$(this).next().addClass("active");
//				$(this).next().text("Díszcsomagolás (490 Ft)");
				$(this).parent().parent().find("td:not(.name)").css("visibility", "visible");
			} else {
				$(this).next().removeClass("active");
//				$(this).next().text("Díszcsomagolás");
				$(this).parent().parent().find("td:not(.name)").css("visibility", "hidden");
			}
		});
		
		$("#sac").change(function(e) {
			if ($("#sac:checked").val() !== undefined) {
				$(this).parent().css("padding-bottom", "6px");
				$(this).parent().parent().find(".jcarousel-container").show();
			} else {
				$(this).parent().css("padding-bottom", "0");
				$(this).parent().parent().find(".jcarousel-container").hide();
			}
		});
		
		$(".cat-product-list a").mouseover(function(){
			$(this).children().addClass('active');
			$(this).parent().parent().find("img:not(.active)").css('opacity', 0.4);
		});

		$(".cat-product-list a").mouseout(function(){
			$(this).children().removeClass('active');
			$(this).parent().parent().find("img").css('opacity', 1);
		});

		$(".bar-right a").click(function() {
			$(".cservice-box").css("right", ($(window).width() - 978) / 2);
			$(".cservice-box").show();
			return false;
		});

		$(".cservice-box a").click(function() {
			$(".cservice-box").hide();
			return false;
		});

		$("input.search, input.code, input.code-error").each(function() {
			var default_value = this.value;
			$(this).focus(function() {
				if(this.value == default_value) {
					this.value = "";
				}
			});
			$(this).blur(function() {
				if(this.value == "") {
					this.value = default_value;
				}
			});
		});
		
		$("img.info").mouseover(function(e) {
			var pos = $(this).position();
			$(this).parent().parent().find(".tooltip").css("top", pos.top - 10);
			$(this).parent().parent().find(".tooltip").css("left", pos.left + 21);
			$(this).parent().parent().find(".tooltip").show();
		});
		$("img.info").mouseout(function(e) {
			$(this).parent().parent().find(".tooltip").hide();
		});
		
		$(".nav li").mouseover(function(e) {
			showDropDown($(this));
		});
		
		$(".nav li").mouseout(function(e) {
			hideDropDown($(this));
		});
		
		$(".categories li").mouseover(function(e) {
			showCatDropDown($(this));
		});
		
		$(".categories li").mouseout(function(e) {
			hideCatDropDown($(this));
		});
		
		$("#brandSelect").change(function(e) {
			document.location.href = $(this).val();
		});
		
		$("ul.tabbed-menu li").click(function(e) {
			$(".tabbed-menu").children().removeClass("active");
			$(".tabbed-menu").children().children().removeClass("active");
			$(".tabbed-content").hide();
			var tab = "#tab"+$(this).index();
			$(this).addClass("active");
			$(this).children().addClass("active");
			$(tab).show();
			
			return false;
		});
	});

// MAIN JQUERY END //
