// var topnavlinks = new_array('topnavlink39', 'topnavlink47', 'topnavlink48', 'topnavlink49', 'topnavlink50', 'topnavlink51', 'topnavlink52', 'topnavlink53');
// var topnav_sublinks = new_array('topnav_sublink39', 'topnav_sublink47', 'topnav_sublink48', 'topnav_sublink49', 'topnav_sublink50', 'topnav_sublink51', 'topnav_sublink52', 'topnav_sublink53');

function level1_mOver(idObj,colorObj)
{
	document.getElementById(idObj.id).style.color = colorObj;
	document.getElementById(idObj.id).style.borderBottom = "7px solid " + colorObj;

	// document.getElementById(idObj.id).style.borderBottomStyle = "solid";
	// document.getElementById(idObj.id).style.borderBottomWidth = "7px";
	// document.getElementById(idObj.id).style.borderBottomColor = colorObj;
}

function level1_mOut(idObj,colorObj)
{
	document.getElementById(idObj.id).style.color = colorObj;
	document.getElementById(idObj.id).style.borderStyle = "none";
}


//====================================================================
// Function : level1_display
// Comments : This function creates the div for the level 1 nodes.
// Author   : Gregory Reddin (greddin@gmail.com)
//====================================================================
function level1_display(path, node, strFragRoot, bDisplayRoot)
{
	document.write("\n<!-- DMA Main Top Level-1 Nodes (Start) -->\n");
	document.write("<div id=\"topnavlinks\">\n");
	document.write("<ul>\n");

	this.textColor_a  = '';
	this.textColor_i  = '#00a3e0';

	if (bDisplayRoot)
	{
		// reserved
	}
	else
	{
		// var topnav_sublinks = new Array();

		for (var i = 0 ; i < node.m_subNodes.length ; i++) {

			if (getCustomSectionProperty(node.m_subNodes[i].cp_ShowInMainNav).toLowerCase() == "true") {

				//alert(node.m_subNodes[i].m_label);
				//alert(getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor));

				if (getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor) != "")
				{
					this.textColor_a = getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor);
				}
				else
				{
					this.textColor_a = "#00a3e0";
				}

				document.write("<li><a href=\"" + node.m_subNodes[i].m_href + "\""
					+ "	id=\"topnavlink" + node.m_subNodes[i].m_id + "\""
					+ " target=\"_top\" class=\"\""
					+ " onmouseover=\"level1_mOver(this,'" + this.textColor_a + "');setdefault();stopdelay('topnav_sublink" + node.m_subNodes[i].m_id + "','topnavlink" + node.m_subNodes[i].m_id + "');\""
					+ " onmouseout=\"level1_mOut(this,'" + this.textColor_i + "');delay('topnav_sublink" + node.m_subNodes[i].m_id + "','topnavlink" + node.m_subNodes[i].m_id + "')\">"
					+ node.m_subNodes[i].m_label.toUpperCase() + "</a></li>\n");

			}
	
		}

	}

	document.write("</ul>\n");
	document.write("</div>\n");
	document.write("<!--  DMA Main Top Level-1 Nodes (End) -->\n");
}

//====================================================================
// Function : level2_outer_display
// Comments : This method creates the div tag for the supplied node
//            and all its level 2 children (if appropriate)
// Author   : Gregory Reddin (greddin@gmail.com)
//====================================================================
function level2_outer_display(path, node, strFragRoot) 
{
	document.write("\n<!--  DMA Main Top Level-2 Nodes (Start) -->\n");
	
	for (var i = 0 ; i < node.m_subNodes.length ; i++) {

		if (getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor) != "")
		{
			this.textColor_a = getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor);
		}
		else
		{
			this.textColor_a = "#00a3e0";
		}

		if (node.m_subNodes.length > 0)
		{
			if (hasChildren(node.m_subNodes[i]))
			{
				document.write("<div style=\"visibility:hidden;\" id=\"topnav_sublink" + node.m_subNodes[i].m_id + "\""
						+ " class=\"topnav_dropdown\""
						+ " onmouseover=\"stopdelay('topnav_sublink" + node.m_subNodes[i].m_id + "','topnavlink" + node.m_subNodes[i].m_id + "')\""
						+ " onmouseout=\"delay('topnav_sublink" + node.m_subNodes[i].m_id + "','topnavlink" + node.m_subNodes[i].m_id + "')\">\n");

				document.write("<ul>\n");

				// alert(getCustomSectionProperty(node.m_subNodes[i].cp_MenuTextColor));

				level2_inner_display(path, node.m_subNodes[i], strFragRoot);

				document.write("</ul>\n");	
				document.write("</div>\n");
			}
			
		}
	}

	document.write("<!--  DMA Main Top Level-2 Nodes (End) -->\n");
}

