/**
* Funktioner för Wallstore.se
*/
$(function(){
	$(document).ready(function() {
		
		if( $( 'div.MainAreaCheckout' ).length > 0 ) {
			$( 'body' ).addClass( 'cart' );
		}
							   
		if( $(".BigProductImage").length > 0  ) {
			
			activateFancybox();
				
			$(".BigProductImage a").fancybox({
				'autoScale'		:	false, 
				'titlePosition'	:	'inside',
				'overlayOpacity':	'0.8',
				'overlayShow'	:	true
			});
			$(".ToolBarImageWrapper a:last-child").fancybox({
				'autoScale'		:	false, 
				'titlePosition'	:	'inside',
				'overlayOpacity':	'0.8',
				'overlayShow'	:	true
			});
			
			$(".ProductThumbnailsBody a").click( activateFancybox );
		
		}
		
		if( $('#cinema').length > 0 ) {
			$('#cinema').cycle({ 
				fx:     'fade', 
				speed:  'slow', 
				timeout: 4000
			});
		}
		
		
	});
});

function activateFancybox() {
	$(".BigProductImage a").removeAttr('onclick');
	var $imgSource = $(".BigProductImage a img").attr('src');
	$imgSource = $imgSource.replace("/medium/", "/original/");
	$(".BigProductImage a").attr('href',$imgSource); 	
	
	$(".ToolBarImageWrapper a:last-child").removeAttr('onclick');
	var $imgSource = $(".BigProductImage a img").attr('src');
	$imgSource = $imgSource.replace("/medium/", "/original/");
	$(".ToolBarImageWrapper a:last-child").attr('href',$imgSource); 	
}


