var aTree = new Array();

// JavaScript Document
function postHidden(theForm, url) {
	
	var fLength = document[theForm].elements.length;
	var aEle = [];
	for( var i=0; i<fLength; i++) {
		var el = document[theForm].elements[i];
		aEle[i] = el.name + "=" + el.value;
	}
	
	if(aEle.length > 0 && url) {
		var pars = aEle.join("&");
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars			
			}
		);
	}
	
}

function onMoMo(obj, newClass, bPointer) {
	if(bPointer)
		obj.style.cursor = 'pointer';
	else
		obj.style.cursor = 'default';
	obj.className = newClass;
}

function valiSubmit(lObj,thefrm) {
	var aObj = lObj.split(",");
	var bError = false;
	for(var i=0; i<aObj.length; i++) {
		var fieldname = aObj[i];
		if(document[thefrm][fieldname].value == "") {
			bError = true;
			break;
		}	
	}
	if(bError)
		alert("Please make sure all the required fields are filled in");
	else
		document[thefrm].submit();
}

function showHide(obj) {
	var obj = document.getElementById(obj);
	if(obj.style.display == "none")
		obj.style.display = "block";
	else
		obj.style.display = "none";
}

function changeClass(obj, newClass) {
	var obj = document.getElementById(obj);
	obj.className = newClass;
}

function rollOver(obj, newSrc) {
	var oldSrc = obj.src;
	obj.onmouseout = function() { obj.src = oldSrc; }
	obj.src = newSrc;
}

/* 
Originally Created by: Saul Salvatierra :: http://myarea.com.sapo.pt
with help from Ultimater :: http://ultimiacian.tripod.com  
Modified by Kwaku Otchere
ToolTip
*/
//Note: if doctype is assigned, scrolltop property belongs to documentelement not body!
var theObj = ""; 
//create tooltip
function toolTip(text,me) {
	theObj=me;
	theObj.onmousemove=updatePos;
	document.getElementById('toolTipBox').innerHTML=text;
	document.getElementById('toolTipBox').style.display="block";
	window.onscroll=updatePos;
}
 
//update posiition of tooltip
function updatePos() {
	var ev=arguments[0]?arguments[0]:event;
	var x=ev.clientX;
	var y=ev.clientY;
	var toolTipBox = document.getElementById('toolTipBox');
	diffX=20;
	diffY=0;
	
	//change documentElement to body if doctype not declared!
	//toolTipBox.style.top  = y-2+diffY+document.documentElement.scrollTop + "px";
	var tTop = y-2+diffY+document.documentElement.scrollTop;
	var tLeft = x-2+diffX+document.documentElement.scrollLeft;
	
	var tWidth = getWH("toolTipBox","width");
	var tHeight = getWH("toolTipBox","height");
	
	//if tooltip goes off the right screen, move it to the other side of the cursor
	if( document.documentElement.clientWidth < (tLeft + tWidth) ) {
		tLeft = tLeft -  tWidth - ( 2 * diffX );
	}
	
	//if tooltip goes off the bottom screen, move it to the other side of the cursor
	if( document.documentElement.clientHeight < (tTop + tHeight) ) {
		tTop = tTop -  tHeight;
	}
	
	toolTipBox.style.left = tLeft + "px";
	toolTipBox.style.top = tTop + "px";

	theObj.onmouseout=hideMe;
}
//hide tooltip
function hideMe() {
	document.getElementById('toolTipBox').style.display="none";
}

//get width or height of object
function getWH(eleID, prop)
{
  var w = 0, ele = null;
  // Get a reference to the element object
  if (document.getElementById) {
    ele = document.getElementById(eleID);
  }
  else {
    if (document.all) ele = document.all[eleID];
  } 
  
  var offset = (prop == "width") ? "offsetWidth" : "offsetHeight" ;
  
  if (ele) {
	  
    // Get the element's width
    if (typeof(ele[offset]) != 'undefined') {
      w = ele[offset];
    }
    else if (ele.style) {
      w = parseInt(ele.style[prop]);
    }
  }
  return w;
}
//End Tooltip

function popUpVideo(urlstr, width, height) {
	var lnk_video = 'http://www.arlingtonvirginiausa.com/includes/wmv_video.cfm?video=';
	popUpWindow(lnk_video + urlstr + '&width=' + width + '&height=' + height,width,height);	
}

var popUpWin=0;
function popUpWindow(URLStr, width, height, left, top, props) {
	
	if(!left) left = 100;
	if(!top) top = 100;
	if(!width) width =  200;
	if(!height) height = 200;
	if(!props) props = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes';
	
	if(popUpWin) {
    	if(!popUpWin.closed)
			popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', props + ',width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

