
$(document).ready(function() {

	$('#navigation ul li').mouseenter(function(){
		
		$(this).children('ul').stop(true, true).show();
	}).mouseleave(function(){
		
		$(this).children('ul').stop(true, true)
		.hide();
	});
	
	$("input.focus").live('focus',function () {
        if (this.value == this.defaultValue) {
            this.value = "";
        }
        else {
            this.select();
        }
    });

    $("input.focus").live('blur',function () {
        if ($.trim(this.value) == "") {
            this.value = (this.defaultValue ? this.defaultValue : "");
        }
    });
	
	
	
	
	$("#btnsearch").click(function(){
		if ($("#fldsearch").val() != $("#fldsearch").attr('defaultValue')){			
			$("#form_search").submit();
		}		
		return false;
	});
	
	$("#reload-postalcode").live('click',function(){
		
		$.ajax({
			url: '/ajax.html',
			data: {context: 'Site_Ajax', action: 'reload_postalcode'},
			type: 'POST',
			dataType: 'json',
			success: function(data){
				if (data.status == 'OK') {
					$("#footer-main").html(data.html);
				}
			}
		});
				
		return false;
	});
	
	$("#check-postalcode").live('click',function(){
												
		if ($("#postalcode").val() != $("#postalcode").attr('defaultValue')){			
			$('#form_postalcode').ajaxSubmit({
				url: '/ajax.html',
				data: {context: 'Site_Ajax', action: 'search_postalcode', view: '_postal_code'},
				method: 'POST',
				dataType: 'json',
				success: function(data){
					if (data.status == 'OK') {
						$("#footer-main").html(data.html);
						
						return false;
					}else if(data.html){
						alert(data.html);
					}
				}
			});
		}		
		return false;
	});
	
	
	
	
	
	$(".zoom").fancybox({
		'titleShow'			: true,
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
		
	});
	
	$("a[rel=zoom_group]").fancybox({
		'titleShow'			: true,
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return title + '<br>Image ' +  (currentIndex + 1) + ' / ' + currentArray.length;
		}
	});

	
	$(".zoom-gallery").fancybox({
		'width'				: 680,
		'height'			: 560,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'

	});
	
	$(".zoom-slideshow").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 799,
		'height'			: 550,
		'type'				: 'iframe',
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$(".zoom-video").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 852,
		'height'			: 496,
		'type'				: 'iframe',
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$(".zoom-mp3").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$(".zoom-promo").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 799,
		'height'			: 600,
		'type'				: 'iframe',
		'scrolling' 		: 'no',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});

	$(".zoom-bloc").fancybox({
		'padding'			: 0,
		'titleShow'			: false,
		'width'				: 799,
		'height'			: 610,
		'type'				: 'iframe',
		'scrolling' 		: 'auto',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000'
	});
	
	$(".zoom-youtube").click(function() {
		$.fancybox({
				
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
	
	$(".youtube").click(function() {
		$.fancybox({
				
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
	
});


