/**
 * Put in here all custom functions
 * @author Anders 
 */

$(document).ready(function() {
	
	/*
	 * Zebra striping n all tables with class zebra
	 * Define styles in css: "odd"
	 */
	$("table.zebra tbody tr:nth-child(odd)").addClass("odd");
	
	/*
	 * Show/hide
	 */
	$(".showHideContent").hide();
	$(".showHideHeader").click(function() {
		//alert("clicked");
		//find next showHideContent div
		var $showHideContent = $(this).next("div.showHideContent");
		if($showHideContent.is(":hidden")) {
			$showHideContent.slideDown(500);	
		} else {
			$showHideContent.slideUp(500);
		}
		
	});
	
	/*
	 * Add a confirmation dialogue to all links with class 'confirm'.
	 * Define dialogue text in attribute 'rel'.
	 */
	$("a.confirm").livequery("click",function() {
		var confirmtext = $(this).attr("rel");
		var confirmhref = $(this).attr("href");
		function confirmcallback(v,m,f) {
			if(v==true) {
				window.location = confirmhref;
			} 	
		}
		var confirmed = $.prompt(confirmtext,{ buttons: { OK: true, Exit: false }, callback: confirmcallback });
		
		return false;
	});
	
	$("a.prompt").click(function() {
		var prompthref = $(this).attr("href");
		$.get(prompthref, function(data){
			$.prompt('<div id="jqi-container">' + data + '</div>');
		});

		return false;
	});
	
	/*
	 * Masking time input (jquery.maskedinput-1.2.2.js)
	 */
	$('input.timeHMMSS').mask("9:59:59");
	$('input.timeHHMMSS').mask("99:59:59");
	$('input.timeMMSS').mask("59:59");
	$('input.timeMMSSDD').mask("59:59.99");
	$('input.dateDD-MM-YYYY').mask("39-19-2999");
	$('input.dateDD-MM-YYYY_HH-II').mask("39-19-2999 29:59");
	$('input.year').mask("2999");
	
	$("#message").fadeOut(7500);
	
	
});


