jQuery(document).ready(function() {
	var bewDone = false;
	$('#mycarousel').jcarousel({scroll:5,animation:'slow'});
	$('#mycarousel_s').jcarousel({scroll:10,animation:'slow'});
	$('.jcarousel-item a:last-child').each(function(){
		var words = $(this).html().split(' ');
		var word1 = words.shift();
		$(this).html(word1 + '<br>' + words.join(' '));
	});
	$('.tx-feedforward-pi1').each(function(){
		if ($(this).height() == 0)
			$(this).parents('.rightBox').hide();
	});
	$('.imglist a').lightBox();
	$('.productsummary-pic-main a').lightBox();
	$('#mysearchbox input.searchbox-sword').focus(function(){if ($(this).attr("value") == "Suche...") $(this).attr("value", "");});
	$('#mysearchbox input.searchbox-sword').blur(function(){if ($(this).attr("value") == "") $(this).attr("value", "Suche...");});
	$('.bew-able span.bew-span').hover(function() {
		if (!bewDone) {
			$(this).prevAll('span').andSelf().css({ 'background-position': '0 -20px', 'cursor': 'pointer' });
			$(this).nextAll('span').css({ 'background-position': '0 0' });
		}
	},function() {
		$(this).prevAll().andSelf().css('background-position', '0 0');
		$('.point').css('background-position', '0 -20px');
		$('.halfpoint').css('background-position', '0 -40px');
	});
	$('.bew-able span.bew-span').click(function() {
		if (!bewDone) {
			$(this).prevAll().andSelf().addClass('point');
			$('.bew-able span').css('cursor', 'default');
			$('.bew-able').removeClass('bew-able');
			bewDone = true;
			var bewertung = 0;
			var detailansichtid = jQuery(this).attr('id').substr(7);
			if ($(this).hasClass('bew-0')) {
				bewertung = 1;
			} else if (jQuery(this).hasClass('bew-1')) {
				bewertung = 2;
			} else if (jQuery(this).hasClass('bew-2')) {
				bewertung = 3;
			} else if (jQuery(this).hasClass('bew-3')) {
				bewertung = 4;
			} else if (jQuery(this).hasClass('bew-4')) {
				bewertung = 5;
			}
			var bewurl = 'http://www.tablet-info.de/fileadmin/templates/tabletinfo/tablet-detailansicht-bewertung.php?id='+detailansichtid+'&b='+bewertung;
			if (bewertung > 0) {
				jQuery.ajax({
					type: 'GET',
					url: bewurl,
					dataType: 'text',
					success: function(msg, textStatus) {
						$('.bew-tiny').html(msg);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						$('.bew-tiny').html('Fehler: '+textStatus);
					}
				});
			}
		}
	});
	$('.slider-bewpreisleistung').tipTip({
		content: 'Unsere Preis-Leistungs-Bewertung', 
		defaultPosition: 'top'
	});
	
	$('table.sortable tr:even').css('background-color', '#efefef');
	$('table.sortable').tablesorter();
	$('table.sortable').bind('sortEnd',function(){
		$('table.sortable tr:even').css('background-color', '#efefef');
		$('table.sortable tr:odd').css('background-color', 'white');
	});
});
