function toggleSelects(isVisible){

	for(i=0; i < document.forms.length; i++){
	
		for(j=0; j < document.forms[i].elements.length; j++){
		
			if(document.forms[i].elements[j].type.indexOf('select-one') != -1)
				setVisibility(document.forms[i].elements[j], isVisible)	
		}
	}
}

function toggleMultiSelects(isVisible){

	if (s_isMultiSelectsEnabled == true && isVisible == true)
		return
		
	for(i=0; i < document.forms.length; i++){
	
		for(j=0; j < document.forms[i].elements.length; j++){
			
			if(document.forms[i].elements[j].type.indexOf('select-multiple') != -1){
				setVisibility(document.forms[i].elements[j], isVisible)
					
			}			
		}	
	}	
	s_isMultiSelectsEnabled = isVisible
}

function initBrowserFlags(){

	if (document.images){
		s_isCSS = (document.body && document.body.style) ? true : false
		s_isW3C = (s_isCSS && document.getElementById) ? true : false
		s_isIE4 = (s_isCSS && document.all) ? true : false
		s_isNN4 = (document.layers) ? true : false
		s_isNN6 = (navigator.product == 'Gecko') ? true : false
	}
}

function changeBgColor(obj, hoverColor) {
	
	if(obj){
	
		if(s_isNN4){
			obj.bgColor = hoverColor
		}
		else if (s_isCSS){
			obj.backgroundColor = hoverColor
		}
	}
}

function getObject(objectName) { 
 
	var obj
  
	if(document.getElementById){
		obj = document.getElementById(objectName)
	}
	else if(document.all){
		obj = document.all(objectName)
	}
	else if(seekLayer){
		obj = seekLayer(document, objectName)
	}
	return obj
}

function setVisibility(obj, isVisible){
	
	if (!obj)
		return
		
	if (isVisible) {
	
		if (!s_isNN4)
			obj.style.visibility = 'visible'
		else
			obj.visibility = 'visible'
	}
	else {
		if (!s_isNN4)
			obj.style.visibility = 'hidden'
		else
			obj.visibility = 'hidden'
	}
}

function queryString(key)
{
	var value = null;
	
	for (var i=0; i < queryString.keys.length; i++)
	{
		if (queryString.keys[i].toUpperCase() == key.toUpperCase())
		{
			value = unescape(queryString.values[i])
			break;
		}
	}
	return value;
}

function parseQuerystring(query)
{
	var pairs = query.split("&")
		
	for (var i=0; i<pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=')
		if (pos >= 0)
		{
			//alert('branch2')
			
			var argname = pairs[i].substring(0, pos)
			var value = pairs[i].substring(pos + 1)
			queryString.keys[queryString.keys.length] = argname
			queryString.values[queryString.values.length] = value	
		}
	}
}

function getQuerystringValue(url, paramName){
	
	var pairs = url.split("&")
	
	for (var i=0; i<pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=')
		
		if (pos >= 0) {
			var argname = pairs[i].substring(0, pos)
			
			if(argname.toUpperCase() == paramName.toUpperCase()){
				var value = pairs[i].substring(pos + 1)
				return value
			}
		}
	}
}

function moveToMouse(e, el, yScrollTop, xScrollLeft)
{

	// Moves an element to the position of the mouse
	xPos = getPointerX(e);
	yPos = getPointerY(e);
	
	if(xPos > 160)
	{
	}
	
	move(el, (yPos + yScrollTop), (xPos + xScrollLeft));
}

function getPointerX(e)
{
	return (e != '' ? e.pageX:getRealLeftByObj(window.event.srcElement));
}

function getPointerY(e)
{
	return (e != '' ? e.pageY:getRealTopByObj(window.event.srcElement));
}

