var g_arrVars = new Array(); // global array of variables .    
var g_bSuppressLoading = false;

function FinishLoadingCover()
{
    if( g_bSuppressLoading == false ) {
        showHideLoadingCover( false );
        g_bSuppressLoading = true;
    }
}

function Wait()
{
	window.scrollTo(0, 0); // kick to top of page
    showHideLoadingCover( true, 'Please wait...' )
} // Wait


function showHideLoadingCover( bShow, sStatusMsg )
{
    var divContent = document.getElementById('divContent');         // defined in MBasePage   
    var divToCoverPage = document.getElementById('divToCoverPage'); // defined in default.aspx.cs       
    var iframeCover = document.getElementById('iframeCover');       // defined in default.aspx.cs    
    var strongStatus = document.getElementById('strongStatus');     // defined in default.aspx.cs
    
    if( strongStatus != null && sStatusMsg != null ) {
        strongStatus.innerHTML = sStatusMsg;
    }
    
    if( divContent != null && divToCoverPage != null ) {
        if( bShow == null || bShow == true) {
            if( divToCoverPage.style.width == null || divToCoverPage.style.width == '' ) {
                divToCoverPage.style.width = document.documentElement.clientWidth - 175 + "px";

                if( divContent.offsetHeight > document.documentElement.clientHeight - 180 ) {
                    divToCoverPage.style.height = divContent.offsetHeight + 25 + "px";
                }
                else {
                    divToCoverPage.style.height = document.documentElement.clientHeight - 180 + "px";                    
                }
                divToCoverPage.style.display = 'inline';
                iframeCover.style.width = divToCoverPage.style.width;
                iframeCover.style.height = divToCoverPage.style.height;
                iframeCover.style.display = 'inline';
            }
            else if( divToCoverPage.style.width != null && divToCoverPage.style.width != '') {
                divToCoverPage.style.display = 'inline';
                iframeCover.style.width = divToCoverPage.style.width;
                iframeCover.style.height = divToCoverPage.style.height;
                iframeCover.style.display = 'inline';
            }
        }
        else {
            divToCoverPage.style.display = 'none';
        }
    }
}

function ToggleTab( sTabID, sDivID, sReviewType )
{
    // current selection.
    var div = document.getElementById(sDivID);
    div.style.display='inline'; 
	
    var tab = document.getElementById(sTabID);
    tab.className = 'stepsTableOn';
    tab.style.visibility = 'visible';
    tab = document.getElementById(sTabID+'_left');		
    tab.className = 'stepsTableOnLeft';
    tab.style.visibility = 'visible';	        

    // previous selection.
    var tbl = document.getElementById('Steps');	
    var sPrevTabID = tbl.getAttribute('tabID');		
    var sPrevDivID = tbl.getAttribute('divID');

    if( (sPrevTabID != '' && sPrevDivID != '') && ( sTabID != sPrevTabID && sDivID != sPrevDivID) ) {
        var tabPrev = document.getElementById(sPrevTabID);
        var divPrev = document.getElementById(sPrevDivID);
        if( divPrev != null && tabPrev != null ) {
	        divPrev.style.display='none'; 
	        tabPrev.className = 'stepsTableOff';
            tabPrev = document.getElementById(sPrevTabID+'_left');		
            tabPrev.className = 'stepsTableOffLeft';	        
        }
    }

    tbl.setAttribute('divID', sDivID);	
    tbl.setAttribute('tabID', sTabID);
    
    /* BEGIN Special Handling - Review tab. */
    if( sTabID == 'TabStep6' ) {
        TransformReview( sReviewType ); // defined in test-selection-tab.js
    }
    /* END Special Handling - Review tab. */
}

