function areYouSure(text) {
     return confirm(text);
}

function preloadPage(preloadElement, postloadElement) { 
if (document.getElementById) {
    document.getElementById(preloadElement).style.display = 'none';
    document.getElementById(postloadElement).style.display = 'block';
}
    return;
}

function setElement(element, value) {
    var theElement = document.getElementById(element);
    theElement.value = value;
    return;
}

function toggleVisibility(element, elementId) {
    var theElement = document.getElementById(element);
    if(theElement.style.display == 'none') {
        theElement.style.display = 'block';
    }
    else {
        theElement.style.display = 'none';
    }
    if(elementId != undefined)
    {
        var toggleTextObject = document.getElementById(elementId);
        //if(toggleTextObject.innerHTML == '+')
	//    toggleTextObject.innerHTML = '-';
	//else
	//    toggleTextObject.innerHTML = '+';
    }
    return;
}

/**
 * Delete all child nodes for a given Id
 */
function deleteChildNodes(Id)
{
    var parentElement = document.getElementById(Id);

    if ( parentElement.hasChildNodes() )
    {
        while ( parentElement.childNodes.length >= 1 )
        {
            parentElement.removeChild( parentElement.firstChild );       
        } 
    }
    return;
}

activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis = navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}

window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu('nav'); 
    /* activateMenu('vertnav'); */
}
/**
 * popup()
 * Loads up a simple popup window.
 */
function popup(url,windowName) {
    /* newwindow=window.open(url,windowName,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600'); */
    var newwindow = window.open(url,windowName,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,fullscreen=yes');
    if (window.focus) {newwindow.focus()}
        return false;
}
function popupsize(url,windowName,width,height) {
    newwindow=window.open(url,windowName,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height);
    if (window.focus) {newwindow.focus()}
        return false;
}


function selectAllCheckboxes(formName, selected)
{
    targetform = document.getElementById(formName);
    for (i = 0; i < targetform.elements.length; i++)
    {
        if (targetform.elements[i].type == "checkbox")
	{
	    targetform.elements[i].checked = selected;
	}
    }
}

function toggleCheckBoxes(formName)
{
   targetform = document.getElementById(formName);
   for (i = 0; i < targetform.elements.length; i++)
   {
     if (targetform.elements[i].type == "checkbox")
     {
       if(targetform.elements[i].checked == false)
       {
         targetform.elements[i].checked = true;
       }
       else
       {
         targetform.elements[i].checked = false;
       }
     }
   }
}

/*
function ToggleCheckBoxes(FormName, FieldName, CheckValue)
{
    if(!document.forms[FormName])
        return;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
        return;
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
        objCheckBoxes.checked = CheckValue;
    else
        // set the check value for all check boxes
        for(var i = 0; i < countCheckBoxes; i++)
            objCheckBoxes[i].checked = CheckValue;
}
*/

function replaceMMText(text)
{
    var chrTest=text.value.charCodeAt(0);

    var chr8217=String.fromCharCode(8217);
    var chr39=String.fromCharCode(39);
    var lineIn=text.value;
    var lineOut="";

    lineOut = lineIn.replace(new RegExp(chr8217,"g"),chr39);
    text.value = lineOut;
}
									     
