//When the page has loaded...
$(document).ready(function() {
	
	//Fix the drop down menu mouse over action for IE 6...
	$('.IE6 #navigation li').mouseenter(function() {
		$('ul', this).css('visibility', 'visible');
	});
	
	//Fix the drop down menu mouse out action for IE 6...
	$('.IE6 #navigation li').mouseleave(function() {
		$('ul', this).css('visibility', 'hidden');
	});
	
	//Start image slideshow...
	$('#slideshow ul').cycle({  
		fx: 'fade', 
		timeout: 8000,
		pause: true,
		pager:  '#slideshow-control-position',
		pagerAnchorBuilder: function(idx, slide) { 
			return '#slideshow-control-position a:eq(' + idx + ')'; 
		}
	});
	
	//Kingdom Buzz rotation
	$('#kingdom-buzz-container').cycle({  
		fx: 'scrollHorz', 
		speed:3000,
		timeout: 8000,
		cleartypeNoBg: true,
		pause: true
	});
	
	//Navigation Left Menu Fix
	$('#navigation ul ul li:last').addClass('navLast');
	
	//Add classes to menu items
	var i = 0;
	$('.menu').find('li').each(function(){
		if(i<10){
			i++;
		}
		else{
			i = 1;
		}
		$(this).addClass('menu-button-' + i);
	});
	
	//Add classes to Kingdom Buzz articles on home page
	var i = 0;
	$('#kingdom-buzz').find('.kingdom-buzz-article').each(function(){
		if(i<2){
			i++;
		}
		else{
			i = 1;
		}
		$(this).addClass('buzz-' + i);
	});	
	
	//Colorbox for forms etc
	$("a[rel='colorbox']").colorbox();
	$(".youtube").colorbox({iframe:true, innerWidth:625, innerHeight:544});
	$(".totm-form").colorbox({width:"500", height:"400", inline:true, href:"#totm-form"});
	$(".potw-form").colorbox({width:"520", height:"400", inline:true, href:"#potw-form"});
	$(".dorm-form").colorbox({width:"500", height:"400", inline:true, href:"#dorm-form"});
	$(".wai-form").colorbox({width:"500", height:"400", inline:true, href:"#wai-form"});
	$(".caption-form").colorbox({width:"500", height:"500", inline:true, href:"#caption-form"});
	$(".spell-form").colorbox({width:"500", height:"500", inline:true, href:"#spell-form"});
	$(".drawing-form").colorbox({width:"500", height:"500", inline:true, href:"#drawing-form"});
	$(".jack-o-lantern").colorbox({width:"500", height:"500", inline:true, href:"#jack-o-lantern"});
	$(".pumpkinblitz").colorbox({width:"500", height:"550", inline:true, href:"#pumpkinblitz"});
	$(".app-form").colorbox({width:"515", height:"600", inline:true, href:"#app-form"});
	$(".pwall-form").colorbox({width:"850", height:"600", inline:true, href:"#pwall-form"});
	$(".backyardsafari-form").colorbox({width:"500", height:"450", inline:true, href:"#backyardsafari-form"});
	$(".bittybay-art-gallery").colorbox({width:"500", height:"500", inline:true, href:"#bittybay-art-gallery"});
	
	//Accordion for help page
	$("#accordion").accordion({ autoHeight: false });
	
});

function launchItem(url, width, height){
	newwindow = window.open(url,'name','height='+height+',width='+width+'');
	if (window.focus) {newwindow.focus()}
	return false;
}
