/* library.js */

var toggledDisplay = new Object();

function toggleDisplay(bDisplayed)
{
  if(!document.getElementById || toggleDisplay.arguments.length < 2) return;
  var displayed = new Object();
      displayed['true'] = 'block';
      displayed['false'] = 'none';
  for(var i = 1; i < toggleDisplay.arguments.length; i++)
  {
    oDisplay = document.getElementById(toggleDisplay.arguments[i]);
    if(oDisplay)
    {
      oDisplay.style.display = displayed[bDisplayed];
      if(bDisplayed)
      {
        oImages = oDisplay.getElementsByTagName('IMG');
        for(var j = 0; j < oImages.length; j++)
          oImages[j].src = oImages[j].src;
      }
       if(typeof toggledDisplay[toggleDisplay.arguments[i]] != 'undefined')
        toggledDisplay[toggleDisplay.arguments[i]] = !bDisplayed;
    }
  }
}

var PrevLocationID = 0;
function SelectLocationID()
{
    var PrevCampaignID = document.getElementById('PreviousCampaignID').value;
    PrevLocationID = document.getElementById('PreviousLocationID').value;

    if(PrevCampaignID && PrevLocationID)
    {
        getCampLocations(document.getElementById('CampaignID'), PrevLocationID);
    }
}




/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005
************************************************************************************************************/	

var ajax = new sack();

/*Drop Down for Volunteer Form*/
		function getChildVolunteerLocations(sel)
			{
				var ParentLocationID = sel.options[sel.selectedIndex].value;
				document.getElementById('ChildVolLocationID').options.length = 0; 
				if(ParentLocationID.length>0){
					ajax.requestFile = '/admin/getChildVolunteerLocations.asp?ParentLocationID='+ParentLocationID;	// Specifying which file to get
					ajax.onCompletion = createChildVolunteerLocations;	// Specify function that will be executed after file has been found
					ajax.runAJAX();		// Execute AJAX function
				}
			}

		function createChildVolunteerLocations()
			{
				var obj = document.getElementById('ChildVolLocationID');
				eval(ajax.response);	// Executing the response from Ajax as Javascript code	
			}



/*Drop Down for Parent and Child Locations*/
		function getChildLocations(sel)
			{
				var ParentLocationID = sel.options[sel.selectedIndex].value;
				document.getElementById('ChildLocationID').options.length = 0; 
				if(ParentLocationID.length>0){
					ajax.requestFile = '/admin/getChildLocations.asp?ParentLocationID='+ParentLocationID;
					ajax.onCompletion = createChildLocations;	
					ajax.runAJAX();
				}
			}

		function createChildLocations()
			{
				var obj = document.getElementById('ChildLocationID');
				eval(ajax.response);
			}



/*Drop Down for Campaigns and Child Locations*/
		function getCampLocations(sel)
			{
				var CampaignID = sel.options[sel.selectedIndex].value;
				document.getElementById('LocationID').options.length = 0; 
				if(CampaignID.length>0){
					ajax.requestFile = '/admin/getCampLocations.asp?CampaignID='+CampaignID;
					ajax.onCompletion = createCampLocations;
					ajax.runAJAX();
				}
			}

		function createCampLocations()
			{
				var obj = document.getElementById('LocationID');
				eval(ajax.response);

                        if(PrevLocationID != 0)
                        {
                            for(var i=0; obj.options[i]; i++)
                            {
                                var CurrentLocID = obj.options[i].value;
                                if(CurrentLocID == PrevLocationID)
                                {
                                    obj.selectedIndex = i;
                                    break;
                                }
                            }
                        }
			}


/*Drop Down for Campaigns and Child Locations Used on Delivery Lists*/
		function getCampLocationsMap(sel)
			{
				var CampaignID = sel.options[sel.selectedIndex].value;
				document.getElementById('MapLocationID').options.length = 0; 
				if(CampaignID.length>0){
					ajax.requestFile = '/admin/getCampLocationsMap.asp?CampaignID='+CampaignID;
					ajax.onCompletion = createCampLocationsMap;
					ajax.runAJAX();
				}
			}

		function createCampLocationsMap()
			{
				var obj = document.getElementById('MapLocationID');
				eval(ajax.response);
			}
