$(document).ready(function() {	

	setupZoom();

	$('#tabs').tabs();
	
	$('a.hydralok').css({'cursor':'default'}).click(function(){ return false; });

	$('a.download').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	$('a.lang').click(function(){
		
	
		lang = $(this).attr('rel');
		
		if (lang == 'french') {
			message = false;
			//message = 'Nous traduisons actuellement les pages en Français sur notre nouveau site web. Pendant ce temps, nous vous invitons aux pages correspondantes sur notre ancien site ici.';
		} else if (lang == 'spanish') {
			message = 'Estamos traduciendo las páginas de nuestro sitio web en Castellaño. Mientras tanto, revisa nuestro sitio web anitguo aquí.';
		} else {
			message = false;
			//message = 'We are currently updating the translated pages on our new website. In the mean time we will transfer you to the relevant language on our old website.';
		}	
		
		if (message) {
			alert(message);
		} else {
			return true;
		}
			
		window.open($(this).attr('href'));
		return false;
	});

	$('.productGallery .thumbs img').hover(function(){
		
		image = $(this).parent().attr('href');
		//alert($(this).parent().parent().parent().html());
		$(this).parent().parent().parent().find('.mainImage a').attr('href', image);
		$(this).parent().parent().parent().find('.mainImage a img').attr('src', image);
		
		
	},function(){});


	//Get the height of the first item
	$('#mask').css({'height':$('#panel-1').height()});	
	
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div').width($('#mask').width());
	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();
		
		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');
		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 600);		
		
		//Discard the link default behavior
		return false;
	});
});
