//basic browser detection
var isNS6 = (document.getElementById)?true:false;
var isIE5 = (document.getElementById)?true:false;
var isNS4 = (document.layers)?true:false;
var isIE4 = (document.all)?true:false;
var opera = (navigator.userAgent.indexOf("Opera")!=-1)?true:false;

//allow the rollover of images
function imageRollover(action,name,id,rootObject)
{
  //if the rootObject is inumerated, use it, otherwise don't
  srcFile = (arguments.length > 3) ? eval(rootObject+".src") : eval(name+action+".src") ;
  
  if (isIE5 || isNS6 || ie55)
  {
	docObj = document.getElementById(name);
	docObj.src = srcFile;
  }
  else if (isIE4)
  {
    document.images[name].src = srcFile;
  }
  else if (isNS4)
  {
    window.document.eval(id).document.images[name].src = srcFile;
  }
  return true;
}

//Trim whitespace from the begining and end of a string
function trim(strString)
{
	//if the string is empty just return nothing
	if (strString.length > 0)
	{
		//loop over the string until a non-whitespace char is found
		for (i = 0;i < strString.length;i++)
		{
			strChar = strString.charAt(i);
			//if the character at this position is not whitespace
			if (strChar != ' ' && strChar != '\t' && strChar != '\r' && strChar != '\n')
			{
				intStartPos = i;
				break;
			}
			//this is in case the string is all whitespace
			if (i == strString.length-1)
				{ intStartPos = 0; }
		}
	
		//loop over the string backwards until a non-whitespace char is found
		for (i = strString.length-1; i >= 0; i--)
		{
			strChar = strString.charAt(i);
	
			//if the character at this position is not whitespace
			if (strChar != ' ' && strChar != '\t' && strChar != '\r' && strChar != '\n')
			{
				intEndPos = i
				break;
			}
			//This is in case the string is all whitespace
			if (i == 0)
				{ intEndPos = -1; }
		}
	
		//Get the trimmed string and return it to the user
		return strString.substring(intStartPos,intEndPos+1);
	}
	else
	{
		return '';
	}
}

function ShowHideLayers(IDval,type)
{
	//findPos(IDval);

	//netscape 4.x
	if (document.layers)
	{
		if (type == 'visible')
			{ type = "show"; }
		else
			{ type = "hide"; }
		IDval = IDval + 'N';
		document.layers[IDval].visibility = type;
	}
	//ie 4.x or Opera
	else if (document.all && (! document.getElementById || opera))
	{
		IDval = IDval + 'N';
		document.all[IDval].style.visibility = type;
	}
	//everything else (Mozilla, NS 6 and up, ie 5 and up)
	else
	{
		if (type == 'visible')
			{ type = "block"; }
		else
			{ type = "none"; }
		var itm = document.getElementById(IDval);
		itm.style.display = type;
	}
}

var positionX = 0;
var positionY = 15;

function findPos(IDval)
{
	var availableWidth;
	var availableHeight;
	if(document.layers)
		{ availableWidth=innerWidth; } 
	else
		{ availableWidth=document.body.clientWidth; }

	//the 260 is simply a right padding value
	positionX = (availableWidth - 410);

	//netscape 4.x
	if (document.layers)
	{
		IDval = IDval + 'N';
		document.layers[IDval].left = positionX;
		document.layers[IDval].top = positionY;
	}
	//ie 4.x or Opera
	else if (document.all && (! document.getElementById || opera))
	{
		IDval = IDval + 'N';
		document.all[IDval].style.left = positionX;
		document.all[IDval].style.top = positionY;
	}
	//everything else (Mozilla, NS 6 and up, ie 5 and up)
	else
	{
		var itm = document.getElementById(IDval);
		itm.style.left = positionX;
		itm.style.top = positionY;
	}
}

function pdfPopUp(path,pdf)
{
	webPage = (path+pdf);
	w = window.open(webPage,"new","toolbar=no,scrollbars=yes,resizable=yes");
	return false;
}