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

(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};
})(jQuery);

$(document).ready(function() {
	var pictureRightAlign = {
		'float' : 'right'
      }
      
	
	$('#content img[align="right"]').css(pictureRightAlign);
	
	$('.valign').vAlign();
	/*
	 * 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'});
			});						
			
		}
	});
});



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();
}


