

$(document).ready(function(){
	
	// Loginbox
//	$(".margin-loginbox-form").hide();
/*
	$(".loginbox-tab").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});
*/	
	$(".loginbox-tab").click(function(){
		$(this).toggleClass("active");
		$(this).next(".margin-loginbox-form").slideToggle("slow,");
		return false;
	});

	// Accordion
	$('.accordion').accordion({
		event: 'click',
		autoHeight: false,
		header: '.header'
	});

	// Scrollbox
	$('.marginscrollboxContent').each(function(i) {
//		var index = 0;
		var totalSize = $(".content-part", this).size() - 1;
		var index = parseInt( Math.random() * ( totalSize +1 ) );

		var wizard = $(this).accordion({
			event: 'click',
			autoHeight: false,
			header: '.header',
			active: index
		});
		if (index == totalSize)
		{
			$("a.next-button", this).addClass("disabled");
		} else {
			$("a.next-button", this).removeClass("disabled");
		}
		if (index == 0)
		{
			$("a.prev-button", this).addClass("disabled");
		} else {
			$("a.prev-button", this).removeClass("disabled");
		}
//		wizard.accordion( 'activate' , index);

		$(this).bind('accordionchange', function(event, ui) {
			index = $(this).find(".header").index ( ui.newHeader[0] );
			if (index == totalSize)
			{
				$("a.next-button", this).addClass("disabled");
			} else {
				$("a.next-button", this).removeClass("disabled");
			}
			if (index == 0)
			{
				$("a.prev-button", this).addClass("disabled");
			} else {
				$("a.prev-button", this).removeClass("disabled");
			}
		});
		$("a.next-button", this).click(function(){
			index = index + 1;
			if (index > totalSize)
			{
				index = totalSize;
			} else {
				wizard.accordion( 'activate' , index);
			}
			return false;
		});
		$("a.prev-button", this).click(function(){
			index = index - 1;
			if (index < 0)
			{
				index = 0;
			} else {
				wizard.accordion( 'activate' , index);
			}
			return false;
		});
	});
	


	// Dropdown menu
	function menuShow() {
		$(this).addClass("hover");
		$('ul', this).slideDown();
	}

	function menuHide() { 
		$(this).removeClass("hover");
		$('ul', this).slideUp();
	}

	$("li.has-children").hoverIntent({
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
		interval: 50,   // number = milliseconds for onMouseOver polling interval
		over: menuShow,     // function = onMouseOver callback (required)
		timeout: 300,   // number = milliseconds delay before onMouseOut
		out: menuHide       // function = onMouseOut callback (required)
	});


     
});



