

willow.ready(function($){

	var photo_pause = 0;
	var thisInterval;

	var optionsmenu = {
		direction:"down",
		showL3s:false,
		speed:500
	};

	willow.getMenu("51715|51717|51719|51721|51723|51726",function(data){
		$("#L1").menu(data.menu,optionsmenu);
	});

	
	willow.getMenu("51735|51733|51730",function(data){
		$("#omni").menu(data.menu,optionsmenu);
	});

	var thisCaption = $("#photo_captionrotator").cycle({
		speed:500,
		timeout:0
	});
	
	var thisPhoto = $("#photo_rotator").cycle({
		speed:500,
		timeout:0
	});

	$('#photo_prev').click(function(){
		if(photo_pause == 0){
			clearInterval(thisInterval);
			thisInterval = setInterval(function(){willow.rotateImages(thisPhoto,thisCaption);},4000);
		}
		thisCaption.cycle('prev');
		thisPhoto.cycle('prev');
	});
	
	$('#photo_next').click(function(){
		if(photo_pause == 0){
			clearInterval(thisInterval);
			thisInterval = setInterval(function(){willow.rotateImages(thisPhoto,thisCaption);},4000);
		}
		thisCaption.cycle('next');
		thisPhoto.cycle('next');
	});
	
	$('#photo_PlayPause').click(function(){	
		if(photo_pause == 0){
			photo_pause = 1;
			clearInterval(thisInterval);
			$("#photo_PlayPause a").css('background','url(/images/play_btn.gif)');
			
		}else{
			photo_pause = 0;
			thisInterval = setInterval(function(){willow.rotateImages(thisPhoto,thisCaption);},4000);
			$('#photo_PlayPause a').css('background','url(/images/spacer.gif)');
		}
	});
	

	thisInterval = setInterval(function(){willow.rotateImages(thisPhoto,thisCaption);},4000);
	
	$("#dd_quicklinks .dd_box").hide();
	$("#dd_scores .dd_box").hide();
	$("#dd_calendar .dd_box").show();
	$("#dd_header_calendar").css("background-image","url(/images/home/button_calendar_on_v2.gif)");	
	
	$('#search').pdSearch({showButton:false});
});		

function openMML(consoleid, galleryid, mediaid, mediatype) {
	var pGallery = (galleryid > 0)?'&gallery_id=' + galleryid:'';
	var pMedia = (mediaid > 0)?'&mediatype=' + mediatype +'&mediaid=' + mediaid:'';
	window.open('/podium/MediaLibrary/player/default.aspx?console_id=' + consoleid + pGallery + pMedia + '&browse=yes&recent=yes', '_blank', 'location=no, menubar=no, scrollbar=no, status=no, resizable=no, height=497, width=700');
}
function translatePage(languagePair){
	//This function was modified from a javascript link on the translate.google.com page.
	//var t = ((window.getSelection&&window.getSelection()) ||(document.getSelection&&document.getSelection()) ||(document.selection && document.selection.createRange && document.selection.createRange().text));
	var e = ( document.charset || document.characterSet );
	
	currentURL = "http://www.brooksschool.org/default.asp?nf=1";
	
	//if (t != '') {
	//	location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=' + languagePair + '&tbb=1&ie='+e;
	//}else{
		location.href='http://translate.google.com/translate?u='+escape(currentURL)+'&hl=en&langpair=' + escape(languagePair) + '&tbb=1&ie='+e;
	//};
}

function getQueryVariable(variable) {
	var query = location.search.substring(1);
	//debug(query);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
	return -100;
}

var showNF = getQueryVariable('nf');
var showNF2 = getQueryVariable('langpair');
//alert(showNF);
//hasFlashNEEDED = false;
if(showNF != -100 || showNF2 != -100){
	hasFlashNEEDED = false;
	//alert('showing nf');
}

willow.displaySidebar = function(data){
	//hide all sidebars
	$(".dd_box").hide();
	$("#dd_header_quicklinks").css("background-image","url(/images/home/button_quicklinks_off_v2.gif)");
	$("#dd_header_scores").css("background-image","url(/images/home/button_scores_off_v2.gif)");
	$("#dd_header_calendar").css("background-image","url(/images/home/button_calendar_off_v2.gif)");
	
	//show 1 sidebar
	$("#dd_"+data+" .dd_box").show();
	$("#dd_header_"+data).css("background-image","url(/images/home/button_" + data + "_on_v2.gif)");
}
	
willow.rotateImages = function(photoObj,captionObj){
	photoObj.cycle('next');
	captionObj.cycle('next');
}
	
	
	
	
	
	
	
