//************************Script Info**************************************************************
//Version: 1.0
//Date: 06/11/07
//Changes:
//Programmed by:  Charles McKinney
//*************************************************************************************************

/*Global Variables*/
var ScreenHeight = screen.availHeight;  //used to detect screen height
var ScreenWidth = screen.width;  //used to detect Screen Width
var StartLeft;  //used in mover function to store starting X position
var StartTop;  //used in mover function to store starting Y position
var OriginalStartValue; //used in fader to store starting value
var HideRevealArray = new Array();  //array of objects to reveal

//********************SetStyle function **************************************************

//  Purpose:  Use to change the specific style of an object.  Can change more than one style element
//            element id, style property name:style property value
//            if sending more than one property name/value separate with quotes and a comma
//
//  Arguments: ElementID = id of ElementID to change
//             PropValue = property and value to change it to (propertyname:value);
//
//  Date:     09/06/06
//  Changes:

//************************************************************************************************

function SetStyle(ElementID,PropValue) {

   var ThisObject;

   //netscape 4.7? and below are disallowed
   if (document.layers) {
     return false;
   }

   //detect browser set variable to find id of object if it exists

   //alert(ElementID + " " + PropValue); 
   if (document.all && document.all["" + ElementID + ""] != null)  ThisObject = document.all["" + ElementID + ""];
   if (document.getElementById && document.getElementById("" + ElementID + "") != null) ThisObject = document.getElementById("" + ElementID + "");

   if (ThisObject == undefined) {
     alert("PROGRAMMER ALERT:  Something is wrong.  Either the browser detection failed or the id you passed was invalid");
     return false;
   }

   for (var a = 1; a < SetStyle.arguments.length;a++) {

       //alert(SetStyle.arguments[a]);
       ThisProp = SetStyle.arguments[a].split(":");
       ThisPropName = ThisProp[0];
       ThisPropValue = ThisProp[1];

       //alert("ElementID=" + ThisObject.id + " prop=" + ThisPropName + " " + ThisPropValue);

       try {
         ThisObject.style[""+ThisPropName+""] = ThisPropValue;
       }
       catch(e) {
        alert("PROGRAMMER ALERT: Either the property name [" + ThisPropName + "] or the property value [" + ThisPropValue + "] are illegal.");
        return false;
       }

       //if (ThisObject.id == "alert_layer") FindProperties(ThisObject.id);
   }
}

//********************SetClass function **************************************************

//  Purpose:  Use to change the class of an object.
//            element id, class to change to
//
//  Arguments:  ElementID = Id of element to change
//              NewClass = css class to change it to
//
//  Date:     07/10/06
//  Changes:

//************************************************************************************************


function SetClass(ElementID,NewClass) {

 //alert("class change running for " + ElementID + ". Change class to " + NewClass);
   var ThisObject;

   if (document.layers) {
     return false;
   }

   if (document.all && document.all["" + ElementID + ""] != null)  ThisObject = document.all["" + ElementID + ""];
   if (document.getElementById && document.getElementById("" + ElementID + "") != null)  ThisObject = document.getElementById("" + ElementID + "");

   if (ThisObject == undefined) {
     alert("Something is wrong.  Either the browser detection failed or the id you passed was invalid");
     return false;
   }

   ThisObject.className = NewClass;
}

//********************ChangeStyleRules function **************************************************

//  Purpose:  Use to change specific style elements of a class.  Must know the array number of
//            the class you which to change.  Can change more than one style element
//            element id, style property name, style property value
//            if sending more than on property name/value separate with ":"
//            must have the same number of names and values
//
//  Arguments: CrulesArrayNum - numeric value of css class in the rules array to change
//             PropValue = The property and the value to change it to separated by a colon
//             "Property:value"
//
//  Date:     07/10/06
//  Changes:

//************************************************************************************************


function ChangeStyleRules(CrulesArrayNum,PropValue) {

   var theRules

   if (document.styleSheets[0].cssRules) theRules = document.styleSheets[0].cssRules;
   if (document.styleSheets[0].rules) theRules = document.styleSheets[0].rules;

   for (var a = 1; a < ChangeStyleRules.arguments.length;a++) {

       ThisProp = ChangeStyleRules.arguments[a].split(":");
       ThisPropName = ThisProp[0];
       ThisPropValue = ThisProp[1];

       try {
         theRules[CrulesArrayNum].style[""+ThisPropName+""] = ThisPropValue;
       }
       catch(e) {
        alert("PROGRAMMER ALERT: Either the property name [" + ThisPropName + "] or the property value [" + ThisPropValue + "] are illegal.");
        return false;
       }
   }
}

