

set_delivery_radiobutton = function(obj_id) {
	$('#delivery_address_id' + obj_id).attr('checked', true);
}


var last_incomment_vote = 0;
var votestar_id = '';
$(document).ready(function(){
	
	$('#kommentare-tab').tabs();
	
	if($.browser.msie == true) {
		if(parseInt($.browser.version) <= 7) {
			$('#top-navi li')
			.mouseover(function() {
				$(this).addClass('is-hover');
			})
			.mouseout(function() {
				$(this).removeClass('is-hover');
			});
		}
		if(parseInt($.browser.version) >= 9) {
			$('#kommentare-tab *').css('font-family', '"Trebuchet MS", Arial, Helvetica, sans-serif');
		}
	}
	
	
	/* $('#top-navi li')
	.mouseover(function() {
		$(this).addClass('is-hover');
	})
	.mouseout(function() {
		$(this).removeClass('is-hover');
	}); */
	
	
	
	$('#slideshow').c2pslider({
		'thumbs_enable': false,
		'animation_step_speed': 6000,
		'animation_speed': 600,
		'autoplay': true,
		'fullsize_fitting_images': false,
		'thumbs_fitting_images': false
	});
	
	$('.dks-slider, #themenwelten').c2pslider({
		'autoplay': false,
		'fullsize_fitting_images': false,
		'thumbs_fitting_images': false
	});
	
	$('#dks-image-galery').c2pslider({
		'autoplay': false,
		'fullsize_fitting_images': false,
		'thumbs_fitting_images': false
	});
	
	$('#slideshow .c2p-fullsize-a').click(function() {
		return false;
	});
	
	/* if($('#select-product-id').length == 1) {
		var product_id = $('#select-product-id').val();
		if(parseInt(products_in_basket[product_id]) == 1) {
			$('amount-row .current-amount').val(products_basket_amount[product_id]);
			console.log('setze korrekte Menge');
		} else {
			$('amount-row .current-amount').val(1);
		}
	} */
	
	
	
	$('#select-product-id').change(function() {
		
		// alert($(this).val());
		var product_id = $(this).val();
		
		
		$('#display-price').html(products_prices_gross[product_id]);
		$('.product-number').html(products_numbers[product_id]);
		
		// console.log(products_in_basket[product_id]);
		// products_basket_amount
		
		if(parseInt(products_in_basket[product_id]) == 1) {
			$('.amount-row .current-amount').val(products_basket_amount[product_id]);
			// $('.inputfields .submitbutton').removeClass('inbasket0');
			// $('.inputfields .submitbutton').addClass('inbasket1');
			// console.log('Menge ändern' + $('.inputfields .submitbutton').length);
		} else {
			$('.amount-row .current-amount').val(1);
			// $('.inputfields .submitbutton').removeClass('inbasket1');
			// $('.inputfields .submitbutton').addClass('inbasket0');
			// console.log('In den Warenkorb' + $('.inputfields .submitbutton').length);
		}
	
	});
	
	
	$('#shipping-costs')
	.mouseover(function() {
		$('#shipping-costs-bubble').show();
	})
	.mouseout(function() {
		$('#shipping-costs-bubble').hide();
	});
	
	
	// Speichern des letzten eingetragenen Votes
	last_incomment_vote = $('#incomment-vote').val();
	$('#incomment-vote-area a').each(function() {
		$(this)
		.mouseover(function() {
			votestar_id = '#vote-star' + ($(this).index() + 1);
			$('#incomment-vote-area').css('background-image', 'url(' + $(votestar_id).attr('src') + ')');
		})
		.click(function() {
			$('#incomment-vote').val($(this).index() + 1);
			last_incomment_vote = ($(this).index() + 1);
			return false;
		});
	});
	
	$('#incomment-vote-area').mouseout(function() {
		if(!last_incomment_vote) {
			last_incomment_vote = 0;
		}
		votestar_id = '#vote-star' + last_incomment_vote;
		$('#incomment-vote-area').css('background-image', 'url(' + $(votestar_id).attr('src') + ')');
	});
	
	// Toggle Effekt der Aufmacher-Elemente
	$('#kt-toggle-lead-element')
	.data('source_height', $('#kt-toggle-lead-element').height())
	.height($('#kt-toggle-lead-element .lead-introduction').height() + 'px');
	
	$('.product-lead-document .lead-doc-more')
	.click(function() {
		$(this).hide();
		$('#kt-toggle-lead-element').height($('#kt-toggle-lead-element').data('source_height'));
		$('.product-lead-document .lead-doc-less').css('display', 'inline');
		return false;
	});
		
	$('.product-lead-document .lead-doc-less')
	.click(function() {
		$(this).hide();
		$('#kt-toggle-lead-element').height($('#kt-toggle-lead-element .lead-introduction').height() + 'px');
		$('.product-lead-document .lead-doc-more').css('display', 'inline');
		return false;
	});
});

