// JavaScript Document
$(document).ready(function() {
		var scrollImageHeight = $('#left-product-images-outer').height();
		var imageCount = scrollImageHeight / 112;
		var imageIncrease = 112;
		var i = 0;
		var id;
		
		

		$("div.scroll-down").click(function(){
			//Make if statement that if top is more less than 0 to animate, if equal or more than do not animate
			if ( (-scrollImageHeight + imageIncrease) < i) { 
				$("#left-product-images-outer").animate({
					top : "-=" + imageIncrease + 'px'
				}, "medium");
				
			i = i - imageIncrease;
			} 
			
	   });
		$("div.scroll-up").click(function(){
			//Make if statement that if top is less than 0 to animate, if equal or more than do not animate
			if (0 > i) { 
				$("#left-product-images-outer").animate({
					top : "+=" + imageIncrease + 'px'
				}, "medium");
				i = i + imageIncrease;
			} 
	   });	
		
		/*$("#product-details-top a.showHide").click(function(){
			id = this.id;
			
			var img = $('#tabimg-'+id.substr(8));
			var src = img.attr('src');
			getDetailsDescription
			$('#'+id).addClass('show');
			$('div.show').removeClass('hide');
			
			$('product-deatils-content');
			
			
			$('div.hide').fadeOut('fast');
			$('div.show').fadeIn('fast');
			$('div.show').addClass('hide');
			$('div.show').removeClass('show');
			
	   });*/
		

});

function showTab(index) {
	$('.product-deatils-content').hide();
	$('#tabdiv-' + index).show();
	
	$('#product-details-top img').each(function() {
		var src = $(this).attr('src');
		
		if(src.substr(src.length-9) == '_over.jpg')
			$(this).attr('src', src.substr(0,src.length-9)+'.jpg');
	});
	
	var src = $('#tabimg-'+index).attr('src');
	if(src.substr(src.length-9) != '_over.jpg')
		$('#tabimg-'+index).attr('src', src.substr(0,src.length-4)+'_over.jpg');
}

function showColour(id) {
	$('.image-thumb-container').hide();
	$('#img-thumbs-'+id).show();
	$('.product-image-main').hide();
	$('#imgmain-'+id+'-0').show();
}

function showImg(id) {
	$('.product-image-main').hide();
	$('#'+id).show();
}

function checkBoxes(form) {
	var errTextEl = document.getElementById('addErrorText');
	var checkedBoxes = 0;

	for(var i=0;i<form.elements.length;i++) {
		var element = form.elements[i];
		if(element.type != "radio")
			continue;
		if(element.checked)
			checkedBoxes++;
	}
	
	var isError = checkedBoxes < 2;
	errTextEl.style.display = isError?'block':'none';
	return !isError;
}

