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

$(document).ready(function() {
	/*
	 * Mask inputs
	 */
	$('input.time').mask("29:59");
	$('input.timeHMMSS').mask("9:59:59");
	$('input.date').mask("39/29/2999");
	$('input.date-da').mask("39-29-2999");
	$('input.datetime').mask("2999/29/39 29:59:59");
	
	/*
	 * Zebra striping n all tables with class zebra
	 * Define styles in css: "odd"
	 */
	$("table.zebra tbody tr:nth-child(odd)").addClass("odd");
	
	$(".showhideContent").hide();
	$(".showhideHeader").css({'background' : 'url("/images/elements/slider_down.png") 0px 0px no-repeat', 'background-color':'#ddd', 'padding-left' : '20px'});
	$(".showhideHeader").hover(
      function () {
		$(this).css('background-color','#bbb');
      }, 
      function () {
		$(this).css('background-color','#ddd');
      }
    );
	
	$('.showhideHeader').click(function() {
		var $slidebutton = $(this);
		var $slidepanel = $(this).next('.showhideContent').eq(0);
		if($slidepanel.is(':hidden')) {
			$slidebutton.css({'background' : 'url("/images/elements/slider_up.png") 0px 0px no-repeat', 'background-color':'#ddd', 'padding-left' : '20px'});
			$slidepanel.slideDown("slow");
		} else {
			$slidepanel.slideUp("slow",function() {
				$slidebutton.css({'background' : 'url("/images/elements/slider_down.png") 0px 0px no-repeat', 'background-color':'#ddd', 'padding-left' : '20px'});
			});						
			
		}
	});
	
	$("a.confirm").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, Afbryd: false }, callback: confirmcallback });
		
		return false;
	});
	
	
	
});



function addWait($element,size,where) {
	/*
	 * Comment
	 */
	$("#wait").remove();
	if(where=="after") {
		$element.after('<img src="/images/elements/wait_'+size+'.gif" alt="" id="wait" />');
	} else if(where=="replace") {
		$element.html('<img src="/images/elements/wait_'+size+'.gif" alt="" id="wait" />');
	}
}

function removeWait() {
	$("#wait").remove();
}


