//Highlight form element- 

var highlightcolor="#ff9900"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION|SUBMIT/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

<!--
function changeBgColor(sBgColor) {
	var el = event.srcElement;
	
	if (el.tagName == "INPUT" && el.type == "button")
		event.srcElement.style.backgroundColor = sBgColor
	
	if (el.tagName == "SUBMIT" && el.type == "button")
		event.srcElement.style.backgroundColor = sBgColor
}
//-->

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}


<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
 // Functions to get querystring from javascript
function QueryString(key)
{
 var value = null;
 for (var i=0;i<QueryString.keys.length;i++)
 {
  if (QueryString.keys[i]==key)
  {
   value = QueryString.values[i];
   break;
  }
 }
 return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();
 
function QueryString_Parse()
{
 var query = window.location.search.substring(1);
 var pairs = query.split("&");
 
 for (var i=0;i<pairs.length;i++)
 {
  var pos = pairs[i].indexOf('=');
  if (pos >= 0)
  {
   var argname = pairs[i].substring(0,pos);
   var value = pairs[i].substring(pos+1);
   QueryString.keys[QueryString.keys.length] = argname;
   QueryString.values[QueryString.values.length] = value;  
  }
 }
 
}

QueryString_Parse();


function getDownloadPath(){
  var bLiveServer;
  var sRet;
  
  bLiveServer  = true;
  
  if (bLiveServer){
    sRet = "/erf/apps/doc/public/78/"
  }
  else{ 
    sRet = "/erf/epa/apps/doc/public/78/"
  }
  return sRet;
}

function displayPageSection(sNameOfSection) {
// Displays a section of a page.
// Parameters:
// - name of section to display.
	var iWinW;
	var sHorz, sVert;
	var sVisShow;
	var sDocStyle, sStyleDoc;
	
	if (navigator.appName == "Netscape") {
		// Netscape.
		iWinW = window.innerWidth-230
 		sHorz = ".left";
		sVert = ".top";
		sVisShow = "'show'";
		sDocStyle = "document.";
		sStyleDoc = "";
	}
	else {
		// IE.
		iWinW = document.body.scrollWidth-230
 		sHorz = ".pixelLeft";
		sVert = ".pixelTop";
		sVisShow = "'visible'";
		sDocStyle = "";
		sStyleDoc = ".style";
	}
	
	if (document.getElementById) {
		sVisShow = "'visible'";
		sDocStyle = "document.getElementById('";
		sStyleDoc = "').style";
	}
    
    eval(sDocStyle + sNameOfSection + sStyleDoc + sHorz + '=' + (iWinW / 2));
    eval(sDocStyle + sNameOfSection + sStyleDoc + sVert + "=50");
	eval(sDocStyle + sNameOfSection + sStyleDoc + '.visibility=' + sVisShow);
}


// Common javascript functionality.

var gsInvalidFields = "";
var gsDigits = "0123456789";
var gsLowerCaseLetters = "abcdefghijklmnopqrstuvwxyz"
var gsUpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var gsWhitespaceChars = " \t\n\r";

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	var sRet;
	var bDebug = false;

	if (begin == -1) {
		begin = dc.indexOf(prefix);

		if (begin != 0) return null;
	} else
		begin += 2;

	var end = document.cookie.indexOf(";", begin);

	if (end == -1)
		end = dc.length;
	
	sRet = unescape(dc.substring(begin + prefix.length, end));
	
	if (bDebug) {
		alert (name + " = " + sRet);
	}
	
	return sRet;
}

function isLoggedIn() {
/*
Checks if a user is logged in.
Returns:
- True if valid, else False.
*/
	var bRet = false;
	var bDebug = false;
	var sPpSignInName = getCookie("PpSignInName");

	if (bDebug) {
		alert(sPpSignInName);
	}
	
	if (sPpSignInName) {
		if (isEmail(sPpSignInName)) {
			bRet = true;
		}
	}

	return bRet;
}

function changeSubmitButton(sBgColor, sFontColor) {
	var el = event.srcElement;
	
	if (el.tagName == "INPUT" && (el.type == "button" || el.type == "submit")) {
		el.style.backgroundColor = sBgColor
		el.style.color = sFontColor
	}
}

function onmouseoverSubmitButton() {
	changeSubmitButton('#006633', '#ffffff')
}

