/* Common Javascript used throughout system */

var gLabels;

userAgent = window.navigator.userAgent; 
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
CSIsW3CDOM = ((document.getElementById) && !(IsIE()&&browserVers<6)) ? true : false;

var gClientTimezoneOffset = (new Date()).getTimezoneOffset()
var gDaylightDiff = gClientTimezoneOffset - (new Date(2006,0)).getTimezoneOffset(); //negative if summer time on
var gServerTimezoneOffset;
var gTimezoneOffsetStandard = gServerTimeZoneOffsetStandard();
try{
	gServerTimezoneOffset = gTimezoneOffsetStandard + gDaylightDiff; //minutes
}
catch(aEx){
	// assume server in Ottawa
	gServerTimezoneOffset = -360 + gDaylightDiff; //minutes
}

function gServerTimeZoneOffsetStandard(){
	
	// returns the offset (minutes) at the server: current server time - UTC
	// negative if west of Greenwich (-300 for Ottawa/Montreal; -480 for Vancouver)
	
	return(-1 * (new Date(2006,0)).getTimezoneOffset()); 
}

function IsIE() { return userAgent.indexOf("MSIE") > 0;}

function IsWin() { return (typeof(navigator.platform) != "undefined"  &&  navigator.platform.substr(0,3)=="Win");}

function CSIEStyl(s) { return document.all.tags("div")[s].style; }

function CSNSStyl(s) { if (CSIsW3CDOM) return document.getElementById(s).style; else return findElement(s,0);  }

mustInitImg = true;

function initImgID() {
	di = document.images; 
	if (mustInitImg && di) { 
		for (var i=0; i<di.length; i++) { 
			if (!di[i].id) di[i].id=di[i].name; 
		} 
	mustInitImg = false;
	}
}

function findElement(n,ly) {
	d = document;
	if (browserVers < 4) return d[n];
	if ((browserVers >= 6) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}

function changeImages() {
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (d.layers) {img = findElement(changeImages.arguments[i],0);}
			else {img = d.images[changeImages.arguments[i]];}
			if (img) {img.src = changeImages.arguments[i+1];}
			//else alert("ChangeImages can't find " + changeImages.arguments[i]);
		}
	}
}

function EF(pE,pF) {

// return English or French version: pE and pF may not be strings!

	if (gLanguage == "E") {
		return pE;
	} else {
		if (typeof(pF) == "string" && pF=="*F") {
			if (typeof(pE) == "string") return "*F " + pE;
			else return pE;
		}
		else return pF;
	}
	
}

function trim(val) {
	var i,j;
	i = 0;
	while (i<val.length && val.charAt(i) == " ") i++;
	if (i>= val.length) return "";
	j = val.length-1;
	while (j>=0 && val.charAt(j) == " ") j--;
	return val.substring(i,j+1);
}

function toggleDisplay(pBlockId, pTextId, pShowText, pHideText) {

// toggle display of the block and toggle the text ("Show", "Hide")

	var aDisplayBlock = document.getElementById(pBlockId);
	var aTextBlock = document.getElementById(pTextId);
	
	if (!aDisplayBlock) {
		alert("In toggleDisplay, there is no block with id " + pBlockId);
		return;
	}
	if (!aTextBlock) {
		alert("In toggleDisplay, there is no text item with id " + pTextId);
		return;
	}
	
	var aDisplayedText = aTextBlock.innerHTML;
	switch (aDisplayedText) {
		case pShowText:
			aTextBlock.innerHTML = pHideText;
			aDisplayBlock.style.display = "Block";
			break;
		case pHideText:
			aTextBlock.innerHTML = pShowText;
			aDisplayBlock.style.display = "None";
			break;
	}

}

function optionSelect(pSelectObj, pValue) {
// Select the option with the value pValue in the select object

	if (!pSelectObj) return;
	
	for(var aI=0; aI<pSelectObj.options.length; aI++) {
		aOption = pSelectObj.options[aI];
		if (aOption.value == pValue) {
			pSelectObj.selectedIndex = aI;
			break;
		}
	}
}

