// JavaScript Document
//**********************************************************************************************************
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

//**********************************************************************************************************
function gotopage(field_in,type)
{
var chosen_location = document.getElementById(field_in).value;
if (chosen_location == '')
	alert('Please choose ' + type);
else
	location.href= 'index.cfm?' +type + '=' + chosen_location;
}

//**********************************************************************************************************
function gotopage2(field_in,type)
{
var selection_value = document.getElementById(field_in).value;
if (selection_value == '')
	alert('Please choose ' + type);
else
	location.href= 'index.cfm?' + selection_value;
}

//**********************************************************************************************************
function divdisplay(divtochange,divlist)
{
var urlselection=getQueryVariable('p');
//var urlitem=getQueryVariable('item');
//var cookiename = urlselection+urlitem;
var cookiename = urlselection;
var testCookie = getCookie(divtochange)
var msg = "";
var nav_list = eval('document.getElementById(\''+divlist+'\').value.split(",")');
if(nav_list.length > 0)
	{
		for (var i=0;i<nav_list.length;i++)
			{
			if (divtochange == nav_list[i])
				{
				var temp = document.getElementById(divtochange).style.display = "block";
				
				}
			else
				{
				var temp = eval('document.getElementById(\'' + nav_list[i] +'\').style.display = "none"');
				}
			}
	}

if(!testCookie)
	{
	setCookie(cookiename,divtochange);
	}
}


//**********************************************************************************************************
function confirmlaunch(msg, page)
{

if(confirm(msg+ "\nClick OK to launch\nor click Cancel to stop."))
	newWindow = window.open(page, "", "width=800,height=600,left=0,top=0,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,alwaysRaised");
}

//**********************************************************************************************************
function start( page)
{
var w = screen.width; // Get the width of the screen
var h = screen.height; // Get the height of the screen
var new_height = 0.75 * h;
var new_width = 0.75 * w;
var new_left = 0.125 * w;
var new_top = 0.125 * h;

if(new_height > 600)
{
	new_height = 600;
	new_top = h / 2 - 300;
}


if (new_width > 800)
{
	new_width = 800;
	new_left = w / 2 - 400;
}
newWindow = window.open(page, "", "width="+new_width+",height="+new_height+",left=" + new_left +",top="+ new_top +",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,alwaysRaised");
}

//**********************************************************************************************************
function load_area()
{

var filename = location.href;
var divtoload = Get_Cookie(filename);

if (divtoload)
	{
	var getwhattodisplay = divtoload.split('=');
	var whattoshow = getwhattodisplay[0].toString();
	
	divtodisplay('section_staffing');
	}
}

//**********************************************************************************************************
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
	{
	var pair = vars[i].split("=");
	if (pair[0] == variable)
		return pair[1];
	}
//alert('Query Variable ' + variable + ' not found');
}

//**********************************************************************************************************
function swap(inclass,inid,mode)
{
//determines class names to use for this set of swaps
var temp_slit = new Array();
temp_split = inclass.split('_');

var standard_class = temp_split[0] + '_default';
var mouseover_class = temp_split[0] + '_mouseover';
var selected_class = temp_split[0] + '_selected';


// if the selected tab is clicked, then do nothing
switch(mode)
	{
	case 'm_over':
		if(inclass != selected_class)
		{
		var divs = getElementsByClass(mouseover_class)
		for(i=0; i <divs.length;i++)
			{
					divs[i].className = standard_class;
			}
		temp = eval('document.getElementById(\''+ inid+ '\').className = mouseover_class');
		}
	  break    
	case 'm_out':
		if(inclass != selected_class)
		{
		var divs = getElementsByClass(mouseover_class)
		for(i=0; i <divs.length;i++)
					divs[i].className = standard_class;
		}
	  break
	case 'clicked':
		if(inclass != selected_class)
		{
		var divs = getElementsByClass(selected_class);
		for(i=0; i <divs.length;i++)
					divs[i].className = standard_class;
		temp = eval('document.getElementById(\''+ inid+ '\').className = selected_class');
		
		}
	  break
	}
}