function onmouseoutSubmitButton() {
	changeSubmitButton('#99cc33', '#000000')
}

function chkCheckBoxIsChecked(oCtrl, sErr) {
/*
Function to check that a CheckBox has been selected
Concats to the global error message gsInvalidFields.
Parameters:
- text control.
- error message to add to the error string if invalid.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if (bDebug) {
			sDebug = "chkCheckBoxIsChecked: " + oCtrl.name + " = " + oCtrl.value
			//alert(sDebug);
		}

		if (!oCtrl.checked) {
			bGo = false;
			bErr = true;
		}
	}

	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}
	
	return bErr;
}

function isEmpty(aString) {
// Checks whether a string is empty.
	return ((aString == null) || (aString.length == 0))
}

function isWhitespace (aString) {
// Returns true if text control is empty or 
// whitespace characters only.
	var iLoop;
	var cChar;

    // Is s empty?
    if (isEmpty(aString)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (iLoop = 0; iLoop < aString.length; iLoop++)
    {   
        // Check that current character isn't whitespace.
        cChar = aString.charAt(iLoop);

        if (gsWhitespaceChars.indexOf(cChar) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function containsAlphaNumeric(aString) {
/*
Function to determine whether a string contains characters.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bRet = false;
	var iLoop = 0;
	var refString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	
	if (aString.length > 0) {
		for (iLoop = 0; iLoop < aString.length; iLoop++) {
			chkChar = aString.substring(iLoop, iLoop + 1);
			
			if (refString.indexOf (chkChar, 0) > -1) {
				bRet = true;
				break;
			}
		}
	}
	
	if (bDebug) {
		alert("containsAlphaNumeric: " + aString + " = " + bRet);
	}

	return bRet;
}

function containsASpace(aString) {
/*
Function to determine whether a string contains a space.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bRet = false;
	var iLoop = 0;
	var refString = " ";
	
	if (aString.length > 0) {
		for (iLoop = 0; iLoop < aString.length; iLoop++) {
			chkChar = aString.substring(iLoop, iLoop + 1);
			
			if (refString.indexOf (chkChar, 0) > -1) {
				bRet = true;
				break;
			}
		}
	}
	
	if (bDebug) {
		alert("containsASpace: " + aString + " = " + bRet);
	}

	return bRet;
}

function chkTextArea(oCtrl, sErr) {
/*
Function to check that Text area is not empty.
Parameters:
- text area control.
- error message to add to the error string if invalid.
Returns:
- True if valid, else False.
*/
	var bGo = true;
	var bErr = false;
  
	if (!oCtrl) {
		bGo = false;
		alert("The form object you have passed does not exist.");
	}
		
	if (bGo){
		if ((oCtrl.value == null) || (oCtrl.value == "") || isEmpty(oCtrl.value)) {
			gsInvalidFields += "\n" + sErr;	
			bErr = true;    
		}
	}
	return bErr;
}

// Function to check a Textarea
function chkTextAreaLength(oTxtArea, sErr, iMaxLen) {
var sTemp=new String(oTxtArea.value);
var bIsOk = true;
	if (sTemp.length > iMaxLen )
	{
		// Check if a name was specified to use (IE 3 fix)
		if  (eValue == "" ) {
			if (browser.name == "MSIE" && browser.version <= 3) {
				eValue = "Text Area";
			}
			else {
				eValue = oTxtArea.name;
			}
		}
		gsInvalidFields += "\n" + sErr;
		bIsOk = false;
	}
return bIsOk;
}

// Function to determine whether a string contains numeric characters
function ChkTextIsNumeric(aString) {
	if (aString.length == 0) {
		return (false);
	}
	var refString = "1234567890";
	for (count=0; count < aString.length; count++) {
		chkChar = aString.substring (count, count+1);
		if (refString.indexOf (chkChar, 0) == -1)
			return (false);
	}
	return (true)
}