//********************InsertText function **************************************************
//  Purpose: pass an id and the content you wish to display and this will write it into
//           that space on the page
//
//  Arguments: ElementID: the id of the element to insert text into
//             AlertText:the text to insert
//
//  Caution:   I've seen some issues with passing html to the IE7 browser using this function.
//             If you run into problems let me know.
//
//  Date:     07/10/06
//  Changes:
//************************************************************************************************

function InsertText(ElementID,AlertText) {

     if (document.layers) {
        var ElemObject = document + "." + ElementID;
        if (ElemObject != null) {
          ElemObject.document.write(AlertText);
          ElemObject.document.close();
        }
     }

     if (document.all) {
        if (document.all["" + ElementID + ""] != null) {
          document.all["" + ElementID + ""].innerHTML=AlertText;
        }
     }

     if (document.getElementById) {
         var ElemObject = document.getElementById("" + ElementID + "");
         if (ElemObject != null) {
         document.getElementById("" + ElementID + "").innerHTML=AlertText;
        }
     }
}


//********************SetHideReveal function **************************************************
//  Purpose: To make a clickable object that will hide and and reveal other elements on the page.
//           When first clicked the container object will be revealed.  Click again and will be hidden
//           Can set a level so that items of the same level cannot be opened at the same time
//
//  Arguments: ElementHandler - the id of the clickable object
//.            ElementContainer - the id of the object to hide and reveal
//             Exclusive - a value for the level,  or blank if non-exclusive
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function SetHideReveal(ElemHandler,ElemContainer,Exclusive,DisplayType) {

  //alert("SetHideReveal: Handler= " + ElemHandler + " Container= " + ElemContainer + " Exclusive= " + Exclusive);
   
   if (DisplayType == "" || DisplayType == undefined) DisplayType = "block";
   
   EHandler = FindObjects(ElemHandler);
   if (EHandler === false) return true
   EHandler = EHandler[0];

   EContainer = FindObjects(ElemContainer);
   if (EContainer === false) return true
   EContainer = EContainer[0];
 
   //alert("Looking for " + ElemContainer + " found " + EContainer);
   //alert("Looking for " + ElemHandler + " found " + EHandler);

   EContainer.handler = EHandler;
   EContainer.hidereveal = true;

   if (Exclusive != undefined) {
     EContainer.exclusive = Exclusive;
     HideRevealArray[HideRevealArray.length] = EContainer;
   }

   SetStyle(EContainer.id,"display:none");
   EContainer.opened = false;

   EHandler.object = EContainer;
   EHandler.object.display_type = DisplayType;
   EHandler.hidereveal = true;
   EHandler.onclick = function() {CheckAll(this);}

   AddCheckAll(HideReveal);
}

