//funtions to open up the current sub navigation
function showCurrentSection(crtPage)
{        
    var objCurrentSection = document.getElementById(crtPage);        
    if (objCurrentSection != null)
    {
        objCurrentSection.style.display = "block";                    
        objCurrentSection.parentNode.childNodes[0].className = "sub_navShow";
        if (objCurrentSection.parentNode.parentNode.nodeName == "UL")
            showSection(objCurrentSection.parentNode.parentNode); 
      
    }
}

function showSection(objSection)
{  
    objSection.style.display = "block";
    objSection.parentNode.childNodes[0].className = "sub_navShow";    
    if (objSection.parentNode.parentNode != null && objSection.parentNode.parentNode.nodeName == "UL")
        showSection(objSection.parentNode.parentNode);
 
}

//function extraxt the page name to highlight the current page anchor on the left navigation
function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}
function setMenu(openUl,anchorId)
{
	document.getElementById(anchorId).className = "current";
	var openIds = openUl.split('|');
	for(var i=0; i< openIds.length; i++)
	{
	   if(document.getElementById(openIds[i]) !=null)
	   {
	     document.getElementById(openIds[i]).className = "sub_navShow";
	   }
	}
}
function setActiveMenu(arr, crtPage)
{

	showCurrentSection(crtPage+'link');
	for(var i=0; i < arr.length; i++)
	{	
		if(extractPageName(arr[i].href) == crtPage)
		{
		    arr[i].className = "current";
			arr[i].parentNode.className = "current";
			
			if(document.getElementById(crtPage) != null)
			{
			   	document.getElementById(crtPage).className = "sub_navShow";			    
			}				
		}		
	
	}	
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("left_nav")!=null) 
		setActiveMenu(document.getElementById("left_nav").getElementsByTagName("a"), extractPageName(hrefString));
}
function search()
	{
	 var searchText = document.getElementById('txtSearch').value;
	 window.location="/Promarc/Search/Results.aspx?k="+searchText+"&s=All%20Sites";	
	}	

function searchFocus()
{
	Page_ValidationActive=false;
		var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById('btnSearch');
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
}