function chkTextIsVersionNo(oCtrl, sErr) {
/*
Function to check that a text box contains a version number.
Parameters:
- text control.
- error message to add to the error string if invalid.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsVersionNo: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		if (isNaN(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}
	
	return bErr;
}

function chkTextIsPostcode(oCtrl, sErr) {
/*
Function to check that a text box contains a postcode.
Parameters:
- text control.
- error message to add to the error string if invalid.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	var results, pattern, myRE;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsPostcode: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		pattern = /^[A-Za-z]{1,2}[\d]{1,2}([A-Za-z])?\s?[\d][A-Za-z]{2}$|^$/i;
		myRE = new RegExp(pattern);
		results = oCtrl.value.match(myRE);
		if (!results)
		{
			bErr = true;
		}
	}

	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}
	
	return bErr;
}

function chkTextIsTelephone(oCtrl, sErr, iMinLen, iMaxLen) {
/*
Function to check that a text box contains a telephone.
Parameters:
- text control.
- error message to add to the error string if invalid.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}

	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsTelephone: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		if (isNaN(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		if (iMinLen) {
			if (bDebug) {
				alert("Minimum Length: " + iMinLen + ", Length = " + oCtrl.value.length);
			}
			
			if (oCtrl.value.length < iMinLen) {
				bGo = false;
				bErr = true;
			}
		}
	}
	
	if (bGo) {
		if (iMaxLen) {
			if (bDebug) {
				alert("Maximum Length: " + iMaxLen + ", Length = " + oCtrl.value.length);
			}
			
			if (oCtrl.value.length > iMaxLen) {
				bGo = false;
				bErr = true;
			}
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr + " (Must be all digits)";
		gsInvalidFields += "\n(Minimum length " + iMinLen + " characters, maxium length " + iMaxLen + " characters)";
	}
	
	return bErr;
}

function chkTextIsAlphaNumeric(oCtrl, sErr) {
/* 
Function to check a that a text box contains a 
alphanumeric string.
Concats to the global error message empty_fields.
Parameters:
- text control.
- error message to add to the error string if invalid.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}

	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsAlphaNumeric: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}

	if (bGo) {
		if (!containsAlphaNumeric(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}
	
	return bErr;
}

function chkTextIsAlphaNumericWithMinMax(oCtrl, sErr, iMinLen, iMaxLen) {
/* 
Function to check a that a text box contains a 
alphanumeric string.
Concats to the global error message empty_fields.
Parameters:
- text control.
- error message to add to the error string if invalid.
- minimum length of text.
- maximum length of text.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}

	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsAlphaNumericWithMinMax: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		if (iMinLen) {
			if (bDebug) {
				alert("Minimum Length: " + iMinLen + ", Length = " + oCtrl.value.length);
			}
			
			if (oCtrl.value.length < iMinLen) {
				bGo = false;
				bErr = true;
			}
		}
	}
	
	if (bGo) {
		if (iMaxLen) {
			if (bDebug) {
				alert("Maximum Length: " + iMaxLen + ", Length = " + oCtrl.value.length);
			}
			
			if (oCtrl.value.length > iMaxLen) {
				bGo = false;
				bErr = true;
			}
		}
	}
	
	if (bGo) {
		if (!containsAlphaNumeric(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr;
		
		if (iMinLen) {
			gsInvalidFields += "\n(Minimum length " + iMinLen + " characters, maxium length " + iMaxLen + " characters)";
		}
	}
	
	return bErr;
}

function chkTextIsNumeric(oCtrl, sErr) {
/* 
Function to check a that a text box contains a 
numeric string.
Concats to the global error message empty_fields.
Parameters:
- text control.
- error message to add to the error string if invalid.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = false;
	var sDebug;
	
	if (!oCtrl) {
		bGo = false;
		bErr = true;
		alert("The form object you have passed does not exist.");
	}

	if (bGo) {
		if (bDebug) {
			sDebug = "chkTextIsNumeric: " + oCtrl.name + " = " + oCtrl.value
			alert(sDebug);
		}

		if (isEmpty(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bGo) {
		if (isNaN(oCtrl.value)) {
			bGo = false;
			bErr = true;
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}
	
	return bErr;
}

function chkRadioIsSelected(oCtrl, sErr) {
/*
Function to check that a radio button has been selected.
Returns:
- True if valid, else False.
*/
	var bDebug = false;
	var bGo = true;
	var bErr = true;
	var iItem = 0;
	var iLen = 0;
	
	if (!oCtrl) {
		bGo = false;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		iLen = oCtrl.length;
		
		if (iLen == undefined) {
			// There is only 1 radion button.
			if (oCtrl.checked) {
				bGo = false;
				bErr = false;
			}
		}
	}
	
	if (bGo) {
		if (bDebug) {
			alert("Len: " + iLen);
		}

		for (iItem = 0; iItem < iLen; iItem++) {
			if (bDebug) {
				alert(iItem + ' = ' + oCtrl[iItem].checked);
			}
			
			if (oCtrl[iItem].checked) {
				bErr = false;
			}
		}
	}
	
	if (bErr) {
		gsInvalidFields += "\n" + sErr;
	}

	return bErr;
}