//********************HideReveal function **************************************************
//  Purpose: Active function for SetHideReveal
//
//  Arguments: HandlerObject - the object that was clicked on
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function HideReveal(HandlerObject) {

   if (HandlerObject.hidereveal != true) return true;

   //alert(HandlerObject.id + " " + HandlerObject.object);
   ElemObject = HandlerObject.object;

   //alert("ID= " + ElemObject.id + " opened= " + ElemObject.opened  + " " + ElemObject.haserror);
   //alert("ID= " + ElemObject.id + " exclusive= " + ElemObject.exclusive);

   //alert(ElemObject.inputs);
   if (ElemObject.inputs != undefined) {
    var HasInputError = false;
    for (var a = 0; a < ElemObject.inputs.length; a++) {
        ThisInput = ElemObject.inputs[a];
        if (ThisInput.haserror == true) {
           HasInputError = true;
           ElemObject.badinput = ThisInput;
        }   
    }   
   }

   //alert(HasInputError);
   if (HasInputError) ElemObject.haserror = true;
   
   if (ElemObject.exclusive == true) {
     if (ElemObject.opened == false || ElemObject.haserror == true) {
        SetStyle(ElemObject.id,"display:"+ElemObject.display_type+"");
        ElemObject.opened = true;

        for (var a = 0; a < HideRevealArray.length;a++) {

          ThisObject = HideRevealArray[a];
          if (ThisObject != ElemObject && ThisObject.exclusive == ElemObject.exclusive) {
            SetStyle(ThisObject.id,"display:none");
            ThisObject.opened = false;
          }
        }
     } else {

        if (HasInputError == true) {
          if (ElemObject.badinput.type == "text" || ElemObject.badinput.type == "textarea") {
	       ElemObject.badinput.focus();
               ElemObject.badinput.select();
               return true;
          }    
        }   
                      
        SetStyle(ElemObject.id,"display:none");
        ElemObject.opened = false;
     }
   }

   if (ElemObject.exclusive == undefined || ElemObject.exclusive == false) {
    //alert(ElemObject.id + " " + ElemObject.opened + " " +  ElemObject.haserror);
   
   if (ElemObject.opened == false || ElemObject.haserror == true) {
       SetStyle(ElemObject.id,"display:"+ElemObject.display_type+"");
       ChangeBox(ElemObject);
       ElemObject.opened = true;
         if (ElemObject.haserror == true) {
          if (ElemObject.badinput.type == "text" || ElemObject.badinput.type == "textarea") {
	       ElemObject.badinput.focus();
               ElemObject.badinput.select();
          }    
        } 
        ElemObject.haserror = false; 
        return true;
    } else {
       SetStyle(ElemObject.id,"display:none");
       ChangeBox(ElemObject);
       ElemObject.opened = false;
    }
   }
  ElemObject.haserror = false; 
  return true;
}


//********************findPosX **************************************************
//  Purpose: Used to determine X position of an object on the page.
//           Returns the value of the position in pixels
//
//  Arguments: ElemObject - the object to find the position for
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function findPosX(ElemObject)
{
        var CurLeft = 0;
        if (ElemObject.offsetParent)
        {
                while (ElemObject.offsetParent)
                {
                        CurLeft += ElemObject.offsetLeft
                        ElemObject = ElemObject.offsetParent;
                }
        }
        else if (ElemObject.x)
                CurLeft += ElemObject.x;
        return CurLeft;
}

//********************findPosY **************************************************
//  Purpose: Used to determine Y position of an object on the page.
//           Returns the value of the position in pixels
//
//  Arguments: ElemObject - the object to find the position for
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function findPosY(ElemObject)
{
        var CurTop = 0;
        if (ElemObject.offsetParent)
        {
                while (ElemObject.offsetParent)
                {
                        CurTop += ElemObject.offsetTop
                        ElemObject = ElemObject.offsetParent;
                }
        }
        else if (ElemObject.y)
                CurTop += ElemObject.y;
        return CurTop;
}

//********************ElementSizer **************************************************
//  Purpose: Used to set the size of an object on the page
//           Checks available screen heigth and width anc complains if the values
//           for top and left are larger than that.
//
//  Arguments: ElemObject - the object to size
//             Height - the height of the object in pixels
//             Width - the width of the object in pixels
//             Top - The Y position to place the object in
//             Left - The X position to place the object in
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function ElementSizer(ElemObject,Height,Width,Top,Left) {

    if (Height > ScreenHeight) {
       alert("The Height " + Height + " passed is larger than than the available screen Height " + ScreenHeight + ".  Function will stop now.")
       return false;
    }

    if (Width > ScreenWidth) {
       alert("The Width " + Width + " passed is larger than than the available screen Width " + ScreenWidth + ".  Function will stop now.")
       return false;
    }

     PassLeft = "" + "left:" + Left + "";
     PassTop = ""+"top:"+Top+"";
     PassHeight = "" + "height:" + Height + "";
     PassWidth = ""+"width:"+Width+"";
     SetStyle(ElemObject.id,PassHeight,PassWidth,PassTop,PassLeft);
}