function getRealTopByObj()
{
	yPos = 0;
	if(thisObj)
	{
		yPos = thisObj.offsetTop;
		tempEl = thisObj.offsetParent;
		while(tempEl != null)
		{
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
	}
	//return event.clientY + document.documentElement.scrollTop; // true yPos mouse event
	return yPos;
}

function getRealLeftByObj()
{
	xPos = 0;
	if(thisObj)
	{
		xPos = thisObj.offsetLeft;
		tempEl = thisObj.offsetParent;
		while(tempEl != null)
		{
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
	}
	//return event.clientX + document.documentElement.scrollLeft; // true xPos mouse event
	return xPos;
}

function move(el, top, left)
{
	el.style.top =  top + "px";
	el.style.left = left + "px";
}

function setLocation(obj, x, y){

	if(obj){
		
		if(s_isCSS){
			
			var units = (typeof obj.left == 'string') ? 'px' : 0
			
			obj.left = x + units
			obj.top = y + units
			
			alert(obj.left)
		}		
	}
}

function OpenWindow(strURL, strAttributes)
{
	window.open(strURL, "", strAttributes, "")
}

function openWindow(strURL, strAttributes)
{
	window.open(strURL, "", strAttributes, "")
}

function keywordSearch() {
	var frm
		
	frm = document.search
	frm.method = 'GET'
	
	if (frm.keyword.value != ''){
		frm.submit()
	}
	else {
		alert('Please type in a few words that describe what you are looking for.')
		frm.keyword.focus()
	}
}

function archiveSearch() {
	var frm
		
	frm = document.search1
	frm.method = 'GET'
	
	if (frm.qu.value != ''){
		frm.submit()
	}
	else {
		alert('Please type in a few words that describe what you are looking for.')
		frm.keyword.focus()
	}
}

function swapClass(nameObject, className){

	var obj
	
	obj = getObject(nameObject)
	
	if (obj)	
		obj.className = className
}

function getParentTag(obj, tagName, numChecks){

	if (!obj) {
		return false;
	}
			
	for(var i = 0; i < numChecks; i++) {
		
		obj	= obj.parentNode;
		
		if (!obj) {
			return false;
		}
		
		if (obj.tagName == tagName) {
			return obj;
		}
	}	
}

function getChildTag(obj, tagName, numChecks){

	if (!obj) {
		return false;
  }
  
	for (var i=0; i<numChecks; i++) {
	  
		obj	= obj.firstChild;
		
		if (obj && obj.nodeType == 3) {
		  obj = obj.nextSibling;
		}
		
		if (obj && obj.tagName == "IMG" || obj && obj.tagName == "BR"  || obj && obj.tagName == "HR") {
			obj = obj.nextSibling;
		}
		
		if (!obj) {
			return false;
		}
		
		if (obj.tagName == tagName) {
			return obj;
		}
	}	
}

function stripAlphaChars(txt){
		
	var chr
	var txtNew = ''

	if (!txt)
		return
			
	for (var i=0; i<txt.length; i++){
	
		chr = txt.substring(i, i + 1)
				
		if (chr >= 0 && chr <= 9)
			txtNew += chr	
	}
	return txtNew
}
function openfile(openWindow, filename, targetName){
		
	openWindow = window.open(filename, targetName)
	openWindow.focus();
}

function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function findObj(n, d) { //v4.0
  var p,i,x;  
  
  if(!d) {
    d = document;
  }
  
  if (((p = n.indexOf("?")) > 0) && parent.frames.length) {
    try {
      d = parent.frames[n.substring(p+1)].document; 
      n = n.substring(0,p);
    }
    catch (e) {
      //pass
    }
  }
  
  if (!(x = d[n]) && d.all) {
    x = d.all[n]; 
  }
  
  for (i = 0;!x && i < d.forms.length; i++) {
    x = d.forms[i][n];
  }
  
  for (i = 0;!x && d.layers && i < d.layers.length; i++) {
    x = findObj(n, d.layers[i].document);
  }
  
  if (!x && document.getElementById) { 
    x = document.getElementById(n); 
    return x;
  }
}

function createXMLHttpRequest()
{
	try
	{
		return new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
	}
	try
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e)
	{
	}
	try
	{
		return new XMLHttpRequest();
	}
	catch(e)
	{
	}
	return null;
}