//====================================================================
// Function : level2_inner_display
// Comments : This is a helper function for level1_outer_display.
//            It actually does the inner loop displaying the level 2
//            children for the supplied node.
// Author   : Gregory Reddin (greddin@gmail.com)
//====================================================================
function level2_inner_display(path, node, strFragRoot)
{
	for (var i = 0 ; i < node.m_subNodes.length ; i++) {

		document.write("<li><a href=\"" + node.m_subNodes[i].m_href + "\" style=\"color:" + this.textColor_a + "\">"
					+ node.m_subNodes[i].m_label + "</a></li>\n");
	}
}

//====================================================================
// Function : hasChildren
// Comments : This function returns boolean for the supplied node.
//            Used to determine if a node has any children.
// Author   : Gregory Reddin (greddin@gmail.com)
//====================================================================
function hasChildren(node)
{
	if (node.m_subNodes.length > 0)
	{
		return true;
	}
	else 
	{
		return false;
	}
}

//====================================================================
// Shouldn't have to modify anything beneath this line!
//====================================================================
var myVariable;
var para1;
var para2;

function MM_findObj(n, d) { //v4.01
  var p,i,x;  
	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}

// This function add a new element to array_var. If array_var not null, then the result 
// of the function is inserted into the array.
// Re-coded 
function addTopNavSublink(div_id, div_visibility, array_var) {
	//we get sure that when we concatenate the elements, they are concatenated as strings, not
	//as numbers ... If div_visibility is '', we will consider it to be 'hide'
	var result = div_visibility!=''?(div_id.toString()+'||'+div_visibility.toString()):div_id.toString();
	if (array_var != null) {
		array_var.push(result);
	}
	return result;
}

// Re-coded 
function MM_showHideLayers(arr_var) { 
  var i, theDiv, temp;
  for (i=0; i<arr_var.length; i++) {
  	temp = arr_var[i].split('||'); //in temp[0] we store the div_id, in temp[1] we store it's visibility.
  	if (temp.length == 1) {temp.push('hide');}
	if ((theDiv = MM_findObj(temp[0]))!=null) {
		theDiv.style.visibility = (temp[1]=='show')?'visible':(temp[1]=='hide')?'hidden':temp[1];
	}
  }
}

/*
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_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; 
	}
}
*/

// This function passes it's arguments as a new array -- for creating arrays in a simple way ...
// Re-coded 
function new_array() {
	var result = new Array();
	for (var i=0; i<new_array.arguments.length; i++) {
		result.push(new_array.arguments[i]);
	}
	return result;
}

function setdefault() {
	MM_showHideLayers(topnav_sublinks);
	changelink(topnavlinks);
}

/*
function setdefault() {
	MM_showHideLayers('topnav_sublink1','','hide','topnav_sublink2','','hide','topnav_sublink3','','hide','topnav_sublink4','','hide','topnav_sublink5','','hide','topnav_sublink6','','hide','topnav_sublink7','','hide','topnav_sublink8','','hide','topnav_sublink9','','hide','topnav_sublink10','','hide','topnav_sublink11','','hide','topnav_sublink12','','hide','topnav_sublink13','','hide','topnav_sublink14','','hide','topnav_sublink15','','hide');
	changelink('topnavlink1','','hide','topnavlink2','','hide','topnavlink3','','hide','topnavlink4','','hide','topnavlink5','','hide','topnavlink6','','hide','topnavlink7','','hide','topnavlink8','','hide','topnavlink8','','hide','topnavlink9','','hide','topnavlink10','','hide','topnavlink11','','hide','topnavlink12','','hide','topnavlink13','','hide','topnavlink14','','hide','topnavlink15','','hide');
}
*/

function stopdelay(subnav, topnavlink) {
	MM_showHideLayers(new_array(addTopNavSublink(subnav,'show', null)));
	changelink(new_array(addTopNavSublink(topnavlink,'show', null)));
	window.clearTimeout(myVariable);
}

/*
function stopdelay(subnav, topnavlink) {
	MM_showHideLayers(subnav,'','show')
	changelink(topnavlink,'','show');
	window.clearTimeout(myVariable);
}
*/

function delay(subnav, topnavlink) {
	para1 = subnav;
	para2 = topnavlink;
	myVariable = window.setInterval("hide()", 2000);
}

function hide() {
	MM_showHideLayers(new_array(para1));
	changelink(new_array(para2));
	//document.getElementById(para2).style.borderStyle = "none";
}

/*
function hide() {
	MM_showHideLayers(para1,'','hide');
	changelink(para2,'','hide');
}
*/

// Re-coded 
function changelink(arr_var) {
  var i, theDiv, temp;
  for (i=0; i<arr_var.length; i++) {
  	temp = arr_var[i].split('||'); //in temp[0] we store the div_id, in temp[1] we store it's visibility.
  	if (temp.length == 1) {temp.push('hide');}
	if ((theDiv = MM_findObj(temp[0]))!=null) {
		theDiv.className = (temp[1]=='show')?'topnavihover':(temp[1]=='hide')?'':temp[1];
	}
  }
}

/*
function changelink() {
  var i,p,v,obj,args=changelink.arguments;
  for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_findObj(args[i]))!=null) { 
			v=args[i+2];
			v=(v=='show')?'topnavihover':(v=='hide')?'':v; 
			obj.className=v;
		}
}
*/