//********************ElementReSizer **************************************************
//  Purpose: Used to adjust the size of an object on the page
//
//  Arguments: ElemObject - the object to resize
//             AdjustValue - the number of pixels to adjust by
//             Operator - + to make larger
//                        - to make smaller
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function ReSizer(ElemObject,AdjustValue,Operator) {

     Width=0;
     Height=0;

     CurLeft = findPosX(ElemObject);
     CurTop = findPosY(ElemObject);
     CurWidth = ElemObject.offsetWidth;
     CurHeight = ElemObject.offsetHeight;

     //alert("left=" + CurLeft + " top=" + CurTop + " width=" + CurWidth + " Height=" + CurHeight);

     if (Operator == "+") {
       SetWidth = CurWidth + AdjustValue;
       SetHeight = CurHeight + AdjustValue;
       SetLeft = CurLeft - AdjustValue;
       SetTop =  CurTop - AdjustValue;
     }

     if (Operator == "-") {
       SetWidth = CurWidth - AdjustValue;
       SetHeight = CurHeight - AdjustValue;
       SetLeft = CurLeft + AdjustValue;
       SetTop = CurTop + AdjustValue;
     }

     //alert("width=" + ScreenWidth + " height=" + ScreenHeight);
     //alert("before left=" + SetLeft + " top=" + SetTop + " width=" + SetWidth + " Height=" + SetHeight);

     if (SetWidth >= ScreenWidth) SetWidth = ScreenWidth;
     if (SetHeight >= ScreenHeight) SetHeight = ScreenHeight;

     if (SetLeft < 0) SetLeft = 0;
     if ((SetLeft+SetWidth) > ScreenWidth) {
         AdjustLeft = ScreenWidth - (SetLeft+SetWidth);
         SetLeft = SetLeft - AdjustLeft;
     }

     if (SetTop < 0) SetTop = 0;
     if ((SetTop+SetHeight) > ScreenHeight) {
         AdjustTop = ScreenHeight - (SetTop+SetHeight);
         SetTop = SetTop - AdjustTop;
     }

     //alert("after left=" + SetLeft + " top=" + SetTop + " width=" + SetWidth + " Height=" + SetHeight);

     PassLeft = "" + "left:" + SetLeft + "";
     PassTop = ""+"top:"+SetTop+"";
     PassHeight = "" + "height:" + SetHeight + "";
     PassWidth = ""+"width:"+SetWidth+"";
     SetStyle(ElemObject.id,PassHeight,PassWidth,PassTop,PassLeft);
}

//********************FullScreen **************************************************
//  Purpose: Used to make a an object the full size of the page
//
//  Arguments: ElemObject - the object to resize
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************

function FullScreen(ElemObject) {

   NewLeft = 0;
   NewTop = 0;
   NewWidth = ScreenWidth;
   NewHeight = ScreenHeight-10;

   PassLeft = "" + "left:" + NewLeft + "";
   PassTop = ""+"top:"+NewTop+"";
   PassHeight = "" + "height:" + NewHeight + "";
   PassWidth = ""+"width:"+NewWidth+"";
   SetStyle(ElemObject.id,PassHeight,PassWidth,PassTop,PassLeft);
}

//********************MoveIt **************************************************
//  Purpose: Used to move an object on the screen
//
//  Arguments: ElemObject - the object to resize
//             AdjustVert - vertical adjustment to use in pixels
//             AdjustHor - horizontal adjustment to use in pixels
//             UseTimer - Time value (in milliseconds) to allow movement over time
//                        Set to 0 if no timer to be used
//             UseRandom - true = random adjustment of location
//                         false or missing = No random adjustment
//
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************

