initPage = function (){ 	
  // clear hint text in text input fields on focus
  if ($$('input.clearonfocus')){ 
    $$('input.clearonfocus').map( function(element){
  	  element.observe('click', function(event){  		 
  		  element.removeClassName('clearonfocus');
  		  element.writeAttribute('value', '');
  	  });
  	});
  }
  
  // enlarged textarea field on focus
  if ($$('textarea.enlargeonfocus')){ 
    $$('textarea.enlargeonfocus').map( function(element){
      element.observe('click', function(event){
        if (!element.hasClassName('large')) {
          element.addClassName('large');
        }
      });
    });
  } 
  
  // clear alert class from input fields 
  if ($$('.required')){ 
    $$('.required').map( function(element){
      element.observe('click', function(event){
        if (element.hasClassName('alert')) {
          element.removeClassName('alert');
        }
      });
    });
  }    
  
  // clear alert class from select fields 
  if ($$('select.required')){ 
    $$('select.required').map( function(element){
      element.observe('click', function(event){
        if (element.hasClassName('alert')) {
          element.removeClassName('alert');
        }
      });
    });
  }      
    
  // auto-focus fields
  if ($$('.focus')){ 
    $$('.focus').map( function(element){
      element.focus();
    });
  }    
  
  // showcase highlighting
  /*if ($('showcase')){ 
	/*@cc_on
	@if (@_jscript_version <= 5.6)
	  return;
	@else @*/
	
	/*@end @*/ 
	    	
    $$('#showcase div.imageContainer').map( function(element){    	  
      var thumbEl = element.up('div.thumbnail'); 
      element.observe('mouseover', function(event){
        showcaseHighlight(thumbEl);
      });   
      element.observe('mouseout', function(event){
        showcaseRemoveHighlight(thumbEl);
      });
    });
  } */     
  
  //setTimeout ( "updateToolbar()", 1000 ); 
}

// clear hint text in search fields on submit
submitSearch = function (){ 
  if ($('searchkey') && $('searchkey').hasClassName('clearonfocus')) $('searchkey').writeAttribute('value', '');
}

// select all checkboxes
selectAll = function (){ 
  if ($$('td.checkbox')){ 
    $$('td.checkbox input').map( function(element){
      element.writeAttribute('checked', 'checked');
    });
  }   
}  

// clear all checkboxes
clearAll = function (){ 
  if ($$('td.checkbox')){ 
    $$('td.checkbox input').map( function(element){
      element.removeAttribute('checked');
    });
  }   
}    

// toggle titter updates
toggleTwitterUpdates = function (){ 
  $('twitter_div').toggle();
}    

limitChars = function (id, limit) {
  new PeriodicalExecuter(function () {
   checkChars(id, limit);
  }, 0.2);  
}

checkChars = function (id, limit) {  
  if ($F(id).length > limit) $(id).value = $F(id).substr(0, limit);
  
  $(id+'_chars').update(limit - $F(id).length);  
}

showGeoMap = function () {
  Shadowbox.open({
    player:     'iframe',        
    title:      '',      
    content:    "/?cmd=geomap.show",    
    width:     640,
    height:    380
  });
}

//document.observe("dom:loaded", initPage );

