addLoadEvent(externalLinks);


function reload()
{
	if(event.shiftKey) 
		top.mainframe.location="/.admin/index.php?xdir=/";
}

function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
			oldonload();
			func();
		}
	}
}

function externalLinks() 
{
	if (!document.getElementsByTagName) 
		return; 
	// to do: check case sensitivity... of a and A
	var anchors = document.getElementsByTagName("a");
	var fn = "";
	for (var i=0; i< anchors.length; i++) 
	{ 
		var anchor = anchors[i];
		if (anchor.getAttribute("href"))
		{
			if (anchor.getAttribute("mode") == "menu")
				anchor.target = "menuframe";
			else
			if (anchor.getAttribute("mode") == "main")
				anchor.target = "mainframe";
		} 
	}
	top.meteo.location.href ="http://btn.meteomedia.ca/weatherbuttons/template1.php?placeCode=CAQC0441&containerWidth=250&celsiusF=C";
}

function parseUri(sourceUri)
{
	var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
	// Wow... don't touch this! 
	var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
	var uri = {};
	
	for(var i = 0; i < 10; i++)
	{
		uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
	}
	
	if(uri.directoryPath.length > 0)
	{
		uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
	}
    
	return uri;
}
