
  var currentPageAction;
  var currentPageMode;
  var currentPageID;
  var currentPageGCDID;
  var currentPageDate;
  var currentPageHighlight;
  var currentSchoolAlias;

  function ajaxify(el, container){
    new Ajax.Request(el.href.replace('index.cfm', 'ajax.cfm'), {
      method: 'get',
      onSuccess: function(transport) {
        $(container).update(transport.responseText);
      }
    });
    
  }
  
  function switchDate(date){
    currentPageDate = date;
    ajaxifyURL(buildURL(wID), 'content');
  }
  function switchWidget(wID, mode, date, gcdID,  wFlipper){
    ajaxifyURL(buildWidgetURL(wID, mode, date, gcdID, wFlipper), wFlipper)
  }
  function ajaxifyURL(url, container){
    new Ajax.Request(url, {
      method: 'get',
      onSuccess: function(transport) {
        $(container).update(transport.responseText);
        
        $$('.'+currentPageHighlight).each(function(s){
                                             new Effect.Highlight(s);
                                  });
		         if(profileTabsOn)
                loadprofiletabs();
      }, onFailure:  function(transport){
        alert("something broke");
        }
    });
    //new Ajax.Updater(container, url);
  }

  function buildWidgetURL(wID, mode, date, gcdID, flipper){
    var tmpURL = '/ajaxw.cfm?a=' + currentPageAction;
    if (mode != '')
      tmpURL += '&mode=' + mode;
    if (date != '')
      tmpURL += '&date=' + date; 
    if (gcdID != '')
        tmpURL += '&gcdID=' + gcdID;
    if (flipper != '')
      tmpURL += '&c=' + flipper;
    if (wID != '')
      tmpURL += '&wID=' + wID;
	if (currentSchoolAlias != '')
	  tmpURL += '&s=' + currentSchoolAlias;
    //alert(currentSchoolAlias);
    return tmpURL;
  }
  
  function buildURL(wID){
    var tmpURL = '/ajax.cfm?a=' + currentPageAction;
    if (currentPageMode != '')
      tmpURL += '&mode=' + currentPageMode;
    if (currentPageID != '')
      tmpURL += '&id=' + currentPageID;
    if (currentPageGCDID != '')
      tmpURL += '&gcdID=' + currentPageGCDID;
    if (currentPageCCID != '')
      tmpURL += '&ccID=' + currentPageCCID;
    if (currentPageDate != '')
      tmpURL += '&date=' + currentPageDate;
    if (currentsectionID != '')
      tmpURL += '&section=' + currentsectionID;
    if (currentSchoolAlias != '')
      tmpURL += '&s=' + currentSchoolAlias;
    //alert(tmpURL);
    return tmpURL;
  }
  
  function toggleCat(el, cID){
    var name = el.identify();
    var curVal = el.checked
    el.checked = !curVal;
    
    if (curVal){
      $$('.cat_'+cID).each(function(s){ s.addClassName('hidden'); });
    }else{
      $$('.cat_'+cID).each(function(s){ s.removeClassName('hidden'); });
    }
    setTimeout('$(\''+name+'\').checked = !'+curVal, 1);
  }

  function $RF(el, radioGroup) {
      if($(el).type && $(el).type.toLowerCase() == 'radio') {
          var radioGroup = $(el).name;
          var el = $(el).form;
      } else if ($(el).tagName.toLowerCase() != 'form') {
          return false;
      }
      var checked = $(el).getInputs('radio', radioGroup).find(
          function(re) {return re.checked;}
      );
      return (checked) ? $F(checked) : null;
  }

