/*
***********************************************************
Title:			main.js
Author: 		J. Jackson, JPL
Created: 		12.19.2008
Modified: 		06.23.2009 TFogie
                07.15.2009 KLefever
***********************************************************
*/

$(document).ready(function(){
  $('ul#main_nav').superfish(); // initialize horizontal menu
  $("ul#main_nav ul").append("<span></span>"); // creates & appends span to each sub nav list
  $('input#ctl00_search_input').focus(function() { $(this).select() }); // highlight search value on focus

  // open external links in a new browser
  $('a[rel=external]').attr('target','_blank');  
  
  // attach events for timeline
  $('#tl_map area').click( function() { switchTL($(this).attr('href')) });
});


function SelectAllChk(tableID, checkboxList) {
    var table = document.getElementById(tableID);
    var td = table.getElementsByTagName("td");
    var j = 1;
    if (checkboxList == false)
        j = 0;
    for (var i = j; i < td.length; i++) {
        var chk = td[i].getElementsByTagName("input")[0];
        if (chk != null) {
            if (chk.type == "checkbox") {
                chk.checked = true;
            }
        }
    }
}

function UnSelectAllChk(tableID, checkboxList) {
    var table = document.getElementById(tableID);
    var td = table.getElementsByTagName("td");
    var j = 1;
    if (checkboxList == false)
        j = 0;
    for (var i = j; i < td.length; i++) {
        var chk = td[i].getElementsByTagName("input")[0];
        if (chk != null) {
            if (chk.type == "checkbox") {
                chk.checked = false;
            }
        }
    }
}

function switchTL(id) {
	$('.timeline').fadeOut('slow', function() { $(this).removeClass('show') })
	window.setTimeout('$("'+id+'").fadeIn("slow")', 1000);



}
