$(function () {
	function track (action) {
		pageTracker._trackEvent('out', action);
	}
	
	$('.banner a').click(function () {
		track('banner');
	});
	
	$('#partner .logo').click(function () {
		track('logo');
	});
	
	$('.besteller').click(function () {
		track('besteller');
	});
	
	
	$('.el2 .col1x4').each(function (i) {
		$(this).find('a').each(function (j) {
			$(this).click(function () {
				if (j == 0) { 
					var row = 'img';
				}
				else {
					var row = j;
				}
				track('packages-'+(i+1)+'-'+row);
			});
		});
	});
	
	$('.col1x4.btn a').each(function (i) {
		$(this).click(function () {
			track('packages-'+(i+1)+'-more');
		});
	});
	
	$('.pricetable tr').each(function (i) {
		$(this).find('td:eq(3) a').click(function () {
			track('table-'+(i+1));
		});
	});
	
	$('.el1 .col1x3').each(function (i) {
		$(this).find('a').each(function (j) {
			$(this).click(function () {
				if (j == 0) { 
					var row = 'img';
				}
				else {
					var row = j;
				}
				track('receiver-'+(i+1)+'-'+row);
			});
		});
	});
	
	$('.col1x3.btn').each(function (i) {
		$(this).find('a').each(function (j) {
			if (j == 0) {
				ty = 'more';
			}
			else
			{
				ty = 'besteller';
			}
						
			$(this).click(function () {
				track('receiver-'+(i+1)+'-'+ty);
			});
		});
	});
	
});

function changepic() {
	var activepic = $('#carousel div:visible');
	if ( activepic.attr('id') != 'skywelt' ) {
		activepic.next().show();
		var picname = activepic.next().attr('id');
		$('#carousel ul a').attr('class', '');
		$('#carousel ul a[rel="' + picname + '"]').attr('class', 'selected');
	} else {
		$('#bundesliga').show();
		$('#carousel ul a').attr('class', '');
		$('#carousel ul a[rel="bundesliga"]').attr('class', 'selected');
	}
	activepic.hide();
}

$(document).ready(function() {
	
	var int = setInterval( function() { changepic(); }, 5000 );

	$('#carousel').mouseover(function() {
		int = clearInterval(int);
	}).mouseout(function() {
		int = setInterval( function() { changepic(); }, 5000 );
	});
	
	$('#carousel ul a').mouseover(function() {
				
		// deslected all links
		$('#carousel ul a').attr('class', '');
		
		// select current link
		$(this).attr("class", "selected");
		
		// hide all images
		$('#carousel div').hide();
		
		// show selected image
		var cat = $(this).attr("rel");
		cat = '#' + cat;
		$(cat).show();
		
	});
});