function OpenPopup( sIDParentToClose, sIDChildToClose )
{
    var sIDDivToClose = '';    

    var parent = document.getElementById(sIDParentToClose);
    if( parent != null ) {  
        if(parent.tagName.toUpperCase() == 'TABLE') {
            parent.style.display = (window.ActiveXObject ? 'inline' : 'table'); 
        }
        else {
            parent.style.display = 'inline';
        }
    }

    var child = document.getElementById(sIDChildToClose);    
    if( child != null ) {
        if(child.tagName.toUpperCase() == 'TD') {
            child.style.display = (window.ActiveXObject ? 'inline' : 'table-cell'); 
        }
        else {            
            child.style.display = 'inline';
        }
        
        sIDDivToClose = child.getAttribute("activeChildID");
        if( sIDDivToClose != '' ) {
            var activeChild = document.getElementById(sIDDivToClose);    
            
            if( activeChild != null ) {
                if(activeChild.tagName.toUpperCase() == 'TD') {
                    activeChild.style.display = (window.ActiveXObject ? 'inline' : 'table-cell'); 
                }
                else {            
                    activeChild.style.display = 'inline';
                }
            }
        }
    }        

    /* BEGIN special handling */                                	        
    var divContent = document.getElementById('divContent');         // defined in MBasePage   
    var divOpaque = document.getElementById('divOpaque');
        
    if( divOpaque != null && ( divOpaque.style.display == null || divOpaque.style.display == '' || divOpaque.style.display == 'none')  ) {
        
        divOpaque.setAttribute("activeChildID", sIDDivToClose);
        var divToCoverPage = document.getElementById('divToCoverPage'); // defined in default.aspx.cs       
        
        if( divOpaque.style.width == null || divOpaque.style.width == '' || divOpaque.style.width == '0px' ) {
            divOpaque.style.width = document.documentElement.clientWidth - 175 + "px";

            if( divContent.offsetHeight > document.documentElement.clientHeight - 180 ) {
                divOpaque.style.height = divContent.offsetHeight + 25 + "px";
            }
            else {
                divOpaque.style.height = document.documentElement.clientHeight - 180 + "px";                    
            }
            divOpaque.style.display = 'inline';
        }
        else if( divOpaque.style.width != null && divOpaque.style.width != '' && divOpaque.style.width != '0px' ) {
            divOpaque.style.display = 'inline';
        }
    } 
    /* END special handling */   
}

function ClosePopup( sIDParentToClose, sIDChildToClose )
{
    var sIDDivToClose = '';
    
    var parent = document.getElementById(sIDParentToClose);    
    parent.style.display = 'none';

    var child = document.getElementById(sIDChildToClose);    
    if( child != null ) {
        child.style.display = 'none';
        
        sIDDivToClose = child.getAttribute("activeChildID");
        if( sIDDivToClose != '' ) {
            var activeChild = document.getElementById(sIDDivToClose);    
            if( activeChild != null ) {
                activeChild.style.display = 'none';
            }
        }
    }        

    /* BEGIN special handling */                                	        
    var divContent = document.getElementById('divContent');         // defined in MBasePage   
    var divOpaque = document.getElementById('divOpaque');
    var divOpaque_activeChildID = divOpaque.getAttribute("activeChildID");
        
    if( divOpaque != null && 
       (divOpaque.style.display != null && divOpaque.style.display == 'inline') &&
        divOpaque_activeChildID == sIDDivToClose ) {
        
        divOpaque.style.display = 'none';
        divOpaque.style.width = "0px"; 
        divOpaque.style.height = "0px";	
    } 
    /* END special handling */                          	    
}


function DisplayStatusByID( bShow, sLocalText, bShowImg, elem1ID, elem2ID, elem3ID )
{
    var img = document.getElementById(elem1ID);
    var tr = document.getElementById(elem2ID);
    var div = document.getElementById(elem3ID);
    
    DisplayStatus( bShow, sLocalText, bShowImg, img, tr, div );
}

function DisplayStatusBySuffx( bShow, sLocalText, bShowImg, suffx )
{
    var img = document.getElementById('imgLoading_'+suffx);
    var tr = document.getElementById('trLoadingStatus_'+suffx);
    var div = document.getElementById('divLoadingText_'+suffx);
    
    DisplayStatus( bShow, sLocalText, bShowImg, img, tr, div );
}

