//------------------------------------------------------------------------------------------------------------------
//Rollover
//------------------------------------------------------------------------------------------------------------------
function RollOver(strPage, strCampaign) {
    if (document.images)
    {
   	//Main Nav
	homebuttonon = new Image(120,30);
	homebuttonon.src="images/mnuHomeHover.gif";
	homebuttonoff = new Image(120,30);
	homebuttonoff.src="images/mnuHome.gif";
		
	reportsbuttonon = new Image(120,30);
	reportsbuttonon.src="images/mnuReportsHover.gif";
	reportsbuttonoff = new Image(120,30);
	reportsbuttonoff.src="images/mnuReports.gif";
		
	recognisemebuttonon = new Image(120,30);
	recognisemebuttonon.src="images/mnuRecognisemeHover.gif";
	recognisemebuttonoff = new Image(120,30);
	recognisemebuttonoff.src="images/mnuRecogniseme.gif";
		
	infobuttonon = new Image(120,30);
	infobuttonon.src="images/mnuNewsHover.gif";
	infobuttonoff = new Image(120,30);
	infobuttonoff.src="images/mnuNews.gif";
		
	accountbuttonon = new Image(120,30);
	accountbuttonon.src="images/mnuAccountHover.gif";
	accountbuttonoff = new Image(120,30);
	accountbuttonoff.src="images/mnuAccount.gif";
    }
}
 
function lightup(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "on.src");
      document[imgName].src= imgOn;
    }
 }
 
function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "off.src");
      document[imgName].src= imgOff;
    }
 }
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Center the screen
//------------------------------------------------------------------------------------------------------------------
var intContentWidth = 800;	
var intContentHeight = 600;	
var intBrowserWidth = 0; 
var intBrowserHeight = 0;

function PositionGetBrowserSize(){
	if(navigator.userAgent.indexOf("Firefox") != -1) {
		intBrowserWidth = document.body.offsetWidth-19; 
		intBrowserHeight = document.body.clientHeight;
	} else {
		if (navigator.appName=="Netscape"){
			intBrowserWidth = window.innerWidth-19; 
			intBrowserHeight = window.innerHeight;
		}else if (navigator.appName.indexOf("Microsoft")!=-1){
			intBrowserWidth = document.body.offsetWidth-19; 
			intBrowserHeight = document.body.offsetHeight;
		}
	}
}

function PositionGetLeftAlignment(){
	var intLeft = ((intBrowserWidth/2)-(intContentWidth/2))
	if(intLeft < 0) intLeft = 0;
	return intLeft;
}

function PositionGetTopAlignment(){
	var intTop = (intBrowserHeight/2)-(intContentHeight/2);
	if(intTop < 0) intTop = 0;
	return intTop
}

function PositionResize(pstrPage){
	if (pstrPage == 'Home') {
		PositionGetBrowserSize();

		var theDivStyle = document.getElementById('headLogo').style;
		theDivStyle.left = 0;
		theDivStyle.top = 0;

		theDivStyle = document.getElementById('splash').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = 150;

		theDivStyle = document.getElementById('bottomBar').style;
		theDivStyle.position = 'Absolute';
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = PositionGetTopAlignment() + 573;

	} else if (pstrPage == '') {
		PositionGetBrowserSize();
		var theDivStyle = document.getElementById('headLogo').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = 0;

		theDivStyle = document.getElementById('bodyTextFull').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = 150;
		theDivStyle.height = intBrowserHeight - 191;

		theDivStyle = document.getElementById('textArea').style;
		theDivStyle.left = 20;
		theDivStyle.top = 30;
		theDivStyle.overflow = 'visible';
		theDivStyle.height = intBrowserHeight - 245;

		theDivStyle = document.getElementById('bottomBar').style;
		theDivStyle.position = 'Absolute';
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = intBrowserHeight -40;
	} else if (pstrPage == 'My Account') {
		PositionGetBrowserSize();
		var theDivStyle = document.getElementById('headLogo').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = 0;

		theDivStyle = document.getElementById('content').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = 150;
		theDivStyle.height = intBrowserHeight - 191;

		theDivStyle = document.getElementById('RBContent').style;
		theDivStyle.height = intBrowserHeight - 191;

		theDivStyle = document.getElementById('bottomBar').style;
		theDivStyle.position = 'Absolute';
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = intBrowserHeight -40;
	} else {	

		PositionGetBrowserSize();
		var theDivStyle = document.getElementById('content').style;
		theDivStyle.left = PositionGetLeftAlignment();
		theDivStyle.top = PositionGetTopAlignment();		
	}
}
//------------------------------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------------------------------
// Function pops up a blank window with no url to be used as the submission target of the forms below
//------------------------------------------------------------------------------------------------------------------
function ShowPopup(name, width, height, pstrPageName){
	pop = window.open(pstrPageName, name, "resizable=no,scrollbars=no,width="+width+",height="+height);
	pop.focus();
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Left and Right Functions
//------------------------------------------------------------------------------------------------------------------
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Get the Browser Name
//------------------------------------------------------------------------------------------------------------------
	var detect = navigator.userAgent.toLowerCase();
var thestring, place;
		
function getBrowserName () {
	var OS,browser,version;
			
	if (checkString('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkString('safari')) browser = "Safari"
	else if (checkString('omniweb')) browser = "OmniWeb"
	else if (checkString('opera')) browser = "Opera"
	else if (checkString('webtv')) browser = "WebTV";
	else if (checkString('icab')) browser = "iCab"
	else if (checkString('msie')) browser = "Internet Explorer"
	else if (!checkString('compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";
			
	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkString('linux')) OS = "Linux";
		else if (checkString('x11')) OS = "Unix";
		else if (checkString('mac')) OS = "Mac"
		else if (checkString('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}
			
	return browser;
}
		
function checkString(string)
{			
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Get and display the current server time
//------------------------------------------------------------------------------------------------------------------
var clockID = 0;
		
function padText(pstrText, pintLength, pstrChar, pblnPadAtFront) {
	var i = 0;
	var intCharsToAdd = 0;
			
	intCharsToAdd = pintLength - String(pstrText).length;
			
	for (i=0; i<intCharsToAdd; i++)	 {
		if(pblnPadAtFront) {
			pstrText = pstrChar + pstrText;
		} else {
			pstrText = pstrText + pstrChar;
		}
	}

	return pstrText;
}

function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var tDate = new Date();

   document.theClock.AYClock.value = Date(tDate);
		   
   clockID = setTimeout("UpdateClock()", 1000);
}
		
function StartClock() {
   clockID = setTimeout("UpdateClock()", 500);
}
		
function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Trim function
//------------------------------------------------------------------------------------------------------------------
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Check Email function
//------------------------------------------------------------------------------------------------------------------
function isValidEmail(pstrEmail){
	 var filter=/^.+@.+\..{2,3}$/
	
	 if (filter.test(pstrEmail))
	    return true
	 else {
		return false
	}
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Check if a text field is numeric
//------------------------------------------------------------------------------------------------------------------
function isNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	var i;
	
	for (i = 0; i < sText.length; i++) { 
	   Char = sText.charAt(i); 

	   if (ValidChars.indexOf(Char) == -1) {
	      return false;
	   }
	}
	return true; 
}
//------------------------------------------------------------------------------------------------------------------