function orderCheck(pSubmit) {
// return false if there are any quantities that aren't valid
// or if no quantities given on "Submit" = add to shopping list (blank form ok on "Checkout")

	var abNaN = false;
	var abData = false;
	
	for(var aI=0; aI<pSubmit.form.elements.length; aI++) {
		var aEl = pSubmit.form.elements[aI];
		aName = aEl.name;
		if (aName.indexOf("Quantity") == 0) {
			var aValue = aEl.value;
			if (aValue != "") {
				if (isNaN(aValue)) {
					abNaN = true;
					aEl.focus();
					break;
				}
				else abData = true;
			}
		}
	}
	
	if (abNaN) {
		alert("Sorry, you can only enter numbers in the Qty fields. Please try again.");
		return false;
	}
	
	if (pSubmit.name == "Submit" && !abData) {
		alert("You haven't entered any quantities. Please try again.");
		return false;
	}
	
	return true;
	
}

function gbFieldCheck(pType, pValue) {

// Checks whether value (type = Postal | Phone | Email) is valid.
// Returns a string containing "T" (if valid) or "F", a comma, and 
// the correctly formatted value if valid, otherwise the value supplied.

   var aRegExpBlank = /^\s*$/;
   var aValue = String(pValue);

   if (aValue == "null"  ||  aValue == "undefined" || aRegExpBlank.test(pValue)) return ("T,");
   
   var aRegExpTest, aRegExpReplacement;

   switch (pType) {
      case "Postal":
         aValue = aValue.toUpperCase();
         aRegExpTest = /^\s*([a-zA-Z]\d[a-zA-Z])([\s-]*)(\d[a-zA-Z]\d)\s*$/;
         aRegExpReplacement = "$1 $3";
         break;

      case "Phone":
         aRegExpTest = /^[\s\D]*1*[\s\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})(\s*|\D+(.*))$/; 
         aRegExpReplacement = "($1) $2-$3$4";
         break;

      case "Email":	//allows alphanumerics and - _ $ ! / ' in parts of email address
      case "EMail":
         aRegExpTest = /^\s*([-a-zA-Z0-9_!$\/']+)((\.[-a-zA-Z0-9_!$\/']+)*)@([-a-zA-Z0-9_!$\/']+)((\.[-a-zA-Z0-9_!$\/']+)+)\s*$/;
         aRegExpReplacement = "$1$2@$4$5";
         break;
         
      default:
         return "F," + aValue;
   }

   if (aRegExpTest.test(aValue)) {
      aValue = aValue.replace(aRegExpTest,aRegExpReplacement);
      for(;aValue.length>0 && aValue.charAt(aValue.length-1)==" ";) aValue = aValue.substr(0,aValue.length-1);
      return "T," + aValue;
   } else {
      return "F," + aValue;
   }
}

function findElement(n,ly) {
	d = document;
	if (CSBVers < 4) return d[n];
	if ((CSBVers >= 6) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
function SetImgURL() {
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<SetImgURL.arguments.length; i+=2) {
			img = null;
			if (d.layers) { img = findElement(SetImgURL.arguments[i],0);}
			else {img = d.images[SetImgURL.arguments[i]];}
			if (img) {img.src = SetImgURL.arguments[i+1];}
			else alert(SetImgURL.arguments[i] + " is not an image");
		}
	}
}
function buttonon(s) {
	 SetImgURL(s,"../nav/pop-button-over.gif");
	return true;
	}
function buttonoff(s) {
	SetImgURL(s,"../nav/pop-button-off.gif");
	return true;
	}

function removeHTMLTags(pStrInput){

		var aStrOutput = pStrInput.replace(/<\/?[^>]+(>|$)/g, "");
 		return aStrOutput; 

}

