/*
Examples:
instead of: <body onload="myfunction()">
use: addEvent(window, 'load', myfunction);

instead of: window.onload = myfunction;
use: addEvent(window, 'load', myfunction);
*/

function addEvent(obj, evType, fn)
	{
		if (obj.addEventListener)
			{
				obj.addEventListener(evType, fn, true);
				return true;
			}
		else if (obj.attachEvent)
			{
				var r = obj.attachEvent("on"+evType, fn);
				return r;
			} 
		else
			{
				return false;
			}
	}

function addEventToId(id, evType, fn)
	{
		addEvent(document.getElementById(id), evType, fn);
	}

function externalLinks()
	{
		//makes any link with rel="external" behave as target="_blank"
		if (!document.getElementsByTagName)
			return;

		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.getAttribute("class") == "popup") )
					{
						anchor.target = "_blank";
						if ( anchor.title == '' || anchor.title == undefined )
							{
								anchor.title = "external link";
							}
					}
			}
	}

	//addEvent(window, 'load', externalLinks);//Add externalLinks() to window.onLoad

function checkAll(boxname)
	{
		var inputs;
		var i;
		var doCheck = true;
		if ( arguments.length > 1 )
			{
				doCheck = arguments[1];
			}

		if (!document.getElementsByTagName)
			return;
	
		inputs = document.getElementsByTagName("input");
		for ( i=0; i < inputs.length; i++ )
			{
				if ( inputs[i].type == 'checkbox' && inputs[i].name == boxname )
					{
						inputs[i].checked = doCheck;
					}
			}
	}

function startClock(pcAction,pnInterval)
	{
		if (pnInterval == "undefined" || pnInterval == 0 || pnInterval == null)
			pnInterval = 1000000
		
		setTimeout(pcAction, pnInterval);
	}
	
	
/*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

function correctPNGs()
	{
		var arVersion = navigator.appVersion.split("MSIE");
		var version = parseFloat(arVersion[1]);

		if ((version >= 5.5) && (document.body.filters)) 
			{
				for(var i=0; i<document.images.length; i++)
					{
						var img = document.images[i];
						var imgName = img.src.toUpperCase();
						if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
							{
								var imgID = (img.id) ? "id='" + img.id + "' " : ""
								var imgClass = (img.className) ? "class='" + img.className + "' " : ""
								var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
								var imgStyle = "display:inline-block;" + img.style.cssText 
								if (img.align == "left") imgStyle = "float:left;" + imgStyle
								if (img.align == "right") imgStyle = "float:right;" + imgStyle
								if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
								var strNewHTML = "<span " + imgID + imgClass + imgTitle
									+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
									+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
									+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
									img.outerHTML = strNewHTML
									i = i-1
      						}
   					}
			}
	}

function bustframe()
	{
		if(top != self) 
			top.location.href=self.location.href
	}
