// Browser Detection

//isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;

//NS4 = (document.layers) ? true : false;
NS4 = is_layers;

//IEmac = ((document.all)&&(isMac)) ? true : false;
IEmac = (is_ie && is_mac) ? true : false;

//IE4plus = (document.all) ? true : false;
IE4plus = is_all;

//IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE4 = is_ie4;

//IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE5 = is_ie5;

ver4 = (NS4 || IE4plus) ? true : false;

//NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
NS6 = is_nav6up;

// ------------------------------------------------------------------------------------------------------------------------------------

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();

function SafeAddOnload(f)
{
/*
    20060509, NHEAD--this is supposedly the most browser compatible method, just here for reference:

    var oldonload = window.onload;
    
    if (typeof window.onload != 'function')
    {
        window.onload = f;
    }
    else
    {
        window.onload = function() {
            oldonload();
            f();
        }
    }    
*/
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}	
	else if  (window.onload)
	{
	    if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
	{
		window.onload = f;
	}
}

function SafeOnload()
{    
	for (var i=0;i<gSafeOnload.length;i++)	    
		gSafeOnload[i]();
}

// ------------------------------------------------------------------------------------------------------------------------------------

// Body onresize utility (supports multiple onresize functions)
var gSafeOnresize = new Array();
function SafeAddOnresize(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onresize
	{
		window.onresize = SafeOnresize;
		gSafeOnresize[gSafeOnresize.length] = f;
	}
	else if  (window.onresize)
	{
		if (window.onresize != SafeOnresize)
		{
			gSafeOnresize[0] = window.onresize;
			window.onresize = SafeOnresize;
		}		
		gSafeOnresize[gSafeOnresize.length] = f;
	}
	else
	{
		window.onresize = f;
	}
}

function SafeOnresize()
{
	for (var i=0;i<gSafeOnresize.length;i++)
		gSafeOnresize[i]();		
}

// ------------------------------------------------------------------------------------------------------------------------------------

// Form onsubmit utility (supports multiple onsubmit functions)
var gSafeOnsubmit = new Array();
function SafeAddOnsubmit(f, sFormName, iFormNumber)
{
    if (sFormName == '')
    {
        oForm = window.document.forms[iFormNumber];
    }
    else
    {
        oForm = window.document.getElementById(sFormName);
    }    
    
	if (IEmac && IE4)  // IE 4.5 blows out on testing oForm.onsubmit
	{
		oForm.onsubmit = SafeOnsubmit;
		gSafeOnsubmit[gSafeOnsubmit.length] = f;
	}
	else if  (oForm.onsubmit)
	{
		if (oForm.onsubmit != SafeOnsubmit)
		{
			gSafeOnsubmit[0] = oForm.onsubmit;
			oForm.onsubmit = SafeOnsubmit;
		}		
		gSafeOnsubmit[gSafeOnsubmit.length] = f;
	}
	else
	{
		oForm.onsubmit = f;
	}
}

function SafeOnsubmit()
{
	for (var i=0;i<gSafeOnsubmit.length;i++)
		gSafeOnsubmit[i]();		
}
