<!--
$(document).ready(function() {

/* Scripts to control the "Read more" and "Read less" for the news part of
   the home page. */
$("a.read-more").click(function() {
	$(this).parent().siblings().slideDown(600);
	$(this).fadeOut(600);
});

$("a.read-less").click(function() {
	$("p.more").slideUp(600);
	$("a.read-more").slideDown(600);
});
// End news code

/* Need to make the PDFs open in new windows. Ordinarily you could just do
   target="_blank", but I coded in XHTML Strict, and that's not part of the spec. */

$("a.pdf").attr("target","_blank");

/*
$("a.pdf").mouseover(function() {
    pdfLink = this.href;
	$(this).attr("href","#");
});

$("a.pdf").click(function() { 
	window.open(pdfLink,'pdfWindow','toolbar=no,menubar=no,location=no,status=no'); 
	});


$("a.pdf").mouseout(function() {
	$(this).attr("href",pdfLink);
	pdfLink = "";
});
*/
// End new window code

$("ul#list-of-programs li").mousemove(function () { // Mouseover each program
	clearAll();
	
	$("ul#list-of-programs li").removeClass("active");
	$(this).addClass("active");
	
	styleActive();
    });
	
$("ul#list-of-programs li").mouseout(function () { // Mouseout of each program
	$("li.active div.col3 div:first").addClass("ic-active");
	updateLink();
    });

$("li div.col3 div.image-and-caption").mousemove(function () { // Mouseover an app
	$(this).addClass("ic-active");
	updateLink();
    });
	
$("li div.col3 div.image-and-caption").mouseleave(function () { // Mouseout of an app
	$(this).removeClass("ic-active");
	updateLink();
    });

$(document.documentElement).keydown(function (event) {

  if (event.keyCode == 38) { // Up arrow
	clearAll();
	
	$("li.active").prev("li").addClass("active");
	$("li.active").next("li").removeClass("active");
	$("li.active div.col3 div:first").addClass("ic-active");
		
	updateLink();
	styleActive();
	scrollWithPrograms();

  } else if (event.keyCode == 40) { // Down arrow

	clearAll();
	
	$("ul#list-of-programs li.active").next("li").addClass("active");
	$("ul#list-of-programs li.active").prev("li").removeClass("active");
	$("li.active div.col3 div:first").addClass("ic-active");
	
	updateLink();
	styleActive();
	scrollWithPrograms();
	
  } else if (event.keyCode == 37) { // Left arrow
	if ($("li.active div.col3 div").length == 1) {
	
	} else if ($("li.active div.col3 div:first").is(".ic-active")) {
	$("li.active div.col3 div:last").addClass("ic-active");
	$("li.active div.col3 div:first").removeClass("ic-active");
	} else {
	$("div.ic-active").prev("div").addClass("ic-active");
	$("div.ic-active").next("div").removeClass("ic-active");
	} ;
	updateLink();
	
  } else if (event.keyCode == 39) { // Right arrow	
	if ($("li.active div.col3 div").length == 1) {
	
	} else if ($("li.active div.col3 div:last").is(".ic-active")) {
	$("li.active div.col3 div:first").addClass("ic-active");
	$("li.active div.col3 div:last").removeClass("ic-active");
	} else {
	$("div.ic-active").next("div").addClass("ic-active");
	$("div.ic-active").prev("div").removeClass("ic-active");
	} ;
	updateLink();
	
  } else if (event.keyCode == 13 && applink != undefined) { // Carriage return	
	window.open(applink);
  } 
});

// Script that activates the logos at the bottom
$("#holding li a").hover(
  function () {

    holdingTip = $(this).next(".holdingtip").html();			
		$("#holding-caption-wrapper").show();
	    $("#holding-caption").html(holdingTip);
		$("#holding-arrow").show();

		
	bodyWidth = $("body").width();

	holdingPos = $(this).parent().offset();
	holdingWidth = $(this).parent().width();
	holdingCenter = parseInt(holdingWidth / 2);

	captionHeight = $("#holding-caption-wrapper").height();
	captionWidth = $("#holding-caption-wrapper").width();
	captionCenter = parseInt(captionWidth / 2);

//alert(holdingPos.left + holdingCenter - 8);

	if (holdingPos.left + holdingCenter + captionCenter > bodyWidth) {
	//$("#holding-caption-wrapper").offset({ top: holdingPos.top - captionHeight - 10, left: holdingPos.left + holdingWidth - captionWidth + 15 });
	captionRight = (bodyWidth - (holdingPos.left + holdingWidth))/6;
	$("#holding-caption-wrapper").offset({ top: holdingPos.top - captionHeight - 10, left: bodyWidth - captionRight - captionWidth});
	} else {
	//$("#holding-caption-wrapper").offset({ top: holdingPos.top - captionHeight - 10, left: holdingPos.left - 15 });
	$("#holding-caption-wrapper").offset({ top: holdingPos.top - captionHeight - 10, left: holdingPos.left + holdingCenter - captionCenter });
	}

	$('#holding-arrow').offset({top: holdingPos.top-12, left: holdingPos.left + holdingCenter - 8});
  }, 
  function () {
   $('#holding-caption-wrapper').hide();
   $('#holding-arrow').hide();
  }
);

$(".pfooter,#second-background,#list-of-programs,.contact-info,#main-nav").mouseover(function() {
	$('#holding-caption-wrapper').hide();
	$('#holding-arrow').hide();
});

// Script that activates the main menu subnavigation

/*$("#main-menu li").mouseover( function() {
	rollOverTimerId = 0;
	element = $(this);
	
	rollOverTimerId = setTimeout( function () {
		$(element).children("ul").slideDown(250, function(){
		$(element).closest("li").siblings().children("ul").slideUp(250);
     });
	},500);
	
	$(element).mouseleave( function () {
	clearTimeout ( rollOverTimerId );	
	});
});

$("#main-content-content").mouseout( function() {
	window.setTimeout( function () {
		$("#main-menu li").children("ul").slideUp(1000);
	},200);
});*/


// Script for making the <a names> active

// Get the full url - like mysitecom/index.htm#home
var full_url = document.location.href;

// Splits the URL and stores the part we need
var parts = full_url.split("#");
var trgt = parts[1];

// If an anchor existed in the URL, then clear the default active item and replace it with the appropriate one based on the sub link that was clicked.
if (trgt != undefined) {
	clearAll();
	$("ul#list-of-programs li").removeClass("active");
	$("a[name='"+trgt+"']").closest("li").addClass("active");
	styleActive();
}

$("#main-menu li ul li a").click( function () {

window.setTimeout(function() {
	var full_url = document.location.href;	
	var parts = full_url.split("#");
	var trgt = parts[1];
	
	clearAll();
	$("ul#list-of-programs li").removeClass("active");
	$("a[name='"+trgt+"']").closest("li").addClass("active");
	styleActive();
}, 50);

});

});

-->
