

function changeLocation(objXML)
{
   var aLanguages = objXML.documentElement.getElementsByTagName("LanguageOptions");
   var objLang = document.getElementById("selLanguageID");
   var strSelectedLanguage = objLang.value;

   if(objLang)
   {
      objLang.innerHTML = "";
      
      //Get collection of org group type options and add each item to select options.
      var objLanguageOptions = aLanguages[0].getElementsByTagName("option");
      if(objLanguageOptions.length)
      {
         for(i = 0; i < objLanguageOptions.length; i++)
         {
            objLang.options[i] = new Option(objLanguageOptions[i].firstChild.nodeValue, objLanguageOptions[i].getAttribute("value"));
            if(objLanguageOptions[i].getAttribute("selected"))
               objLang.options[i].selected = true;
         }
      }
   }
}


//Clears all search criteria from the search inputs.
function clearSearch(strForm, strUserDateInputPattern, strClearLanguage)
{
   var objForm = document.forms[strForm];
   var objHideErrors = document.getElementById("divHideErrors");
   var objErrortxtBeginDate = document.getElementById("divErrortxtBeginDate");
   var objErrortxtEndDate = document.getElementById("divErrortxtEndDate");
   
   if (objHideErrors.style.display != "none")
   { 
      objHideErrors.style.display = "none"; 
   }

   if (objErrortxtBeginDate.style.display != "none")
   { 
      objErrortxtBeginDate.style.display = "none"; 
   }
   
   if (objErrortxtEndDate.style.display != "none")
   { 
      objErrortxtEndDate.style.display = "none"; 
   }
   
   if(objForm.selLocation)
      objForm.selLocation.className = "";
      objForm.selLocation.selectedIndex = 0;
   if(objForm.selLanguageID)
      objForm.selLanguageID.innerHTML = "";
      objForm.selLanguageID.options[0] = new Option(strClearLanguage, 0);
      objForm.selLanguageID.options[0].selected = true;
      objForm.selLanguageID.selectedIndex = 0;
   if(objForm.txtBeginDate)
      objForm.txtBeginDate.className = "";
      objForm.txtBeginDate.value = strUserDateInputPattern;
   if(objForm.txtEndDate)
      objForm.txtEndDate.className = "";
      objForm.txtEndDate.value = strUserDateInputPattern;
   if(objForm.txtSearch)
      objForm.txtSearch.className = "";
      objForm.txtSearch.value = "";
}


// Expands/collpases the details for all conventions.
function toggleAllConvDetails(strHideClass)
{
   if(!document.getElementById) 
      return;

   var objDivCollapse = document.getElementById('divCollapseAllConvDetails');
   var objDivExpand = document.getElementById('divExpandAllConvDetails');  
   var objExpandState = document.getElementById('txtConvDetailsView');
   
   var regexpHideClass = new RegExp("\\s*\\b" + strHideClass + "\\b", "g");
   var blnCollapse = false;
   
   if(objExpandState.value == "1")
   {
      //User has chosen to hide the details.
      //First hide collapse div and show expand div.
      objDivCollapse.className = objDivCollapse.className + " " + strHideClass;
      objDivExpand.className = objDivExpand.className.replace(regexpHideClass, "");
      
      objExpandState.value = "0";
      
      blnCollapse = true;
      
      var strImage = "images/tree-plus.gif";
      
      //save the choice to the cookie
      setCookie('ckConvDetailsView', 0);
   }
   else
   {
      //User has chosen to expand the details.
      //First hide expand div and show collapse div.
      objDivExpand.className = objDivExpand.className + " " + strHideClass;
      objDivCollapse.className = objDivCollapse.className.replace(regexpHideClass, "");
      
      objExpandState.value = "1";
      
      var strImage = "images/tree-minus.gif";
      
      //save the choice to the cookie
      setCookie('ckConvDetailsView', 1);
   }
   
   var aImages = document.getElementsByTagName("img");
   for(var i=0; i<aImages.length; i++)
   {
      if(aImages[i].id.indexOf("imgToggleConvDetails") > -1)
         aImages[i].src = strImage; 
   }
   
   var aDivs = document.getElementsByTagName("div");
   for(var i = 0; i < aDivs.length; i++)
   {
      if(aDivs[i].id.indexOf("divConvDetails") > -1)
      {
         if(blnCollapse)
            aDivs[i].className = aDivs[i].className + " " + strHideClass;
         else
            aDivs[i].className = aDivs[i].className.replace(regexpHideClass, "");
      }
   }
}


// Expands/collpases the details for a single convention.
function toggleConvDetails(intConvOrgUnitID, strHideClass)
{
   if(!document.getElementById) 
      return;
   
   //Get all possible contact detail divs.  Some of these may not actually
   //exist since the convention may not have a transliterated name/addr
   //or notes.  However it will always have a physical addr.
   var objDivPhysAddr = document.getElementById("divConvDetailsPhysAddr[" + intConvOrgUnitID + "]");
   var objDivTrnslitdAddr = document.getElementById("divConvDetailsTrnslitdAddr[" + intConvOrgUnitID + "]");
   var objDivNotes = document.getElementById("divConvDetailsNotes[" + intConvOrgUnitID + "]");
   
   var objImg = document.getElementById("imgToggleConvDetails[" + intConvOrgUnitID + "]");  
   
   if(objDivPhysAddr)
   {
      var regexpHideClass = new RegExp("\\s*\\b" + strHideClass + "\\b", "g");
      if(objDivPhysAddr.className.match(regexpHideClass))
      {
         objDivPhysAddr.className = objDivPhysAddr.className.replace(regexpHideClass, "");
         objImg.src = "images/tree-minus.gif";
         
         //Optional divs.  Set className if they are found.
         if(objDivTrnslitdAddr)
            objDivTrnslitdAddr.className = objDivTrnslitdAddr.className.replace(regexpHideClass, "");
         if(objDivNotes)
            objDivNotes.className = objDivNotes.className.replace(regexpHideClass, "");
      }
      else
      {
         objDivPhysAddr.className = objDivPhysAddr.className + " " + strHideClass;
         objImg.src = "images/tree-plus.gif";
         
         //Optional divs.  Set className if they are found.
         if(objDivTrnslitdAddr)
            objDivTrnslitdAddr.className = objDivTrnslitdAddr.className + " " + strHideClass;
         if(objDivNotes)
            objDivNotes.className = objDivNotes.className + " " + strHideClass;
      }
   }
}

