
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_v4	  = false;

if ((navigator.appVersion.indexOf("MSIE 4.") != "-1" && is_ie) || (parseInt(navigator.appVersion) == 4 && is_ns))
{  
	is_v4 = true;
}

function brd_fnSetCoookie(name, value, expires)
{
	if (!expires)
	{
		expires = new Date();
	}
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function brd_fnGetCookie(name)
{
	cookie_name = name + "=";
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length)
	{
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
		{
			var value_end = document.cookie.indexOf (";", value_begin);
			if (value_end == -1)
			{
				value_end = cookie_length;
			}
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
		if (cookie_begin == 0)
		{
			break;
		}
	}
	return null;
}

function brd_fnDeleteCoookie(name)
{
	var expireNow = new Date();
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

// BROWSER FRIENDLY
function brd_fnGetLeftPos(oElement)
{
	var left = oElement.offsetLeft;
	
	while( (oElement = oElement.offsetParent) != null )
	{
		left += oElement.offsetLeft;
	}
	
	return left;
}

// BROWSER FRIENDLY
function brd_fnGetTopPos(oElement)
{
	var top = oElement.offsetTop;
	
	while( (oElement = oElement.offsetParent) != null )
	{
		top += oElement.offsetTop;
	}
	
	return top;
}

// BROWSER FRIENDLY
function brd_fnGetObjectHeight(oElement)
{
	if ( oElement.offsetHeight )
	{
		return( oElement.offsetHeight );
	}
	else
	{
		return( oElement.style.height );
	}
}

// BROWSER FRIENDLY
function brn_fnUnselectable(oElement)
{
	if ( is_ie4 )
	{
		return;
	}
	else if ( typeof(oElement.tagName) != "undefined" )
	{
		if ( oElement.hasChildNodes() )
		{
			for ( var i = 0; i < oElement.childNodes.length; i++ )
			{
				brn_fnUnselectable(oElement.childNodes[i]);
			}
		}
		
		oElement.unselectable = true;
	}
}

// BROWSER FRIENDLY
function hideShow( sID )
{
	var oElement;
	
	oElement = document.getElementById(sID); 
	
	if ( oElement.lastShowID != null )
	{
		if ( oElement.lastShowID == sID )
		{
			oElement.lastShowID = null;
		}
		else
		{
			var hideID = oElement.lastShowID;
			oElement.lastShowID = null;
			hideShow(hideID);
		}
	}
		
	if ( getDisplayValue( sID ) == '' ) 
	{  
		hideElement(sID);
		return(false);
	}
		
	showElement(sID);
	oElement.lastShowID = sID;
	return(false);
}

// BROWSER FRIENDLY
function hideShowBelow( sID, oParent )
{
	var oElement;
	
	oElement = document.getElementById(sID);
	
	var pX = brd_fnGetLeftPos(oParent) + 'px';
	var pY = brd_fnGetTopPos(oParent) + brd_fnGetObjectHeight(oParent) + 'px';
	
	hideShow( sID ); 
	
	oElement.style.left = pX;
	oElement.style.top = pY;
}

// BROWSER FRIENDLY
function showElement( sID )
{
	setDisplayValue( sID, '' );
}

// BROWSER FRIENDLY
function hideElement( sID )
{
	setDisplayValue( sID, 'none' );
}

// BROWSER FRIENDLY
function getDisplayValue( sID )
{
	var oElement = document.getElementById(sID);
	
	if ( oElement )
	{
		if( oElement.style ) 
		{  
			return( oElement.style.display );  // IE
		} 
		else if( oElement.display ) 
		{
			return( oElement.display ); // MOZILLA
		}
	}
	
	return( null );
}

// BROWSER FRIENDLY
function setDisplayValue( sID, sValue )
{
	var oElement = document.getElementById(sID);
	
	if ( oElement )
	{
		if( oElement.style ) 
		{  
			oElement.style.display = sValue;  // IE
		} 
		else if( oElement.display ) 
		{
			oElement.display = sValue; // MOZILLA
		}
	} 
}

// BROWSER FRIENDLY
function preventDoublePosts() 
{
	var oSubmit = document.getElementById('cmdSubmit');
	
	if ( oSubmit ) 
	{
		oSubmit.disabled = true;
		oSubmit.value = "Processing... Please wait...";
	}
	
	return true;	
}

// IE ONLY FRIENDLY
function resizeImage(this_image) 
{
	if (document.all) 
	{
		while (this_image.width > 150) 
		{
			if (this_image.width > this_image.height) this_image.width = this_image.width-10;
			if (this_image.width < this_image.height) this_image.height = this_image.height-10;
		}
			
		while (this_image.height > 250) 
		{
			if (this_image.width > this_image.height) this_image.width = this_image.width-10;
			if (this_image.width < this_image.height) this_image.height = this_image.height-10;
		}
	}				
}	

function popWin(prmLocation, prmWindowName, prmWidth, prmHeight) 
{
	var options = "height=" + prmHeight + ",width=" + prmWidth + ",scrollbars=no";
	
	var aWindow = window.open(prmLocation, prmWindowName, options);
	
	aWindow.focus();
}