function NavMenuHighliteCascade(pId){
	var aNavMenu = document.getElementById(pId);
	var aAnchorObjs = aNavMenu.getElementsByTagName('a')
	var aLength = aNavMenu.getElementsByTagName('a').length;
	var aCounter = 0;
	var aIndex = 0;
	var aI = 0;

	gLabels = new Array()

	for (aI=0;aI<aLength;aI++)
	{
		if(removeHTMLTags(aAnchorObjs[aI].innerHTML) == "United States"){		
			gLabels[aI] = aAnchorObjs[aI].innerHTML;
		}else{
			gLabels[aI] = (aAnchorObjs[aI].text?aAnchorObjs[aI].text:aAnchorObjs[aI].firstChild.data);
		}
		

	}

	for (aI=0;aI<aLength;aI++)
	{
		aCounter += 500;
		setTimeout("AnchorHighLiteOn('" + aI + "','" + pId + "')",aCounter);

		aCounter += 500;
		setTimeout("AnchorHighLiteOff('" + aI + "','" + pId + "')",aCounter);
		
	}

	setTimeout("AnchorsStandard('" + pId + "')",aCounter+2000);
	
}

function AnchorHighLiteOn(pIndex,pId){

	var aNavMenu = document.getElementById(pId);
	var aAnchorObjs = aNavMenu.getElementsByTagName('a')
	var aLength = aAnchorObjs.length;

	//var aText = (aAnchorObjs[pIndex].text?aAnchorObjs[pIndex].text:aAnchorObjs[pIndex].firstChild.data);
	var aText = gLabels[pIndex];
	
	if (aAnchorObjs[pIndex] && gLabels[pIndex])
	{
		aAnchorObjs[pIndex].innerHTML = "<font color='red'>" + aText + "</font>";
	}
}

function AnchorHighLiteOff(pIndex,pId){
	
	var aNavMenu = document.getElementById(pId);
	var aAnchorObjs = aNavMenu.getElementsByTagName('a')
	var aLength = aAnchorObjs.length;
	var aText = '';
	
	if (aAnchorObjs[pIndex])
	{
		//var aText = (aAnchorObjs[pIndex].text?aAnchorObjs[pIndex].text:aAnchorObjs[pIndex].firstChild.data);
		aText = gLabels[pIndex];
		aAnchorObjs[pIndex].innerHTML = aText;
	}

}

function AnchorsStandard(pId){
	var aNavMenu = document.getElementById(pId);
	var aAnchorObjs = aNavMenu.getElementsByTagName('a')
	var aLength = aAnchorObjs.length;
	var aText = '';

	for (var aI=0;aI<aLength;aI++)
	{
		if (aAnchorObjs[aI])
		{
			//var aText = (aAnchorObjs[aI].text?aAnchorObjs[aI].text:aAnchorObjs[aI].firstChild.data);
			aText = gLabels[aI];
			aAnchorObjs[aI].innerHTML = aText;
		}
		
	}
}

  function ActiveLinkTextHilite(pActiveLinkId){

	// Hilites links in red as plain text when they are selected, retore previous slected item as a link

	var aPreActiveLinkId = '';
	var aPreActiveLinkHtml = '';
	var aActiveLinkHtml = '';
	
	var abPageLoading = (document.getElementById('PageLoading').value=='true'?true:false);

	if (!abPageLoading)
	{
		aPreActiveLinkId = document.getElementById('ActiveLinkId').value;
		aPreActiveLinkHtml = document.getElementById('ActiveLinkHtml').value;

	aActiveLinkHtml = document.getElementById(pActiveLinkId).innerHTML;

	document.getElementById('ActiveLinkId').value = pActiveLinkId;
	document.getElementById('ActiveLinkHtml').value = aActiveLinkHtml;
	document.getElementById(pActiveLinkId).innerHTML = '<font color=\'red\'>' + gFreatureLinkText[pActiveLinkId] + '</font>';

	if ((aPreActiveLinkId != '') && (aPreActiveLinkHtml != ''))
	{
	  document.getElementById(aPreActiveLinkId).innerHTML = aPreActiveLinkHtml;
	}else{
			document.getElementById('PageLoading').value = 'true';
		}

	}else{
	document.getElementById(pActiveLinkId).innerHTML = '<font color=\'red\'>' + gFreatureLinkText[pActiveLinkId] + '</font>';
		document.getElementById('PageLoading').value = 'false';
	}

  }
