/* ===========================================================================
 * SCHEDULE THE BEHAVIOURS
 * =========================================================================== 
 */



function initPage()
{
	initLinks();
	initMenu();
}

window.onload = initPage;




function initLinks()
{
	if (!document.getElementsByTagName) 
 		return;
 		
 	var b = document.getElementsByTagName("body");
 	theBody = b[0];
 	if(theBody.className.match("popup"))
 	{
	 	is_popup=true;
 		 window.focus();
	}
 
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) 
 	{
   		var anchor = anchors[i];
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   		{
     		anchor.target = "_blank";
 		}	
     	else if (anchor.className.match("print")) 
     	{
        	anchor.onclick = function() 
        	{
          		printPage();
          		return false;
        	};
    	}
    	else if (anchor.className.match("window")) 
     	{
        	anchor.onclick = function() 
        	{
          		popUp(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("file")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.open(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("close")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.close();
          		return false;
        	};
    	}
 	}
}


function initMenu() 
{
	var nav = document.getElementById("navigation");
	
	if(nav != null)
	{
		var listItems = nav.getElementsByTagName("li");
	
		for (var i=0; i<listItems.length; i++) 
		{
			listItems[i].onmouseover=function() 
			{
				if(this.className == "")
					this.className="hover";
				else
					this.className+=" hover";
			}
			
			listItems[i].onmouseout=function() 
			{
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
				this.className=this.className.replace(new RegExp("hover\\b"), "");
			}
			
			listItems[i].onfocus=function() 
			{
				if(this.className == "")
					this.className="hover";
				else
					this.className+=" hover";
			}
			
			listItems[i].onblur=function() 
			{
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
				this.className=this.className.replace(new RegExp("hover\\b"), "");
			}
		}
	}
}



function printPage() 
{
  if (window.print)
    window.print()
  else
    alert("Sorry, your browser doesn't support this feature. Use the File menu on your browser to select Print.");
}