function DisplayStatus( bShow, sLocalText, bShowImg, img, tr, div )
{
    if( bShow != null && img != null && tr != null && div != null) {
        if( bShow == true ) {
            img.style.visibility = "visible";
            tr.style.visibility = "visible";
            div.innerHTML = sLocalText;
            div.style.display = "inline";
        }
        else {
            tr.style.visibility = "hidden";
            div.style.display = "none";
        }
    }
    
    if( bShowImg != null  && img != null && tr != null && div != null) {        
        if( bShowImg == false ) {
            img.style.visibility = "hidden";
        }
        else {
            img.style.visibility = "visible";
        }
    }
}



function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}


function encode(str) 
{
    try {
	    str = str.replace(/&/g, "&amp;");
	    str = str.replace(/'/g,"&apos;");	
	    str = str.replace(/</g,"&lt;");
	    str = str.replace(/>/g, "&gt;");
	    //str = str.replace(/\"/g, "&quot;");
	    return str;
	}
	catch (e)
	{
	    return "";
	}
}

function decode(str) 
{
    try {
	    str = str.replace(/&amp;/g, "&");
	    str = str.replace(/&apos;/g,"'");	
	    str = str.replace(/&quot;/g,"'");
	    str = str.replace(/&lt;/g,"<");
	    str = str.replace(/&gt;/g, ">");
	    return str;
    }
    catch (e)
    {
        return "";
    }
}


// sets focus to a given object id.
function PutFocus(m_FocusObj)
{
	var focusObj = document.getElementById(m_FocusObj);
	
	if(focusObj)
	{
		try { 
			focusObj.focus();
		} catch(e) {}
	}
}

// browser-based calls.
function SelectSingleNode(xmlDocument, xmlNode, sXPath)
{
	var xFoundNode = null;
	
	try {
		if (window.ActiveXObject){  //IE
			xFoundNode = xmlNode.selectSingleNode(sXPath);
		}

		else { // Mozilla
			xFoundNode = selectSingleNode(xmlDocument, xmlNode, sXPath);
		}
	}
	catch(e) {
		return null;
	}
	
	return xFoundNode;
}


function SelectSingleNodeText( xmlDocument, xmlNode, sXPath )
{
	var xFoundNode = null;
	var sText = "";
	
	xFoundNode = SelectSingleNode(xmlDocument, xmlNode, sXPath);
	
	try {
		if (window.ActiveXObject){  //IE
			sText = xFoundNode.text;
		}
		else { // Mozilla
			sText = xFoundNode.textContent;
		}
	}
	catch(e){}
	
	return sText;
}


function selectSingleNode(xmlDocument, xmlNode, sXPath)
{
	try {
		return xmlDocument.evaluate(sXPath, xmlNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
	} catch(e){return null;}

}


// a function to pad leading zeros.
// (see http://www.aspfaq.com/show.asp?id=2300)
function PadDigits(n, totalDigits) 
{ 
    n = n.toString(); 
    var pd = ''; 
    if (totalDigits > n.length) 
    { 
        for (i=0; i < (totalDigits-n.length); i++) 
        { 
            pd += '0'; 
        } 
    } 
    return pd + n.toString(); 
} 

// from OrderTests.ascx
function Trim(text) 
{ 
   //This will get rid of leading spaces 
   while(text.substring(0,1) == ' ') 
   {
      text = text.substring(1, text.length);
   }

   //This will get rid of trailing spaces 
   while (text.substring(text.length - 1, text.length) == ' ')
   {
      text = text.substring(0, text.length - 1);
   }

   return text;
} 


//Trims leading and trailing space from a string.
function jsTrim(sToTrim)
{
  return sToTrim.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function AutoTab(input, len, e)
{
    var isNN = (navigator.appName.indexOf('Netscape') != -1); 
    var keyCode = (isNN) ? e.which : e.keyCode; 
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !ContainsElement(filter,keyCode))
    {
        input.value = input.value.slice(0, len); 
        input.form[(GetIndex(input) + 1) % input.form.length].focus();
    }
    return false; 
}

//Check whether element is present
function ContainsElement(arr, ele)
{
	var found = false, index = 0; 
	while(!found && index < arr.length)
	{
		if(arr[index] == ele)
		{
			found = true; 
		}
		else
		{
			index++;
		}
	}
	return found; 
}

function GetIndex(input)
{
    var index = -1, i = 0, found = false; 
    while(i < input.form.length && index == -1)
    {
        if(input.form[i] == input)
        {
        index = i;
        }
        else
        {
        i++; 
        }
    }
    return index; 
}



//Diagnosis Codes popup. ---------------------------------------------------------------

/* Passes the id's of the textboxes that are used for Diagnosis Codes. 
(both case-level and specimen-level). */
function DiagCodeFocus(n)
{
	var delim = ":";
	document.getElementById('hfDiagnosisCodes').value = "";
	
	if(document.getElementById('hfDiagnosisCodes') != null)
	{
 		var hfArr = n.split(delim);
 		
		for(i=0; i<hfArr.length; i++) //# of textboxes (Diag Codes)
		{
			document.getElementById('hfDiagnosisCodes').value += hfArr[i];
		
			if(i < hfArr.length-1)
			{
				document.getElementById('hfDiagnosisCodes').value += delim;
			}
		}
	}
}


//Focused element --------------------------------------------------------
function GetFocusedElement(e)
{
	var focussedElement = null;
	var agt = navigator.userAgent.toLowerCase();

	//Get the focussed element.
	if(agt.indexOf("ie") > -1) //IE
	{
		focussedElement =  event.target ? event.target : event.srcElement;
	}
	else //Mozilla
	{
		focussedElement =  e.target ? e.target : e.srcElement;
	}
	
	return focussedElement;
}

//Key pressed -------------------------------------------------------------
function GetKeyPressed(e)
{
	var pKeyPressed = null;
	var agt = navigator.userAgent.toLowerCase();

	//Get the focussed element.
	if(agt.indexOf("ie") > -1) //IE
	{
		pKeyPressed = document.all? window.event.keyCode:e.which;
	}
	else //Mozilla
	{
		pKeyPressed = document.all? e.keyCode : e.which;
	}
	
	return pKeyPressed;
}

//Enter key ---------------------------------------------------------------
function HandleKeyPresses(e) 
{
	var pKeyPressed = GetKeyPressed(e);
	var focussedElement = GetFocusedElement(e);
	var agt = navigator.userAgent.toLowerCase();
		
	//Handle certain keys.
	switch(pKeyPressed)
	{
		case KEY_ENTER:
		{
			//Do we have the hidden field with our default button?
			if(document.getElementById('hfEnterKeyBtn') != null)
			{
				//Cancel the enter key event. 
				//(so submit buttons, such as ImageButton, will not postback twice)
				if(agt.indexOf("ie") > -1) //IE
				{
					document.all ? window.event.returnValue=false : e.returnValue=false;
					document.all ? window.event.cancel=true : e.cancel = true;
				}
				else //Mozilla
				{
					e.returnValue=false;
					e.cancel = true;
				}

                var ctrlID = document.getElementById('hfEnterKeyBtn').value;
                if( ctrlID != '' ) {
				    var defBtn = document.getElementById(ctrlID);
				    //Does the value of the default button actually exist as an element?
				    if(defBtn != null)
				    {
					    //if a button other than the default button has focus, 
					    //then execute it's click instead.
					    if(focussedElement != null && (focussedElement.id != defBtn.id) )
					    {
						    //Make sure it's a button before we try to use click.
						    if(focussedElement.type == "image" || focussedElement.type == "button")
							    focussedElement.click()
						    else
							    defBtn.click();
					    }
					    else
						    defBtn.click();
				    }
				}
				else //no default button specified, so use the focused one.
				{
					//Make sure it's a button before we try to use click.
					if(focussedElement.type == "image" || focussedElement.type == "button")
						focussedElement.click()
				}
			}
		    break;
		}
	    default:
	        break;
	}
}


KEY_BACKSPACE = 8;
KEY_ZERO = 48;
KEY_NINE = 57;
KEY_ENTER = 13;
WHICH_TAB = 0;
KEY_TAB = 9;  
dKEY_ZERO = 96;
dKEY_NINE = 105; 
ARROW_KEY_L = 37;
ARROW_KEY_U = 38;
ARROW_KEY_R = 39;
ARROW_KEY_D = 40;
DELETE_KEY = 46;


document.onkeypress = HandleKeyPresses;
if (document.layers)
	document.captureEvents(Event.KEYPRESS);


//Sets the focus to a pre-determined input field on the form.
function SetInputFocus()
{
	//Do we have the hidden field with our custom focus element?
	if(document.getElementById('hfInputFocus') != null)
	{
	    var ctrlID = document.getElementById('hfInputFocus').value;
	    
	    if( ctrlID != '' ) {
		    var defFocus = document.getElementById(ctrlID);
    		
		    //Does the value of the custom focus actually exist as an element?
		    if(defFocus != null)
		    {
			    try {
				    defFocus.focus();
				    return;
			    }
			    catch(e){}
		    }
		}
	}
	try {
	    //Set focus to the first input/select element on form.
        var divContent = document.getElementById('divContent');
        var inputs = divContent.getElementsByTagName('INPUT');

	    for (var i = 0; i < inputs.length; i++)	{
		    var elem = inputs[i];
    		
		    //Set the first input/select that is visible or not hidden input.
		    if( elem.type == 'text' ) { 
		        if ((elem.style.display != null && elem.style.display == 'none') || 
		        (elem.style.visibility != null && elem.style.visibility == 'hidden') || 
		        (elem.className != null && elem.className == 'MCDate') ) {
		            continue;
		        }
    		    
			    try	{
				    elem.focus();
				    return;
			    }
			    catch(e){}
		    }
	    }
	}
	catch (z){}
}


function ValidateDOB(iMonth, iDay, iYear)
{
	var dtNow = new Date();
	var month = dtNow.getMonth()+1;

	if(iYear > dtNow.getFullYear())
	{
		alert('Date of birth (Year) cannot be in the future.');
		return false;	
	}
	
	if (iMonth >= month && 
	iDay > dtNow.getDate() && 
	iYear >= dtNow.getFullYear())
	{
		alert('Date of birth (Day) cannot be in the future.');
		return false;
	}
	
	if (iMonth > month && 
	iYear >= dtNow.getFullYear())
	{
		alert('Date of birth (Month) cannot be in the future.');
		return false;
	}
	
	return true;
}

function ValidateAge(iAge, ageType)
{
	//Do not allow negative age.
	if(iAge < 0)
	{
		alert('Age cannot be negative.');
		return false;
	}
	
	var dtNow = new Date();


	switch(ageType)
	{
		case "Days":
			if(dtNow.getFullYear() - (iAge/365) < 1801)
			{
				alert('Age: Days can range from 1 - ' + 365*(dtNow.getFullYear() - 1801) + '.');
				return false;
			}		
			break;
		
		case "Weeks":
			if((dtNow.getFullYear() - 1801)*52 < iAge)
			{
				alert('Age: Weeks can range from 1 - ' + (dtNow.getFullYear() - 1801)*52 + '.');
				return false;
			}		
			break;

		case "Months":
			if((dtNow.getFullYear() - 1801)*12 < iAge)
			{
				alert('Age: Months can range from 1 - ' + (dtNow.getFullYear() - 1801)*12 + '.');
				return false;
			}		
			break;


		case "Years":
			if(dtNow.getFullYear() - iAge < 1801)
			{
				alert('Age: Age (approximated) can range from 1 - ' + (dtNow.getFullYear() - 1801) + ".");
				return false;
			}		
			break;
	}
		
	
	return true;
}

// JScript File
// Code Copied from
// http://www.webreference.com/programming/javascript/mk/column2/
// Written By: Mark Kahn

document.onmousemove = mouseMove;
document.onmouseup   = mouseUp;

var dragObject  = null;
var dragObjectTrail  = null;
var mouseOffset = null;

function getMouseOffset(target, ev){
	ev = ev || window.event;

	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}

function mouseMove(ev){
	ev           = ev || window.event;
	var mousePos = mouseCoords(ev);

	if(dragObject){
		dragObject.style.position = 'absolute';
		dragObject.style.top      = mousePos.y - mouseOffset.y - 134 + 'px';
		dragObject.style.left     = mousePos.x - mouseOffset.x - 172 + 'px';
		return false;
	}
}
function mouseUp(){
	dragObject = null;
	dragObjectTrail = null;
}

function makeDraggable(e, element, iframeID){
   var item = document.getElementById(element);
	dragObject  = item;
	mouseOffset = getMouseOffset(item, e);
   
   if( iframeID != null ) {
       var iframe = document.getElementById(iframeID);   
	    dragObjectTrail  = iframe;
        if(dragObjectTrail){
	        dragObjectTrail.style.position = 'absolute';
	        dragObjectTrail.style.top      = dragObject.style.top;
	        dragObjectTrail.style.left     = dragObject.style.left;
        }
   }
}
var cc11 = 0;
function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	if(ev.clientX || ev.clientY) 
	{
	   if(cc11==0)
	   {
	      //var cc22 = ev.clientX;
	      //alert(scrOfX);
	      cc11++;
	   }
     var scrOfX = 0, scrOfY = 0;
     if( typeof( window.pageYOffset ) == 'number' ) {
       //Netscape compliant
       scrOfY = window.pageYOffset;
       scrOfX = window.pageXOffset;
     } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
       //DOM compliant
       scrOfY = document.body.scrollTop;
       scrOfX = document.body.scrollLeft;
     } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
       //IE6 standards compliant mode
       scrOfY = document.documentElement.scrollTop;
       scrOfX = document.documentElement.scrollLeft;
     }
	   return { x:ev.clientX + scrOfX - document.documentElement.clientLeft, y:ev.clientY + scrOfY  - document.documentElement.clientTop }
	}
}

