// <!--  /////////////////////////////////////////////////////

//---------------- PLATFORM DETECT --------------//

navigator.OS = '';
var platform;
platform = window.navigator.platform.toLowerCase();
if (platform.indexOf('win') != -1) {
      navigator.OS = 'win';
} else if (platform.indexOf('mac') != -1) {
      navigator.OS = 'mac';
}

//---------------- POP-UP WINDOWS ----------------//

// Under contruction alert
function showAlert() {
	alert("This feature is not available");
}


//Popup
function showPopUp(url){
	var w = checkWidth(620);
	var h = checkHeight(425);
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,"popup",features);
}

function showActivity(url){
	var w = checkWidth(630);
	var h = checkHeight(460);
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,"activity",features);
}

//Popup used for glossary
function showGlossary(url) {
	var winName = "GlossaryPopup";
	var properties = "width=300,height=175,scrollbars,resizable";
	var newWindow = window.open(url, winName, properties);
	newWindow.focus();
}


function openCenteredWin(url,name,features) {
	myWindow = window.open(url,name,features);
	if (window.focus) myWindow.focus();
}

function checkHeight(h){
	// windows open smaller on NETSCAPE so make bigger
	if (navigator.appName == 'Netscape'){
		h += 19;
	}
	// windows open smaller on MAC IE so make bigger
	if (navigator.OS == 'mac' && navigator.appName != 'Netscape'){
		h = h + 25;
	}
	return h;
}

function checkWidth(w){
	// windows open smaller on MAC IE so make bigger
	if (navigator.OS == 'mac' && navigator.appName != 'Netscape'){
		w = w + 5;
	}
	return w;
}

function getCenterStage(w,h,buffer){
	if(!buffer) buffer = 0;
	if(window.screen) {
		var s = "";
		var aH = screen.availHeight;
		var aW = screen.availWidth;
		var cY = (aH - h)/2;
		var cX = (aW - w)/2;
		s += ",left=" + ((cX-12) + buffer);
		s += ",top=" + ((cY-50) + buffer);
		return s
	}
}

// expand menu (jquery)
$(document).ready(function()
{
	$("ul.inner").hide();
	$("li.selected > ul.inner").show();
});



// creates and operates tabs
$(document).ready(function()
{	
	$(function () 
	{var tabContainers = $('div.tabs > div.tab_wrapper > div');			
		$('div.tabs ul.tabnav a').click(function () 
		{
			tabContainers.hide().filter(this.hash).show();
			//alert(this.hash);
			$('div.tabs ul.tabnav li').removeClass('active');
			$(this).parent().addClass('active');
			return false;
		}).filter(':first').click();
	});	
});

// creates and operates click/reveal
$(document).ready(function()
{	
	$(function () 
	{
		//if javascript is present, hide overflow 
		//$('div.clickreveal > div.cr_wrapper').css('overflow', 'hidden');
		//hide all divs except the first one
		$('div.clickreveal > div.cr_wrapper > div').hide();
		$('div.clickreveal > div.cr_wrapper > div:first').show();
		
		// when an image is clicked,
		$('div.clickreveal ul a').click(function () 
		{
			//hide all divs, except for the one with the same id 
			$('div.clickreveal > div.cr_wrapper > div').hide().filter(this.hash).show();
			return false;
		})
	});	
});

// creates and operates the other type of click/reveal
$(document).ready(function()
{	
	$(function () 
	{
		//if javascript is present, hide overflow 
		//$('div.clickreveal > div.cr_wrapper').css('overflow', 'hidden');
		//hide all divs except the first one
		$('div.clickreveal2 > div.cr_wrapper > div').hide();
		$('div.clickreveal2 > div.cr_wrapper > div:first').show();
		
		// when an image is clicked,
		$('div.clickreveal2 ul a').click(function () 
		{
			//hide all divs, except for the one with the same id 
			$('div.clickreveal2 > div.cr_wrapper > div').hide().filter(this.hash).show();
			return false;
		})
	});	
});

// for text alternative hide and show
$(document).ready(function()
{
	function textAltPrep (){ 
		// init stuff
		$('.ta_toggle').show();
		$('.ta_toggle').siblings('.ta_content').hide(); 
		// event handlers
		$('.ta_toggle').click(function(){
			$(this).siblings('.ta_content').toggle('slow');		
			return false; 
		});
	}
	textAltPrep();
});

$(document).ready(function(){
	
	//glossary popup - finds class, adds js. if js disabled, then uses target=blank instead
	$('.glossary').click(function() 
	{
		strWSize = 'width=400,height=150';
		var dtNow = new Date();
		var oWin = window.open($(this).attr('href'), 'glossary' + dtNow.getTime(), strWSize + ",resizable=yes,scrollbars=yes,location=no");
		return false;
	});
	
	//glossary popup - finds class, adds js. if js disabled, then uses target=blank instead
	$('.popActivity').click(function() 
	{
		strWSize = 'width=640,height=425';
		var dtNow = new Date();
		var oWin = window.open($(this).attr('href'), 'popup' + dtNow.getTime(), strWSize + ",resizable=yes,scrollbars=yes,location=no");
		return false;
	});

	//for the main glossary link in the header
 	$('.glossaryAll').click(function() 
	{
		strWSize = 'width=690,height=425';
		var dtNow = new Date();
		var oWin = window.open($(this).attr('href'), 'popup' + dtNow.getTime(), strWSize + ",resizable=yes,scrollbars=yes,location=no");
		return false;
	});
	
	//for the rpl, communication tools and resources popups in the header
	$('.metaPop').click(function() 
	{
		strWSize = 'width=725,height=425';
		var dtNow = new Date();
		var oWin = window.open($(this).attr('href'), 'popup' + dtNow.getTime(), strWSize + ",resizable=yes,scrollbars=yes,location=no");
		return false;
	});
	
});