//
// CROSS-BROWSER ROUTINES TO DEAL WITH KEYBOARD INPUT
// In IE on Windows, uses default Tab action and converts Enter to Tab except in Textareas and Submits
// On other browsers/platforms, traps Tab and Enter, and uses nextFocus routine to advance
// the focus to the next focusable field in tabindex order.
// Function firstFocus sets focus to focusable field with lowest positive tabindex.

function keyCode(pEvent) {

// cross-browser keycode for keyboard event

   if (IsIE()) return event.keyCode;
   var aKeyCode = pEvent.keyCode;
   if (aKeyCode == 0) aKeyCode = pEvent.which;	//Mozilla
   return aKeyCode;
}
	
function keyTarget(pEvent) {

// cross-browser target of keyboard event

   return IsIE() ? event.srcElement : pEvent.target;
}

function tabIndex(pElement) {

// Return signed tabIndex (Safari forces tabIndex to be positive)

	return (pElement.tabIndex < 16384) ? pElement.tabIndex : pElement.tabIndex - 32768;
}

function IsFocusable(pElement) {

// Returns true if pElement is a form element that can be given the focus and 
// is not disabled or readonly or inside a DIV with display=none

   if (pElement.disabled || pElement.readOnly) return false;
   for (var elAncestor = pElement.parentNode; (elAncestor.nodeName != "HTML") && (elAncestor.nodeName != "FORM") && (elAncestor.nodeName!="DIV"); elAncestor = elAncestor.parentNode); 
   if ((elAncestor.nodeName == "DIV") && (elAncestor.style.display == "none")) return false;
   
   var aType = pElement.type;
   return (aType == "text" ||  aType == "textarea" || aType == "password" || aType == "submit" ); 
   //|| aType.substr(0,6) == "select");
}

function trapEnter(pEvent) {

// onkeydown="return trapEnter(event);" convert enter to tab in IE Windows; call nextFocus on tab,enter in IE Mac

   return IEtrapEnter();
}

function IEtrapEnter() {

// onkeydown="return IEtrapEnter();" convert enter to tab in IE Windows; call nextFocus on tab,enter in IE Mac

   if (IsIE()) {
      var aTarget = event.srcElement;
      if (IsWin()) {
         if (event.keyCode == 13  &&  aTarget.type != "textarea"  &&  aTarget.type != "submit") event.keyCode = 9;
         return true;
      } else {
         if ( event.keyCode == 9  ||  (event.keyCode == 13  &&  aTarget.type != "textarea"  &&  aTarget.type != "submit") ) {
            nextFocus(aTarget);
            return false;
         }
      }
   }
   return true;
}

function trapTabEnter(pEvent) {

// onkeypress="return trapTabEnter(pEvent);" convert enter to tab in IE Windows; call nextFocus on tab,enter for other browsers; 
// if neither tab or enter, return keycode (treated as true)

   var aKeyCode = keyCode(pEvent);
   var aTarget = keyTarget(pEvent);
   if (aKeyCode == 9  ||  (aKeyCode == 13  &&  aTarget.type != "textarea"  &&  aTarget.type != "submit") ) {
      if (IsIE()  &&  IsWin()) {
         event.keyCode = 9; 
         return true;
      }
      aTarget.blur();	//added 2009-4-6 to ensure onchange fires if there is only one focusable field in the form
      nextFocus(aTarget);
      return false;
   }
   return aKeyCode;
}

// Checks for valid data entry

function trapInvalid(pEvent,pValidChars) {

// cross-browser; traps tab/enter moving focus, traps and suppresses invalid char
	
   var aResult = trapTabEnter(pEvent);
   //alert("aResult: " + aResult);
   switch (aResult) {
      case true:
         return aResult;
      case false:
         return aResult;
      case 8:	//backspace
      case 127:	//delete
         return true;
      default:
		 //alert("String.fromCharCode(aResult): " + String.fromCharCode(aResult));
		 //alert("pValidChars.indexOf(String.fromCharCode(aResult)): " + pValidChars.indexOf(String.fromCharCode(aResult)));
         return (pValidChars.indexOf(String.fromCharCode(aResult)) >= 0);
   }
}