function MoveIt(ElemObject,AdjustVert,AdjustHor,UseTimer,UseRandom) {

    ThisObject = ElemObject;
    Vert = AdjustVert;
    Horz = AdjustHor;
    Timer = UseTimer;
    Random = UseRandom;

    ThisObject.speed = UseTimer;
    ThisObject.vert = AdjustVert;
    ThisObject.hor = AdjustHor;
    ThisObject.random = UseRandom;

    CurLeft = findPosX(ElemObject);
    CurTop = findPosY(ElemObject);
    CurWidth = ElemObject.offsetWidth;
    CurHeight = ElemObject.offsetHeight;

    MaxRight= (ScreenWidth-CurWidth)-AdjustHor;
    MaxDown = (ScreenHeight-CurHeight)-(AdjustVert*2);

    if ((CurLeft+AdjustHor) > MaxRight) AdjustHor=MaxRight-CurLeft;
    if ((CurTop+AdjustVert) > MaxDown) AdjustVert=MaxDown-CurTop;

    if (AdjustHor == 0) AdjustHor = Horz;
    if (AdjustVert == 0) AdjustVert = Vert;

    NewLeft = 0;
    NewTop = 0;

    if (UseRandom == true) {
       if (CurLeft == 0) {
         SelectString = "*+";
         NewDirection = RandomSelect(SelectString,2);
         if (NewDirection == "*") NewLeft = CurLeft;
         if (NewDirection == "+") NewLeft = CurLeft + AdjustHor;
       }

       if (CurLeft == MaxRight) {
         SelectString = "*-";
         NewDirection = RandomSelect(SelectString,2);
         if (NewDirection == "*") NewLeft = CurLeft;
         if (NewDirection == "-") NewLeft = CurLeft - AdjustHor;
       }

       if (CurLeft != 0 && CurLeft != MaxRight) {
         SelectString = "-*+";
         NewDirection = RandomSelect(SelectString,3);
         if (NewDirection == "*") NewLeft = CurLeft;
         if (NewDirection == "+") NewLeft = CurLeft + AdjustHor;
         if (NewDirection == "-") NewLeft = CurLeft - AdjustHor;
         if (NewLeft < 0) NewLeft=0;
         if (NewTop > MaxRight) NewTop = MaxLeft;
       }

       if (CurTop == 0) {
         SelectString = "*+";
         NewDirection = RandomSelect(SelectString,2);
         if (NewDirection == "*") NewTop = CurTop;
         if (NewDirection == "+") NewTop = CurTop + AdjustVert;
       }

       if (CurTop == MaxDown) {
         SelectString = "*-";
         NewDirection = RandomSelect(SelectString,2);
         if (NewDirection == "*") NewTop = CurTop;
         if (NewDirection == "-") NewTop = CurTop - AdjustVert;
       }

       if (CurTop != 0 && CurTop != MaxDown) {
         SelectString = "-*+";
         NewDirection = RandomSelect(SelectString,3);
         if (NewDirection == "*") NewTop = CurTop;
         if (NewDirection == "+") NewTop = CurTop + AdjustVert;
         if (NewDirection == "-") NewTop = CurTop - AdjustVert;
         if (NewTop > MaxDown) NewTop = MaxDown;
         if (NewTop < 0) NewTop = 0;
       }
     }

     if (UseRandom == false) {
        if (StartLeft == undefined) {
           SelectString = "-+";
           StartLeft = RandomSelect(SelectString,2);
        }
           if (CurLeft == 0) {
             if (StartLeft == "*" && (CurTop==0 || CurTop >= MaxDown)) StartLeft = "+";
             if (StartLeft == "-") {
               SelectString = "+*";
               StartLeft = RandomSelect(SelectString,2);
             }
           }
           if (CurLeft >= MaxRight) {
             if (StartLeft == "*" && (CurTop==0 || CurTop >= MaxDown)) StartLeft = "-";
             if (StartLeft == "+") {
               SelectString = "-*";
               StartLeft = RandomSelect(SelectString,2);
             }
           }

        if (StartTop == undefined) {
           SelectString = "-+";
           StartTop = RandomSelect(SelectString,2);
        }
           if (CurTop == 0) {
             if (StartTop == "*" && (CurLeft==0 || CurLeft >= MaxRight)) StartTop = "+";
             if (StartTop == "-")  {
               SelectString = "+*";
               StartTop = RandomSelect(SelectString,2);
             }
           }

           if (CurTop >= MaxDown) {
             if (StartTop == "*" && (CurLeft==0 || CurLeft >= MaxRight)) StartTop = "-";
             if (StartTop == "+") {
               SelectString = "-*";
               StartTop = RandomSelect(SelectString,2);
             }
           }

        if (StartTop == "+") NewTop = CurTop + AdjustVert;
        if (StartTop == "-") NewTop = CurTop - AdjustVert;
        if (StartTop == "*") NewTop = CurTop;

        if (StartLeft == "+") NewLeft = CurLeft + AdjustHor;
        if (StartLeft == "-") NewLeft = CurLeft - AdjustHor;
        if (StartLeft == "*") NewLeft = CurLeft;

        if (NewLeft < 0) NewLeft=0;
        if (NewTop < 0) NewTop = 0;
     }

     //alert("StartLeft="+ StartLeft+" maxright= " + MaxRight + " Curleft=" +CurLeft+ " NewLeft=" + NewLeft + " StartTop="+StartTop+" maxdown= " + MaxDown + " Curtop=" +CurTop+ " newtop="+NewTop);

     PassLeft = "" + "left:" + NewLeft + "";
     PassTop = ""+"top:"+NewTop+"";

     SetStyle(ElemObject.id,PassLeft,PassTop);

     if (UseTimer != 0) InMotion = setTimeout("MoveIt(ThisObject,Vert,Horz,Timer,Random);",UseTimer);
}