function chkSelectWithInvalidFirstItem (oCtrl, sErr) {
/*
Function to check an option has been selected in a Select list
where the first item in the select is not a valid item..
*/
	var bRet = true;
	var bGo = true;
	
	if (!oCtrl) {
		bGo = false;
		bRet = false;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if ((oCtrl.selectedIndex < 1) || (oCtrl.value == "") || (oCtrl.value == "NULL")) {
			bRet = false;
		}
	}
	
	if (!bRet) {
		gsInvalidFields += "\n" + sErr;
	}

	return bRet;
}

function chkMultiSelect (oCtrl, sErr) {
/*
Function to check an option has been selected in a Select list
where the first item in the select is not a valid item..
*/
	var bRet = true;
	var bGo = true;
	
	if (!oCtrl) {
		bGo = false;
		bRet = false;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if ((oCtrl.selectedIndex < 0) || (oCtrl.value == "") || (oCtrl.value == "NULL")) {
			bRet = false;
		}
	}
	
	if (!bRet) {
		gsInvalidFields += "\n" + sErr;
	}

	return bRet;
}

function isEmail(sValue) {
/*
Checks if a text string is an email.
Email address must be of form a@b.c -- in other words:
- there must be at least one character before the @
- there must be at least one character before and after the .
- the characters @ and . are both required
Returns:
- True if valid, else False.
*/
	var bRet = false;
	var bGo = true;
	
	if (bGo) {
		if (isEmpty(sValue)) {
			bGo = false;
		}
	}

	if (bGo) {
	    if (isWhitespace(sValue)) {
			bGo = false;
		}
	}
    
	if (bGo) {
	    if (containsASpace(sValue)) {
			bGo = false;
		}
	}
    
	if (bGo) {
		// there must be >= 1 character before @, so we
		// start looking at character position 1 
		// (i.e. second character)
		var iLoop = 1;
		var iLength = sValue.length;

		// look for @
		while ((iLoop < iLength) && (sValue.charAt(iLoop) != "@")) { 
			iLoop++
		}

	    if ((iLoop >= iLength) || (sValue.charAt(iLoop) != "@"))  {
			bGo = false;
		} else {
			iLoop += 2;
		}
	}
	
	if (bGo) {
		// look for .
		while ((iLoop < iLength) && (sValue.charAt(iLoop) != ".")) { 
			iLoop++
		}

		// there must be at least one character after the .
		if ((iLoop >= iLength - 1) || (sValue.charAt(iLoop) != ".")) {
			bGo = false;
		}
	}
	
	if (bGo) {
		bRet = true;
    }

	return bRet;
}

function chkTextIsEmail(oCtrl, sErr) {
/*
Checks that a form field contains an email address.
Parameters:
- form field.
- error message if not valid.
Returns:
- True if valid, else False.
*/
	var bRet = false;
	var bGo = true;
	
	if (!oCtrl) {
		bGo = false;
		alert("The form object you have passed does not exist.");
	}
	
	if (bGo) {
		if (isEmail(oCtrl.value)) {
			bRet = true;
		}
	}
	
	if (!bRet) {
		gsInvalidFields += "\n" + sErr;
	}

	return bRet;
}

