
$(function() {
	
	/* Lets hide the frontpage items for later use */
	$('#caseImages li:not(:first)').hide();
	$('#caseDesc li:not(:first)').hide();
	
	$('#caseList li:first').addClass('active');
	
	var $caseList = $('#caseList li');
	var $caseImages = $('#caseImages li');
	var $caseDesc = $('#caseDesc li');
	
	$caseList.each(function() {
		$(this).mouseover(function() {
			
			$caseList.removeClass('active');
			$(this).addClass('active');
			
			$class = $(this).attr('class').slice(0, -7);
			
			$caseImages.each(function() {
				if($(this).attr('class') == $class) {
					$(this).fadeIn();
				} else {
					$(this).fadeOut();
				}
			});
			
			$caseDesc.each(function() {
				if($(this).attr('class') == $class) {
					$(this).fadeIn();
				} else {
					$(this).fadeOut();
				}
			});
			
		});
		
	});
	
});


$(function() {
	if ( $('form#brochurer').is(':visible') ) {
		$('form#brochurer').submit(function() {
			
			// check name
			if ( !$('[name="name"]').val() ) {
				$('[name="name"]').css('background-color', '#faa');
				$('[name="name"]').focus();
				alert('Name field must not be empty');
				return false;
			}
			else {
				$('[name="name"]').css('background-color', '#fff');
			}
			
			// check adresse
			if ( !$('[name="adresse"]').val() ) {
				$('[name="adresse"]').css('background-color', '#faa');
				$('[name="adresse"]').focus();
				alert('Adresse field must not be empty');
				return false;
			}
			else {
				$('[name="adresse"]').css('background-color', '#fff');
			}
			
			// check by
			if ( !$('[name="by"]').val() ) {
				$('[name="by"]').css('background-color', '#faa');
				$('[name="by"]').focus();
				alert('By field must not be empty');
				return false;
			}
			else {
				$('[name="by"]').css('background-color', '#fff');
			}
			
			return true;
			
		});
	}
	
});




$(function() {
	if ( $('form#kontakt_kaf').is(':visible') ) {
		$('form#kontakt_kaf').submit(function() {
			
			// check firma
			if ( !$('[name="firma"]').val() ) {
				$('[name="firma"]').css('background-color', '#faa');
				$('[name="firma"]').focus();
				alert('Firma field must not be empty');
				return false;
			}
			else {
				$('[name="firma"]').css('background-color', '#fff');
			}
			
			// check telephon
			if ( !$('[name="telefon"]').val() ) {
				$('[name="telefon"]').css('background-color', '#faa');
				$('[name="telefon"]').focus();
				alert('Telefon field must not be empty');
				return false;
			}
			else {
				$('[name="telefon"]').css('background-color', '#fff');
			}
			
			return true;
			
		});
	}
	
});



$(document).ready(function() { 
	
	$("#tableSort").tablesorter( {sortList: [[3,0]]} ); 
	
	$('#tableSort tr:gt(0)').hover(
		function() {
			$(this).css('background-color', '#ccc');
		},
		function() {
			$(this).css('background-color', '#fff');
		}
	);
	
	
	$('#tableSort th').hover(
			function() {
				$(this).css('cursor', 'pointer');
			},
			function() {
				$(this).css('cursor', 'auto');
			}
		);
		
	
}); 