//********************ChangeSpeed **************************************************
//  Purpose: Used to change the rate of motion for an object on the screen
//
//  Arguments: ElemObject - the object to resize
//             AdjustValue - the value in milliseconds to adjust by
//             Operator - + = to move faster
//                        - = to move slower
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function ChangeSpeed(ElemObject,AdjustValue,Operator) {

    UseTimer = ElemObject.speed;
    AdjustVert = ElemObject.vert;
    AdjustHor = ElemObject.hor;
    UseRandom = ElemObject.random;

    if (Operator == "+")  UseTimer = UseTimer - AdjustValue;
    if (Operator == "-")  UseTimer = UseTimer + AdjustValue;

    StopTimer(InMotion);
    if (UseTimer != 0) MoveIt(ElemObject,AdjustVert,AdjustHor,UseTimer,UseRandom);
}

//********************RunFader **************************************************
//  Purpose: Used to fade and change text in an object
//
//  Arguments: ElemObject - the object to resize
//             StartValue - the Opacity value to start with
//             ChangeValue - the value to adjust by
//             Direction - + to adjust up, - to adjust down
//             RunTimer - value in milliseconds to change the opacity - ) for no timer
//             TextChange - Text to change to
//
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function RunFader(ElemObject,StartValue,ChangeValue,Direction,RunTimer,TextChange) {

    ThisObject = ElemObject;
    ThisDirection = Direction;
    StartV = StartValue;
    ChangeV = ChangeValue
    Timer = RunTimer;
    TChange = TextChange;
    NewOpacity = 0;
    MinValue = 0;
    MaxValue = 100;

    if (StartValue == 0) {
       ThisDirection = "+";
       if (TextChange != undefined) InsertText(ThisObject.id,TextChange);
    }

    if (StartValue == OriginalStartValue) {
       StopTimer(Fader);
       OriginalStartValue = undefined;
       return;
    }

    if (ThisDirection == "-") NewOpacity = StartValue-ChangeValue;
    if (ThisDirection == "+") NewOpacity = StartValue+ChangeValue;

    if (window.navigator.userAgent.toLowerCase().match("ie")) {
      PassOpacity = "" + "filter: alpha(opacity="+NewOpacity+")"+"";
    } else {
      if (NewOpacity == 100) {
        NewOpacity = 99;
        OriginalStartValue = 99;
      }
      PassOpacity = "" + "opacity:."+NewOpacity+"";
    }

    //alert(PassOpacity);
    SetStyle(ElemObject.id,PassOpacity);
    if (RunTimer != 0) fader = setTimeout("RunFader(ThisObject,NewOpacity,ChangeV,ThisDirection,Timer,TChange)",RunTimer);
    if (OriginalStartValue == undefined) OriginalStartValue = StartValue;
}


//********************ChangeBox **************************************************
//  Purpose: Used to change a box element from a + (closed) to a - (open)
//           For opening and closing sections on a page.
//
//  Arguments: ElemObject - the object to change the box for
//
//
//  Date:     06/11/07
//  Changes:
//************************************************************************************************


function ChangeBox(ElemObject) {

   //alert("changebox " + ElemObject.id + " " + ElemObject.opened + " " + ElemObject.Changeboxchk);
   
   if (ElemObject.Changeboxchk != true) return true;

   //alert("changebox " + ElemObject.id + " " + ElemObject.opened + " " + ElemObject.section.id);

   if (ElemObject.opened == false || ElemObject.section.haserror == true) {
     ThisBox = ElemObject.section.id + "_box";
     //ElemObject.opened = true;
     InsertText(ThisBox,"-");
     return true;
   }  
   
   //alert(ElemObject.section.id);
   
   if (ElemObject.opened == true) {
     ThisBox = ElemObject.section.id + "_box";
     //ElemObject.opened = false;     
     InsertText(ThisBox,"+");
   }  

 return true;
} 


function OpenPopDiv(ElemID) {

  if (ElemID == undefined) ElemID = "pop_div";
  
  SetStyle(ElemID,"display:block");

}

function ClosePopDiv(ElemID) {

    if (ElemID == undefined) ElemID = "pop_div";
    SetStyle(ElemID,"display:none");
}    
