$(function(){
	
	$('#Date').DatePicker({
		format:'d.m.Y',
		date: $('#Date').val(),
		current: $('#Date').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#Date').DatePickerSetDate($('#Date').val(), true);
		},
		onChange: function(formated, dates){
			$('#Date').val(formated);
			$('#Date').DatePickerHide();
		}
	});

	//swap input value
	swapValue = [];
	$('.swap').each(function(i){
		swapValue[i] = $(this).val();
		$(this).focus(function(){
		  if ($(this).val() == swapValue[i]) {
		  	$(this).val('');
		  }
		  $(this).addClass('focus');
		}).blur(function(){
		  if ($.trim($(this).val()) == "") {
		  	$(this).val(swapValue[i]);
				$(this).removeClass('focus');
		  }
		});
	});
	//drop down nav 	
	var config = {    
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 200,  // number = milliseconds for onMouseOver polling interval    
		over: doOpen,   // function = onMouseOver callback (REQUIRED)    
		timeout: 200,   // number = milliseconds delay before onMouseOut    
		out: doClose    // function = onMouseOut callback (REQUIRED)    
	};             	
	function doOpen() {
		$('a:first',this).addClass('hover');
		$('ul:first',this).css('visibility', 'visible');
	}              	
	function doClose() {
		$('a:first',this).removeClass('hover');
		$('ul:first',this).css('visibility', 'hidden');
	}              	
	$('#nav li').hoverIntent(config);
	
	//home slider
	$('#slider').cycle({
		activePagerClass: 'active',		
		pager: '#slider-nav',
		timeout: 5000
	});
	
	//product detail zoom 
	$(".product-detail .cloud-zoom-gallery").click(function(){    		
    $(".product-detail .image a.fancybox").attr('href', $(this).attr('href'));
    return false;
	});
	$(".fancybox").fancybox({
		'titleShow'     : false,
		'padding'				:	2
	});  
	
	//product detail carousel
	$('.product-detail .carousel').jcarousel({
  	scroll: 4
  }); 
  
  //callback fancybox iframe
  $(".callback-iframe").fancybox({
  	'autoDimensions': false,
		'titleShow'     : false,
		'padding'				:	2,
		'type'					: 'iframe',
		'width'					: 590,
		'height'				: 725
	});
	
	$(".mb").fancybox({
		'titleShow'     : false,
		'type'					: 'iframe',
		'padding'				:	2,
		'width'					: 440,
		'height'				: 300
	});  
	$(".fancyframe").fancybox({
		'titleShow'     : false,
		'type'					: 'iframe',
		'padding'				:	2,
		'width'					: 540,
		'height'				: 500
	});  

});
