// JavaScript Document

// Accordion
j$(function(){
	j$('#myAccordion1').accordion();
});
j$(function(){
	j$('#myAccordion2').accordion();
});
j$(function(){
	j$('#myAccordion3').accordion();
});
// END Accordion

// Contents-Slider
j$(document).ready(function() {	

	//Get the height of the first item
	j$('#mask').css({'height':j$('#panel-1').height()});	
	
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	j$('#panel').width(parseInt(j$('#mask').width() * j$('#panel div.box').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	j$('#panel div.box').width(j$('#mask').width());
	
	//Get all the links with rel as panel
	j$('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = j$(j$(this).attr('href')).height();
		
		//Set class for the selected item
		j$('a[rel=panel]').removeClass('selected');
		j$(this).addClass('selected');
		
		//Resize the height
		//$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		j$('#mask').scrollTo(j$(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});
	
});
// END Contents-Slider

// Activity
// Fade-Action
j$(document).ready(function($) {
	$('a[rel*=facebox]').facebox({
	loading_image : 'loading.gif',
	close_image : 'closelabel.gif'
	})
});

j$(document).ready(function($) {
	// find the div.fade elements and hook the hover event
	$('.fadeThis').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .hover', this);
 
		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(180, 1);
		} else {
			fade.fadeIn(180);
		}
	}, function () {
		var fade = $('> .hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(180, 0);
		} else {
			fade.fadeOut(180);
		}
	});
 
	// get rid of the text
	$('.fadeThis > .hover').empty();
})

j$(document).ready(function($) {
	// find the div.fade elements and hook the hover event
	$('.fadeThisb').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .hoverb', this);
 
		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(180, 1);
		} else {
			fade.fadeIn(180);
		}
	}, function () {
		var fade = $('> .hoverb', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(180, 0);
		} else {
			fade.fadeOut(180);
		}
	});
 
	// get rid of the text
	$('.fadeThisb > .hoverb').empty();
})
// END Fade-Action


// Information
j$(function ($) {
     $(".emergency .delete").click(function(){
         $(this).parents(".emergency").animate({ opacity: "hide" }, "slow");
     });
});