function isFormValid(sErr) {
/*
Show the Errors built up into the error string
If errors display messages and return false to stop form submission.
Uses the global gsInvalidFields string.
*/
	var bRet = false;
	var sMsg = "";

	if (!sErr) {
		bRet = true;
	}
	else {
		sMsg += "================================\n"
		sMsg += "Some of the information you have entered is invalid.\n";
		sMsg += "Please correct the following fields before continuing.\n";
		sMsg += "================================\n"
		sMsg += sErr
		sMsg += "\n\n"
		sMsg += "================================\n"
		
		alert(sMsg);
	}
	
	return bRet;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openwin2(url, winwidth, winheight, sScrollbars) {  
	var counter = 0;

	if (navigator.appName == "Netscape")
	{
		counter++;
		newWin = "win" + counter;
		var image_win = window.open(url, newWin, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + sScrollbars + ",resizable=0,width=" + winwidth + ",height=" + winheight);
	}

	if (navigator.appName == "Microsoft Internet Explorer")
	{
		counter++;
		newWin = "win" + counter;
		var image_win = window.open(url, newWin, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + sScrollbars + ",resizable=0,width=" + winwidth + ",height=" + winheight);
	}
}

function openwin(url, winwidth, winheight) {  
	openwin2(url, winwidth, winheight, '0');
}
  
function opennewwin(url, winwidth, winheight) {
	var counter = 0

	if (navigator.appName == "Netscape")
	{
		counter++;
		newWin = "win" + counter;
		var newNavWin = window.open(url, newWin, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + winwidth + ",height=" + winheight);
	}
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		counter++;
		newWin = "win" + counter;
		var image_win = window.open(url, newWin, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + winwidth + ",height=" + winheight);
	}
}

function openBlankWin(strURL){
	opennewwin(strURL, 750, 500)
}

function openSSDPDF(sFile,sCustomerPath){
// Opens a SSD PDF for download.
// Parameters:
// - name of file to open.  All these files should be
// in the /ssds/pdfOutput directory.

  var sUrl;
  var sPath;
	
  sPath = "/ssds/" + sCustomerPath;
  sUrl = "/downloads/?file=" + sFile + "&dpath=" + sPath;
  alert (sUrl);
  //opennewwin(sUrl, 500, 360);
}


function openFile(sFile){
// Opens a file for download.
// Parameters:
// - name of file to open.  All these files should be
// in the public folder of the CMS application. 
  var sUrl;
  
  sUrl = "/downloads/?file=" + sFile;
  opennewwin(sUrl, 500, 360);
}
	
function openJPG(sFileName) {
  var sUrl;
  sUrl = getDownloadPath() + sFileName
	
	opennewwin(sUrl,750,500)
}

function openDOC(sFileName) {
	// if path not supplied - assume its from the cms directory
	sUrl = getDownloadPath() + sFileName
	opennewwin(sUrl,800,600);
}

function openSWF(strFileName) {
	openFile(strFileName);
}

function openEXE(sFile) {
	// if path not supplied - assume its from the cms directory
	openFile(sFile);
}

function openZIP(sFile) {
	// if path not supplied - assume its from the cms directory
	  openFile(sFile);
}

function openNewsletter(strArticle) {
	if(strArticle.indexOf("/") == -1)
		{
		strArticle = "/erf/apps/doc/public/78/" + strArticle;
		}
	opennewwin("/newsletters/archive/" + strArticle,800,600);
}

function openKbaseArticle(strPubNum) {
	var strURL;
	strURL = "/kbase2/viewarticle.asp?pubnum=" + strPubNum;
	return opennewwin(strURL,650,600);
}

function openSupportGuide(strFileName) {
	// if path not supplied - assume its from the cms directory
	  openFile(strFileName)
}

function openPDF(sFile) {
	openFile(sFile);
}

function openXLS(sFile) {
	// if path not supplied - assume its from the cms directory
	openFile(sFile);
}

	
var currentTabID = "";
function showTabContent(divID) {
/*
Created for customers area where a sub menu is created
divs are shown or hidden
*/
	// hide the last div the user chose to display
	
	//alert("Current: "+currentTabID)
	//alert("Div: "+divID)
	
	if(currentTabID.length > 0)
	{
		oPrevDiv = document.getElementById(currentTabID);
		oPrevDiv.style.visibility = "hidden";
		oPrevDiv.style.display = "none";		
	}
  
	// display the div the customer has chosen
	oDiv = document.getElementById(divID);
	oDiv.style.visibility = "visible";
	oDiv.style.display = "";
	currentTabID = divID;

	swapArrow(divID);
}

function setFirstTabVisible() {
	// ptid stands for page tab id (instance id from cms)
	var ptid = QueryString("ptid");
	
	if(ptid != null && ptid != "")
	{
		showTabContent(ptid);
		//alert("ShowTabContent: "+ptid);
	}
	else
	{
		for (i=0;i<document.images.length; i++) {
			imgname = document.images[i].name;
			// ensure image name is prefixed with tabimg
			if(imgname.indexOf("tabimg") > -1) {
				arrImgName = imgname.split("tabimg");
				strID = arrImgName[1];
				showTabContent(strID);
			}
		}
	}
}

