$(document).ready(function () {
	
	/*Add Border to the first Pic*/
	$('.overviewImage:first').addClass("active");
	
	/* show overlay */
	$('.overviewImage > img').after('<img class="overlayPng" src="fileadmin/template/css/img/product_zommer.gif" />');

	/* hide data on load */
	$('.overviewImage .dataBox').css({display: 'none'});
	
	/* show box on load */
	//$('.product:last').after('<div class="productDetails"></div>');
	$('#productDetails').append('<img src="'+$('.overviewImage:first > img').attr('alt')+'" />');
	$('#productDetails > img').attr({ alt: ""+$('.overviewImage:first > img').attr('title')+"" });
	$('#productDetails > img').after($('.overviewImage:first').children('.dataBox').html());
	if ( $.browser.version != "6.0" )
		$('#productDetails').after('<img class="overlayPng2" src="fileadmin/template/css/img/product_zommer.gif" alt="'+$('.overviewImage:first > img').attr('title')+'" />');
	
	
	$('.overviewImage').click(function () {
		
		/* change thumbnail borders */
		$('.overviewImage').removeClass('active');
		$(this).addClass('active');

		/* replace detail pic */
		$('#productDetails > img').attr({ src: ""+$(this).children('img:first').attr('alt')+"", alt: ""+$(this).children('img:first').attr('title')+""});
		$('.overlayPng2').attr({ alt: ""+$(this).children('img:first').attr('title')+""});
		/* replace data text */
		$('#productDetails .dataBox').html(''+$(this).children('.dataBox').text()+'');
		$('#productDetails h3').remove();
		$('#productDetails p').remove();
		$('#productDetails > img').after($(this).children('.dataBox').html());		
	});

	if ( $.browser.version != "6.0" ) {
		$('#productDetails > img').lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.6,
			imageLoading:			'fileadmin/template/css/img/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'fileadmin/template/css/img/lightbox-btn-prev.gif',		// (string) Path and the name of the prev button image
			imageBtnNext:			'fileadmin/template/css/img/lightbox-btn-next.gif',		// (string) Path and the name of the next button image
			imageBtnClose:			'fileadmin/template/css/img/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:			'fileadmin/template/css/img/lightbox-blank.gif'
		});
	
		$('.overlayPng2').lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.6,
			imageLoading:			'fileadmin/template/css/img/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'fileadmin/template/css/img/lightbox-btn-prev.gif',		// (string) Path and the name of the prev button image
			imageBtnNext:			'fileadmin/template/css/img/lightbox-btn-next.gif',		// (string) Path and the name of the next button image
			imageBtnClose:			'fileadmin/template/css/img/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:			'fileadmin/template/css/img/lightbox-blank.gif'
		});
	}

});
