$(document).ready(function() {

	//*
	//Funkcija nodrošina galvenās izvēlnes apakšizvēlnes parādīšanos
	//*
	
	$(".main-menu .submenu").hide();

	$("#menu li").mouseenter(function(){
		 var e = this;
		$(e).addClass('parent');
		$(e).children(".submenu")
			.stop()
			.css({'opacity': '.9', 'z-index': '10'})
			.fadeIn('fast');
	});

	$("#menu li").mouseleave(function(){
		 var e = this;
		$(e).removeClass('parent');
		$(e).children(".submenu")
			.stop()
			.removeClass('active')
			.css({"z-index": "9"})
			.fadeOut('fast');
	});
	
	//*
	//Funkcija nodrošina lielo attēlu nomaiņu sākumlapā
	//*

	var time = 2500;
	var timeShort = 1400;
	var visibility = 1;
	var fadeFunction = "crossfade"
	if ($.browser.msie) { //Ja ir IE
		visibility = .85;
		fadeFunction = "crossfade"
	}
	
	$(".hidden").removeClass('hidden');

	$("#slider").carouFredSel({
		height 				: 288,
		items				: 1,
		circular			: true,
		direction			: "left",
		infinite			: true,
		scroll : {
			fx				: "crossfade",
			easing			: "linear",
			items			: 1,
			duration		: time,
			pauseOnHover	: true,
			onBefore : function(oldItems, newItems) {
				oldItems.find("> div").animate({
					opacity: 0,
					left: '-500px'
				  }, time);
				newItems.find("> div").css({
					opacity: 0,
					left: '-500px'
				  });
				newItems.find("> div").animate({
					opacity: visibility,
					left: '0px'
				  }, time*2);
			}
		},
		pagination :{
			container : "#carousel-pagination",
			onBefore : function(oldItems, newItems) {
				oldItems.find("> div").animate({
					opacity: 0,
					left: '-500px'
				  }, time);
				newItems.find("> div").css({
					opacity: 0,
					left: '-500px'
				  });
				newItems.find("> div").animate({
					opacity: visibility,
					left: '0px'
				  }, time*2);
			}
		},
		next : {
			key				: "right"
		}
	});
	
	
	
	//*
	//Funkcija nodrošina produktu kategoriju slīdēšanu sākumlapā
	//*

	$("#slider-items").carouFredSel({
		height 				: 138,
		items				: 4,
		circular			: true,
		direction			: "left",
		infinite			: true,
		prev				: "#slider-item-prev",
		next				: "#slider-item-next",
		scroll : {
			fx				: "crossfade",
			items			: 4,
			duration		: timeShort,
			pauseOnHover	: true
		}
	});

	
	//*
	//Funkcija nodrošina sponsoru joslas slīdēšanu
	//*

	$("#partner-slider").carouFredSel({
		height 				: 80,
		items				: 6,
		circular			: true,
		direction			: "left",
		infinite			: true,
		scroll : {
			fx				: "crossfade",
			items			: 6,
			duration		: timeShort,
			pauseOnHover	: true
		}
	});	
	
	
	//*
	//Funkcija nodrošina Fancybox bilžu parādīšanos
	//*
	
	$("#sertifikati li a, .list-carousel li a, .full-size-gallery li a, .zoom-in").fancybox({
		padding : 0,
		margin : 40,
		opacity : false,
		modal : false,
		cyclic : false,
		scrolling : 'auto',	// 'auto', 'yes' or 'no'
		width : 560,
		height : 340,
		autoScale : true,
		autoDimensions : true,
		centerOnScroll : false,
		ajax : {},
		swf : { wmode: 'transparent' },
		hideOnOverlayClick : true,
		hideOnContentClick : false,
		overlayShow : true,
		overlayOpacity : 0.3,
		overlayColor : '#000',
		titleShow : true,
		titlePosition : 'outside', // 'float', 'outside', 'inside' or 'over'
		titleFormat : null,
		titleFromAlt : false,
		transitionIn : 'fade', // 'elastic', 'fade' or 'none'
		transitionOut : 'fade', // 'elastic', 'fade' or 'none'
		speedIn : 250,
		speedOut : 350,
		changeSpeed : 200,
		changeFade : 'fast',
		easingIn : 'swing',
		easingOut : 'fade',
		showCloseButton	 : true,
		showNavArrows : true,
		enableEscapeButton : true,
		enableKeyboardNav : true
	});
	
	
	//*
	//Funkcija nodrošina Sertifikātu paslēpšanu/parādīšanu
	//*	
	
	$(".sertifikati-block .button a").click(function(event){
	var e = this;
	event.preventDefault();
	
	$(e).parents('.sertifikati-block')
		.find('.right li.certificate-hidden')
		.toggle(300)
	});
	
	//*
	//Funkcija nodrošina Google kartes palielināšanos
	//*
	$("a.show-map").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false,
		'centerOnScroll': true,
		'width'			: 1000,
		'height'		: 600,
		'type'			: 'iframe'
	});
	
	//*
	//Funkcija nodrošina jautājuma formas parādīšanos produktu lapā
	//*
	
	$("#ask-question").fancybox({
		padding : 0,
		margin : 40,
		opacity : false,
		modal : false,
		cyclic : false,
		scrolling : 'no', // 'auto', 'yes' or 'no'
		width : 560,
		height : 340,
		autoScale : true,
		autoDimensions : true,
		centerOnScroll : false,
		ajax : {},
		swf : { wmode: 'transparent' },
		hideOnOverlayClick : true,
		hideOnContentClick : false,
		overlayShow : true,
		overlayOpacity : 0.2,
		overlayColor : '#000',
		titleShow : false,
		titlePosition : 'outside', // 'float', 'outside', 'inside' or 'over'
		titleFormat : null,
		titleFromAlt : false,
		transitionIn : 'fade', // 'elastic', 'fade' or 'none'
		transitionOut : 'fade', // 'elastic', 'fade' or 'none'
		speedIn : 300,
		speedOut : 400,
		changeSpeed : 300,
		changeFade : 'fast',
		easingIn : 'swing',
		easingOut : 'fade',
		showCloseButton : true,
		showNavArrows : true,
		enableEscapeButton : true,
		enableKeyboardNav : true
	}); 
	
	
});
