window.onload = function () {
    var container = $('div.sliderGallery');
    var ul = $('ul', container);
    var itemsWidth = ul.innerWidth() - container.outerWidth();

	if(itemsWidth > 0) {
		$('.slider', container).slider({
				min: 0,
				max: itemsWidth,
				//handle: '.handle',
				stop: function (event, ui) {
					//ul.animate({'left' : ui.value * -1}, 555);
				},
				slide: function (event, ui) {
					ul.css('left', ui.value * -1);
				}
			});
		} else {
			$('#sliderimage').hide();
		}
	}


$(document).ready(function() {
	$('#header-flash').flash({
		swf: jQueryBaseHrefWithoutPrefix+'/application/resources/flash/homeBanner.swf',
		width: 965,
		height: 235
	});

	$('#header-flash').flash({
		swf: jQueryBaseHrefWithoutPrefix+'/application/resources/flash/homeBanner.swf',
		width: 965,
		height: 235
	});

	$('.fancybox, .media').fancybox();
	
	$(".fancybox-youtube").click(function() {
		$.fancybox({
				'padding'		: 0,
				'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;
	});

	// The "what's in your water" fancybox
	$('.fancybox-wiyw').fancybox({
		width: 650,
		height: 446
	});

	//track download
	$('.track-product-download').click(function(){
		_gaq.push(['_trackEvent', 'Products', 'Download', $(this).attr('title')]);
	});
	$('.track-product-image').click(function(){
		_gaq.push(['_trackEvent', 'Products', 'Image', $(this).attr('title')]);
	});
	$('.track-product-image-first').click(function(){
		_gaq.push(['_trackEvent', 'Products', 'Image - first', $(this).attr('title')]);
	});
});