function swapArrow(intID) {
// swaps arrow pointing left
// for arrow pointing down
// hides any other image with name prefix of 'tabimg'
// param = the instance id from cms
	//iterate thru images
	for(i=0;i<document.images.length; i++)
	{
		imgname = document.images[i].name;

		// ensure image name is prefixed with tabimg
		if(imgname.indexOf("tabimg") > -1)
		{
			arrImgName = imgname.split("tabimg");
			strID = arrImgName[1];
		
			if(strID == intID) //matching id found - change src
			{
				document.images[i].src = "/images/arrowdn.gif";
			}
			else //not matching
			{
				document.images[i].src = "/images/arrow.gif";
			}
		}
	}
}

function printPage() {
	if (window.print) {
    	window.print() ;  
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}	

function openTrainingCoursePopup(sCourseCode) {
// Opens a popup window for the course.
// Parameters:
// - short description of the course.
	var sLink = "popup_coursedetails.asp?cc=" + sCourseCode;
	
	window.open(sLink, 'course','top=10,left=10,width=550,height=440,location=0,resizable=0,scrollbars=1,left=40,top=40');
}

var sDomain=location.hostname;
function manageLinks()
// Opens external links in a new window
// Needs onload event to work
{
  for (var i=0; i<=(document.links.length-1); i++)
  {
    if(document.links[i].href.indexOf(sDomain)<0)
	  document.links[i].target="_blank";
  }
}
//Highlights table rows on rollover
var strBGColor = "";
function highlightRow(oRow)
	{
	strBGColor = oRow.bgColor;
	oRow.bgColor = '#ffffcc';
	oRow.style.cursor = 'hand';
	}
function unhighlightRow(oRow)
	{
	oRow.bgColor = strBGColor;
	}

//Horizontal menu gets URL 
function GetHorizontalMenuURL(strCommunity){
 strPath = window.location.href;
 arrPath = strPath.split("/");
 strRet = "http://" + arrPath[2] + "/" + strCommunity + "/";
 return strRet;
}

var currentArticleID = ""; // div containing currently displayed newsfeed article
var currentArticleTitleDivID = ""; //div containing 'read more' link
function showNewsfeedArticle(divID, sbnLinkDivID) {
/*
Created for newsfeed service
*/
	// hide the last div the user chose to display
	if(currentArticleID.length > 0)
	{
		// show article content
		oPrevDiv = document.getElementById(currentArticleID);
		oPrevDiv.style.visibility = "hidden";
		oPrevDiv.style.display = "none";
		// hide the show me more table row
		oPrevDivTitle = document.getElementById(currentArticleTitleDivID);
		oPrevDivTitle.style.visibility = "visible";
		oPrevDivTitle.style.display = "";
	}

	// display the div the customer has chosen
	oDiv = document.getElementById(divID);
	oDiv.style.visibility = "visible";
	oDiv.style.display = "";
	currentArticleID = divID;
	// hide the show me more
	oDivTitle = document.getElementById(sbnLinkDivID);
	oDivTitle.style.visibility = "hidden";
	oDivTitle.style.display = "none";
	currentArticleTitleDivID = sbnLinkDivID;
}

function openPricingPopup(sMenuItem) {
	var sUrl = "/productsandservices/popup_pricing.asp?mi=" + sMenuItem;
	openwin2(sUrl, 500, 400, '1');
}

function openPassportMoreInfoPopup() {
	var sUrl = "/passport/moreinfo.asp";
	openwin2(sUrl, 500, 400, '1');
}

function onclickPpLogin() {
	document.frmLogin.submit();
}

function onclickPpObtain() {
	document.frmObtain.submit();
}

function chkNoOfChars(oField, iMaxChars){
	// This function will check the length of text input into a textarea.
	var iMaxCharCount = iMaxChars
	var iSizeOf = oField.value.length;
	//alert(iSizeOf);

	if (iSizeOf > iMaxCharCount) {
		alert('Only ' + iMaxCharCount + ' allowed. Your current character count is ' + iSizeOf);
	}
}

