var cart = 0;

$(document).ready(function(){
	
	$(window)._scrollable();
	
	// blocks height fixes
	
	if( $(".block-first").length > 0 ) {
		$(".block-first").each(function(k,v){						
			//align specific blocks			
			var image = Math.ceil( Math.max( jQuery(".product-image",$(this)).height() , jQuery(".product-image",$(this).next()).height() ) );
			jQuery(".product-image",$(this)).height(image);
			jQuery(".product-image",$(this).next()).height(image);
						
			var info = Math.ceil( Math.max( jQuery(".product-info",$(this)).height() , jQuery(".product-info",$(this).next()).height() ) );
			jQuery(".product-info",$(this)).height(info);
			jQuery(".product-info",$(this).next()).height(info);
						
			var height = Math.ceil( Math.max( jQuery(".block-content",$(this)).height() , jQuery(".block-content",$(this).next()).height() ) );			
			jQuery(".block-content",$(this)).height(height);
			jQuery(".block-content",$(this).next()).height(height);
			
		});
	}
	
	
	// ie :last-child fixes
	if( $.browser.msie ) {
		$(".product-list td:last-child").css({'border-right':'none'});
	}
	
	// buttons text shadow
	if( $(".button").length > 0 && $.browser.msie ) {
		$(".button").each(function(k,v){
			$(v).children("span").textShadow()
		});
	}
	
	// submit button click
	/*
	$(".submit a")
		.click(function(){
			$( "#"+$(this).attr("rel")+" form" ).submit();
			return false;
		});
	*/
	// add to cart button click
	/*
	$(".product-buy .button")
		.click(function(){
			cart = cart+1;
			$("#menu-cart cite").show();
			$("#menu-cart cite").text("("+cart.toString()+")");
			alert('kvieciam: handleAddToCart');						
			return false;
		});
	*/
	// product gallery
	/*
	if( $(".product-gallery a").length > 0 ) {		
		$(".product-gallery a").click(function(){
			var src = $(this).attr('rel');
			$(".product-gallery a").removeClass('act');
			$(this).addClass('act');
			$(".product-gallery div img").attr('src', src );			
			return false;
		});
	}
	*/
	
	// product details
	if( $(".product-details").length > 0 ) {
		$(".details-navigation a").click(function(){
			var $this = $(this);
			$(".product-details-list .active").removeClass("active").hide();
			$(".details-navigation a").removeClass("active");
			$this.addClass("active");			
			$("#"+$this.attr("rel")).addClass("active").show();			
			return false;
		});
	}
	
	// Cufon
	Cufon.replace('h1, h2',{fontFamily: 'Myriad Pro'});
	Cufon.now();
	
});
