/* SETUP LOGIN BOX */
animatedcollapse.addDiv('signin', 'fade=1', 'persist=1' );
animatedcollapse.addDiv('signin-back', 'fade=1', 'persist=1' );
animatedcollapse.init();

// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){
	
	var $news = $('#news-ticker');//we'll re use it a lot, so better save it to a var.
	$news.serialScroll({
		items:'div',
		duration:500,
		force:true,
		axis:'y',
		easing:'linear',
		lazy:false,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		interval:0, // yeah! I now added auto-scrolling
		step:1, // scroll 2 news each time
		cycle:false,
		prev:'a.up', // Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'a.down'
	});	

	$('#archive').accordion({
		autoheight: false,
		header:'h2',
		active: false, 
		alwaysOpen: false, 
		animated: 'easeslide'
	});

	 $('#slideshow').serialScroll({
		items:'li',
		prev:'#screen2 a.prev',
		next:'#screen2 a.next',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false, //click on the images to scroll to them
		interval: 0
	});

	$('#adverts').innerfade2({
		speed: 			1000,
		timeout: 		3000,
		type: 			'sequence',
		containerheight: 	'325px',
		slide_timer_on: 	'yes',
		slide_ui_parent: 	'adverts',
		pause_button_id: 	'advert_pause_button',
		slide_nav_id:		'advertNav'
	});
	$.setOptionsButtonEvent();
	
	//$('#page').dropShadow({left: 2, top: 2, blur: 2});
		
	$("#advert_pause_button").click(function() {
		$.pause();
	});
	
	$("#advert_next_button").click(function() {
		$.next();
	});

	$("#advert_prev_button").click(function() {
		$.prev();
	});
	$("#slide_pause_button").click(function() {
		$.pause();
	});
	
	$("#slide_next_button").click(function() {
		$.next();
	});

	$("#slide_prev_button").click(function() {
		$.prev();
	});

	$('#nav ul').css({display: "none"}); // Opera Fix
	$('#nav li').hover(function(){
		$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
})


function insertIntoSlideNav(DOMObjId, i) {
	for (tmp=0; tmp<i ; tmp++ ) {
		navLinks = document.getElementById(DOMObjId);
	
		var navItem = document.createElement('li');
	
		navItem.setAttribute('class',DOMObjId+'-slide_' + tmp);
	
		navLinks.appendChild(navItem);
	}
}


