//preload images
/*var imgDir="/images/";

if (document.images) { 
	var imgObjs=[];
	var iurls=new Array("nav/aboutOver.gif","nav/exploreOver.gif","nav/helpOver.gif","nav/whatWeDoOver.gif"); 
	for(var i=0; i<iurls.length; i++) { 
		imgObjs[i]=new Image(); 
		imgObjs[i].src = imgDir+iurls[i];
	}
}*/
function showNewsPromoTab(p_tabId){
	var tabNames = new Array("news", "speeches");
	$("#newsPromoMask").animate({ scrollTop: 0 }, "fast")
	for (i=0; i<tabNames.length; ++i) {
		var tab = $("#" + tabNames[i]+"Tab");
		var content = $("#" + tabNames[i]+"Content");
		tab.removeClass("on");
		tab.addClass(p_tabId == tabNames[i] ? "on" : "");
		content.css('display', p_tabId == tabNames[i] ? "block" : "none");
	}
	sizeMaskedContent(p_tabId)
	return false;
}
function sizeMaskedContent(p_id){
	if(p_id == undefined) p_id="news";
	$("#newsPromoContentHolder").css('height',$("#" + p_id + "Content").height());
	return false;
}
function swapImg(p_id,p_src){
	$("#" + p_id).attr('src', imgDir+p_src);
	return false;
}
function closeEmailForm(){ 
	$('#emailBorder').fadeOut("normal"); 
	$('#shareLink').attr('src','/images/icons/share.gif'); 
}
function openEmailForm(){ 		
	$("#sharePage")[0].reset();	
	$('#emailThanks').css("display","none");
	$('#emailForm').css("display","block");		
	$('#emailBorder').fadeIn("normal");
	$('#shareLink').attr('src','/images/icons/share_on.gif'); 
//	$('#shareLink').css("display","none");
//	$('#shareLinkOn').css("display","block");
}
function emailOpener(){ 
		if($('#emailBorder').css('display') == 'none') 
			openEmailForm(); 
		else 
			closeEmailForm(); 		
}

function emailSend(){
	$('#emailForm').css("display","none"); 
	$('#emailThanks').css("display","block");
}

function resetField(){
	this.value='';
}

function printPage(){ window.print(); }

function resizeFlash(target, height, width){
	$('#'+target).css('height',height);
	$('#'+target).css('width',width);
}

function tabChange(tabNumber){
	//resetTabs();
	num= "#tab-" + tabNumber;
	$("div.tabbed-copy").css("display","none");
	$(num).css("display","block");	
}


function makePopups(){
	$("div.makePopup").mouseover(function(){
		showPopup($(this));
	});
	$("div.makePopup").mouseout(function(){
		hidePopup($(this));
	});
}

function showPopup(link){
	var x=  "#" + link.attr('name');
	var y= "#" + link.attr('name') + '-parent';
	var ie= "#" + link.attr('name') + "-iehelp";
	
	var popup = $(x);		
	
	var popupp = $(y);
	var iehelp = $(ie);	

	$(x).css("display","block");		
	$(ie).css("display","block");
	
	var height = popup.attr('offsetHeight');

	var pheight = popupp.attr('offsetHeight');

	if (typeof(pheight) == 'undefined'){
		var nhl = height.toString();
		nhl = nhl -  5;	
		popup.css("margin-top", "-" + height.toString() + "px");		
	}
	else{		
		nh = pheight + height - 30;					
		ieheight = height/8 - 10;		
		iehelp.css("margin-top", "" + ieheight + "px");
	    popup.css("margin-top", "-" + nh + "px");
	}
		

}

function hidePopup(link){
	var x= "#" + link.attr('name');
	var ie= "#" + link.attr('name') + "-iehelp";
	$(x).css("display","none");

}


$(document).ready(function(){
	//sizeMaskedContent("news");

	//$("#grantsTable").tablesorter();	
	//$("#libraryTable").tablesorter();	

	makePopups();
});
var popwin;


