// Tab script written by QDigital technology services. Copyright 2007. Redistribution prohibited.
// Begin code

// The main function. It hides all other tabs but the one whose ID is specified in the function call
function show_tab (container_div, selected_id) {
var tab_list = document.getElementById(container_div).getElementsByTagName("div"); // Get a list of child divs within our main tab div
for (var i=0; i<tab_list.length; i++) { // Begin looping through each div (tab) we found, set it to display nothing
tab_list[i].style.display = "none"; // Hide the tab
}
document.getElementById(selected_id).style.display="block"; // Show the tab whose ID we were passed in the function arguments
setCookie(container_div, selected_id); // Set the persitant cookie value for this tab
document.getElementById(container_div).focus(); // Blur our cursor from the link we clicked
}

// This is the initialize function. Since all tabs are hidden by default, this function is needed to display the default or previously selected tab
function tab_initialize (container_div, default_id) {
var saved_tab = getCookie(container_div); // Grab our cookie value
if (saved_tab == "") { // Check to see if we have a value saved
saved_tab = default_id; // If not, use the default ID
}
show_tab(container_div, saved_tab); // Display the tab
}

// Genric get cookie function
function getCookie (Name) {
var re = new RegExp(Name+"=[^;]+", "i"); // Check to see if we have a value for the name we were passed
if (document.cookie.match(re)) { // Commence check
return document.cookie.match(re)[0].split("=")[1]; // Split name and value and return it
}
return ""; // Otherwise return nothing
}

// Genric set cookie function
function setCookie (name, value) {
document.cookie = name + "=" + value+";path=/"; // Set our cookie name and value
}