if(!window.Node){
  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}

function checkNode(node, filter){
  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
  var result = new Array();
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    if(checkNode(children[i], filter)) result[result.length] = children[i];
  }
  return result;
}

function getChildrenByElement(node)
{
  return getChildren(node, "ELEMENT_NODE"); 
}

function getFirstChild(node, filter)
{
  var child;
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++)
  {
    child = children[i];
    if(checkNode(child, filter)) return child;
  }
  return null;
}

function getFirstChildByText(node){
  return getFirstChild(node, "TEXT_NODE");
}

function getNextSibling(node, filter){
  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
    if(checkNode(sibling, filter)) return sibling;
  }
  return null;
}
function getNextSiblingByElement(node){
        return getNextSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;
var firstCall = null;

function showMenu()
{ 
	try
	{
	    if (firstCall)
  		{ var dim = document.getElementById(firstCall+"#");}
  		else {dim=this;}         
  
  		if(activeMenu)
 		{	
    		activeMenu.className = "";
    		getNextSiblingByElement(activeMenu).style.display = "none";	
  		}
  		if(dim == activeMenu)
  		{ 
    		activeMenu = null;
  		} 
  		else
  		{			
			dim.className = "active";
			getNextSiblingByElement(dim).style.display = "block";
    		activeMenu = dim;			
  		}
  		firstCall = null;
  		return false;
	}
	catch (e) { alert("Oops! Technical error 2..."+e.description);}
} 
function start()
{
	try
	{
	//;
	initMenu();
	firstCall = getValue("rf");
	if (firstCall.length == 0) {return;}	
	showMenu();
	}
	catch (e) { alert("Oops! Technical error 3..."+e.description);}
} 

var menus;
function initMenu()
{
  try 
  {
  	var menu, text, a, i;  
  	menus = getChildrenByElement(document.getElementById("menu"));
  	for(i = 1; i <  menus.length; i++)
  	{
   		menu = menus[i];
   	 	text = getFirstChildByText(menu);			
    	a = document.createElement("a");
    	menu.replaceChild(a, text);
    	a.appendChild(text);				
		a.id = menu.id+"#";
    	a.href = "#";
    	a.onclick = showMenu; 
		a.onfocus = function(){ this.blur(); };
		
  	}
  }
  catch (e) { alert("Oops! Technical error 1..."+e.description);}
}

if(document.createElement) { window.onload = start;}

/* ----------------------------------------- mine*/
function getValue(varname)
{
  
  var url = window.location.href; // First, we load the URL into a variable  
  var qparts = url.split("?"); // Next, split the url by the ?  
  if (qparts.length == 1){return "";}// Check that there is a querystring, return "" if not
  var query = qparts[1];// Then find the querystring, everything after the ?  
  var vars = query.split("&");// Split the query string into variables (separates by &s) 
  var value = "";// Initialize the value with "" as default

  
  for (i=0;i<vars.length;i++)// Iterate through vars, checking each one for varname
  {    
    var parts = vars[i].split("=");// Split the variable by =, which splits name and value   
    if (parts[0] == varname) // Check if the correct variable // Load value into variable
    { value = parts[1]; break; }
  }
  return value;  
}