function isNumeric(charToCheck)
{
	var returnValue = "N";
	var charCode = charToCheck.charCodeAt(0);
	
	if(charCode >= "0".charCodeAt(0) && charCode <= "9".charCodeAt(0))
	{
	 	returnValue = "Y";
	}
	
	return returnValue;
}

// from http://www.web-source.net/web_development/currency_formatting.htm
function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function PrintLabels( toAppendID, input )
{
    showHideLoadingCover( true, 'Printing labels...' );	                		

    var applet = document.createElement('applet');
    applet.setAttribute('codeBase', input.getAttribute('codeBase'));
    applet.setAttribute('archive', input.getAttribute('archive'));
    applet.setAttribute('code', input.getAttribute('code'));
    applet.setAttribute('width', '1'); //input.getAttribute('width'));
    applet.setAttribute('height', '1'); // input.getAttribute('height'));

    var param1 = document.createElement('param');
    param1.setAttribute('name', 'PRINT_SETTINGS_URL');
    param1.setAttribute('value', input.getAttribute('PRINT_SETTINGS_URL'));                   
    applet.appendChild(param1);

    // omit this param. Otherwise, the applet tried to redirect anyway.
    if( input.getAttribute('REDIRECTURL') != null && input.getAttribute('REDIRECTURL') != '' ) {
        var param2 = document.createElement('param');
        param2.setAttribute('name', 'REDIRECTURL');
        param2.setAttribute('value', input.getAttribute('REDIRECTURL'));                   
        applet.appendChild(param2);
    }

    var param3 = document.createElement('param');
    param3.setAttribute('name', 'LABELCONTENT');
    param3.setAttribute('value', input.getAttribute('LABELCONTENT'));                   
    applet.appendChild(param3);

    // call the applet here...
    document.getElementById(toAppendID).appendChild(applet);	
}

function isNumberKey(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;

 return true;
}
function textCounter( field, maxlimit ) {
  if ( field.value.length >= maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    alert( 'This can only be ' + maxlimit + ' characters in length.' );
    return false;
  }
}


