jQuery.extend({
	postJSON: function(url, data, callback) {
		$.post(url, data, callback, 'json');
	}	
}); 

function capitalize(string) {
	return string.charAt(0).toUpperCase() + string.substr(1).toLowerCase();
}

function formatPrice(finalPrice) {
	finalPrice = finalPrice.toString();
	
	if(finalPrice.indexOf('.') > -1) {
		var split = finalPrice.split('.');
		
		if(split[1].length < 2) {
			finalPrice = finalPrice + '0';	 
		}			
	}	else {
		finalPrice = finalPrice + '.00';
	}
	
	return finalPrice;			
}


function editSlideshow() {
	$('.anythingControls').hide();
	
	
	$('.anythingSlider').mouseenter(function() {
		$('.anythingControls').show();
		$('span.arrow').show();
	});
	
	$('.anythingSlider').mouseleave(function() {
		$('.anythingControls').hide();
		$('span.arrow').hide();
	});
}

$(document).ready(function() {
	$('.details .tabNav li, .details .images #video, .details a#rating').click(function() {
		$('.details .tabNav .active').removeClass('active');
		$('.details .tabs .active').removeClass('active');
		$('.details .tabNav #' + $(this).attr('id')).addClass('active');
		$('.details .tabs .' + $(this).attr('id')).addClass('active');
	});
	
	$('#header .nav li').hover(
		function() {
			$('a:not(.dropdown a)', this).addClass('hover');
			$('img', this).each(function(i) {
				$(this).attr('src', $(this).attr('src').replace(/.gif/g, '_hl.gif'));
			});
		},
		
		function() {
			$('a:not(.dropdown a)', this).removeClass('hover');
			$('img', this).each(function(i) {
				$(this).attr('src', $(this).attr('src').replace(/_hl.gif/g, '.gif'));

			});
		}
	);
	
	$('.basket .contents .item .totalprice img').click(function() {
		var id = $(this).attr('class');
		$('#' + id).val(1);
		//$('form[name="basket"]').submit();
	});

	$('#filter input[type="checkbox"]').click(function() {
		$('#filter').submit();
	});
});


function aktivateLoader() {
	$('#mask').addClass('on');
	$('#filterWait').show();
}
