$(document).ready(function(){
		
	

	// External Links
	$('a[rel="external"]').click( function() {
		window.open( jQuery(this).attr('href') );
	    return false;
	});

	// Contact form
	$("#validation-form").validationEngine();

	$("#validation-form input[title]").click(function(){
		
		var savedVal;
		savedVal = $(this).attr("title");
		
		if($(this).attr("title") == $(this).attr("value")) {
			$(this).attr("value", "");
		}
		$(this).blur(function(){
			if($(this).attr("value") == "") {
				$(this).attr("value", savedVal);
			}
		});

	});


	// PRODUCT PAGE: images
	$("a.group").fancybox({
		titlePosition: 'over',
		overlayColor: '#000000',
		padding: 5,		
		overlayOpacity: 0.8
	
	});
	
	// CREDITS
	$("a#cl").fancybox({
		height: 650
	});
	
	// CREDITS
	$("a#c2").fancybox({
		height: 650
	}); 	

	// IE7 fix
	$(".notclick").click(function() {
		return false;
	});
	
	$(".product a").click(function(){
		window.location = $(this).attr("href");
		return false;
	});

	// ISSUU Catalogues
	$(".issuu").fancybox({
		'width' : '75%',
		'height' : '75%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
			'overlayOpacity' : 0.7,
			'overlayColor' : '#000',			
		'type' : 'iframe',
		'titleShow': false
	});

	// SPOTS
	$(".spot, .ytvideo").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'overlayOpacity' : 0.7,
			'overlayColor' : '#000',				
			'width'			: 720,
			'height'		: 433,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});


	// => MAIN MENU on & off
	$("div#navigation ul ul").css("display","none");
	$("div#navigation ul li.current ul").css("display","block");
	
	if($("ul.collection_items > li.current").length != 0){
		var myClass = $("ul.collection_items > li.current").attr("class");
		myClass = myClass.replace("current ","");
		myClass = myClass.replace("first ","");
		myClass = myClass.replace("last ","");
		myClass = myClass.replace(" ","");
		//alert(myClass);
		
		$("ul.collection_items > li.current").prevAll("li.type." + myClass).css("text-decoration","underline");
		$("ul.collection_items > li.current").prevAll("li.type." + myClass).css("color","#D31145");
		$("ul.collection_items > li.current").prevAll("li.type." + myClass).css("background-image","url(/themes/zucchi/images/classtype-on.gif)");
	}

	
	
	// => HOVER Subcategories Items List	
	$("ul.subcategories > li").hover(
		function(){
			$(this).children("a").css("background","none");
			$(this).children("a").children("span").css("color","#FFFFFF");
		},
		function(){
			$(this).children("a").css("background","#FFFFFF");
			$(this).children("a").children("span").css("color","#4D555B");
		}
	);

	// => HOVER Subcategories Items List	
	$(".collectionbox > a").hover(
		function(){
			$(this).css("background","none");
			$(this).children("span").css("color","#FFFFFF");
		},
		function(){
			$(this).css("background","#FFFFFF");
			$(this).children("span").css("color","#4D555B");
		}
	);
	
	// => HOVER Subcategories Items List	
	$(".collectionbox.catalogue").hover(
		function(){
			$(this).css("background","none");
			$(this).children().find(".title").css("color","#FFFFFF");
			$(this).children().find(".subtitle").css("color","#FFFFFF");			
			$(this).children(".browse_catalogue").show();
		},
		function(){
			$(this).css("background","#FFFFFF");
			$(this).children().find(".title").css("color","#4D555B");	
			$(this).children().find(".subtitle").css("color","#4D555B");				
			$(this).children(".browse_catalogue").hide();			
		}
	);	

	// => HOVER Group PDF	
	$("#group_pdf > a").hover(
		function(){
			$(this).css("background","none");
			$(this).children("span").css("color","#FFFFFF");
		},
		function(){
			$(this).css("background","#FFFFFF");
			$(this).children("span").css("color","#D31145");
		}
	);
	
	/* var timeClicked = 0;
	$('#slideBody').click(function() {
		
		$('.body').slideToggle(500, function() {});
	  	
		timeClicked++;
		
		if((timeClicked % 2) == 0) {
			$("a#slideBody img").attr("src","/themes/zucchi/images/slidedown.jpg");
		} else {
			$("a#slideBody img").attr("src","/themes/zucchi/images/slideup.jpg");
		}

		//return false;
		
	}); */

});