function trapInvalid(pEvent,pValidChars) {

// cross-browser; traps tab/enter moving focus, traps and suppresses invalid char

	var pUniqueChars = ""

	if (arguments.length > 2) pUniqueChars = arguments[2];
	
   var aResult = trapTabEnter(pEvent);
   //alert("aResult: " + aResult);
   switch (aResult) {
      case true:
         return aResult;
      case false:
         return aResult;
      case 8:	//backspace
      case 127:	//delete
         return true;
      default:
		 //alert("String.fromCharCode(aResult): " + String.fromCharCode(aResult));
		 //alert("pValidChars.indexOf(String.fromCharCode(aResult)): " + pValidChars.indexOf(String.fromCharCode(aResult)));
			var aChar = String.fromCharCode(aResult)
         return (validCharacter(aChar,pValidChars) && validUniqueCharacter(pEvent,aChar,pUniqueChars));
   }
}

function validCharacter(pChar,pValidChars){
	return (pValidChars.indexOf(pChar) >= 0)
}

function validUniqueCharacter(pEvent,pChar,pUniqueChars){

	var aValue = keyTarget(pEvent).value;

	return (pUniqueChars.length == 0) || (pUniqueChars.indexOf(pChar) == -1) || (aValue.indexOf(pChar) == -1);
}

function trapInvalidHTML(pEvent,pInValidChars) {

// cross-browser; traps tab/enter moving focus, traps and suppresses invalid char
	
   var aResult = trapTabEnter(pEvent);
   switch (aResult) {
      case true:
         return aResult;
      case false:
         return aResult;
      case 8:	//backspace
      case 127:	//delete
         return true;
      default:
         return !(pInValidChars.indexOf(String.fromCharCode(aResult)) >= 0);
   }
}

function trapInvalidDigit(pEvent) {

   return trapInvalid(pEvent,"0123456789");
}

function trapInvalidInteger(pEvent) {

   return trapInvalid(pEvent,"0123456789");
}

function trapInvalidSignInteger(pEvent) {

   return trapInvalid(pEvent,"0123456789-");
}

function trapInvalidDecimal(pEvent) {

   return trapInvalid(pEvent,"0123456789.",".");
}

function trapInvalidDecimalE(pEvent) {

   return trapInvalid(pEvent,"0123456789.",".");
}

function trapInvalidDecimalF(pEvent) {

   return trapInvalid(pEvent,"0123456789,",",");
}

function trapInvalidSignDecimal(pEvent) {

   return trapInvalid(pEvent,"0123456789.-",".-");
}

function trapInvalidSignDecimalE(pEvent) {

   return trapInvalid(pEvent,"0123456789.-",".-");
}

function trapInvalidSignDecimalF(pEvent) {

   return trapInvalid(pEvent,"0123456789,-",",-");
}

function trapInvalidCurrency(pEvent) {

// Only used by AIR

   return trapInvalid(pEvent,"0123456789");
}

function trapInvalidSignCurrency(pEvent) {

// Only used by AIR

   return trapInvalid(pEvent,"0123456789-");
}

function trapInvalidCodeChar(pEvent) {

   return trapInvalid(pEvent,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,-&()' ");
}

function trapInvalidHTMLTags(pEvent) {

	return trapInvalidHTML(pEvent,"<>");
}

function trapInvalidUserChar(pEvent) {

   return trapInvalid(pEvent,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-");
}

function trapInvalidPWChar(pEvent) {

   return trapInvalid(pEvent,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-#&?!@$%");
}

function firstFocus() {

// Move focus to focusable field of form with smallest positive tabIndex

   var form0 = document.frmEdit;
   if (!form0) {
//      alert("No form called frmEdit on page");
      return;
   }

//   displayFocuses();

   var numElements = form0.elements.length;
   if (numElements == 0) return;

   var elTabIndexSmallest;
   var tabIndexSmallest=99999;
   
   for (var i = 0; i<numElements; i++) {

      var elCur = form0.elements[i];

      if (IsFocusable(elCur)) {
         var tabIndexCur = tabIndex(elCur);
         if (tabIndexCur > 0  &&  tabIndexCur < tabIndexSmallest) {
            elTabIndexSmallest = elCur;
            tabIndexSmallest = tabIndexCur;
            //alert("Smallest tabindex is " + tabIndexCur + " for " + elCur.name);
         }
      }
   }
   if(tabIndexSmallest<99999) {
      elTabIndexSmallest.focus();
      elTabIndexSmallest.select();
   }
}

function displayFocuses() {

   var form0 = document.frmEdit;
   if (!form0) {
//      alert("No form called frmEdit on page");
      return;
   }
   var numElements = form0.elements.length;
   var aList = "";

   for (var i=0; i<numElements; i++) {

      var elCur = form0.elements[i];

      aList += elCur.tagName + " " + elCur.name + "; "
   }
//   alert(aList);
}


function nextFocus(pElement) {

// Move focus to later focusable field of form with tabIndex same as this;
// or to first tabindex next larger than this, or to field with smallest positive tabIndex

//	if(IsIE() && IsWin()){
//		alert("Next focus with pElement = " + pElement.name);
//	}
	
   var form0 = document.frmEdit;
   if (!form0) {
 //     alert("No form called frmEdit on page");
      return;
   }
   var numElements = form0.elements.length;
   if (numElements == 0) return;

   var elTabIndexSmallest,elTabIndexNextLarger;
   var tabIndexSmallest=99999,tabIndexNextLarger=99999;
   
   var tabIndexBase = tabIndex(pElement);
   var aBaseElFound = false;
   var elNext=pElement;
   
   for (var i=0; i<numElements; i++) {

      var elCur = form0.elements[i];

      if (elCur===pElement) {
         aBaseElFound = true;
         for (var j=0; j<numElements; j++) {
            elNext = form0.elements[(i+j+1)%numElements];
            if (IsFocusable(elNext)) break;
         }
         continue;
      }
      
      if (IsFocusable(elCur)) {
         var tabIndexCur = tabIndex(elCur);
         if ( (tabIndexCur > tabIndexBase || (aBaseElFound  &&  tabIndexCur == tabIndexBase) )    &&  tabIndexCur < tabIndexNextLarger) {
            elTabIndexNextLarger = elCur;
            tabIndexNextLarger = tabIndexCur;
         }
         if (tabIndexCur > 0  &&  tabIndexCur < tabIndexSmallest) {
            elTabIndexSmallest = elCur;
            tabIndexSmallest = tabIndexCur;
         }
      }
   }
   elTarget = elNext;
   if (tabIndexBase > 0) {
      if (tabIndexNextLarger<99999) elTarget = elTabIndexNextLarger;
      else if (tabIndexSmallest<99999) elTarget = elTabIndexSmallest;
   }
   if(!elTarget || !IsFocusable(elTarget)) elTarget = pElement;
   	elTarget.focus();
   	elTarget.select();
   }

function DateDiff(pUnits, pDate1, pDate2) {

// Returns the difference in Units between Date1 and Date 2 -- only for days now!

	var aMillisecs;
	
	switch (pUnits.toUpperCase()) {
		case "D" : aMillisecs = 1000*60*60*24; break;
	}
	  
	return (Math.floor(pDate2.getTime()/aMillisecs) - Math.floor(pDate1.getTime()/aMillisecs));}


function sFormatDate(pDate) {

// Formats a date in standard dd mon yyyy format

	if(!pDate || pDate == "") return String(pDate);
	if(isNaN(pDate)) return String(pDate);

	var aMonths;
	if (gLanguage == "F"){ 
	   aMonths = new Array("janv","f\xE9v","mars","avr","mai","juin","juil","ao\xFBt","sept","oct","nov","d\xE9c");
	}else{
	   aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	}
	
	return pDate.getDate() + " " + aMonths[pDate.getMonth()] + " " + pDate.getFullYear();
	
}
	
function sFormatDateNum(pDate) {

// Formats a date in numeric mm/dd/yyyy format as a string

	if(!pDate || pDate == "") return String(pDate);
	if(isNaN(pDate)) return String(pDate);

	return pDate.getMonth() + 1  + "/" + pDate.getDate() + "/" + pDate.getFullYear();
	
}
	

