var Utils = {
  updater: function(updateId, url) {
    new Ajax.Updater(updateId, url, {asynchronous:true, evalScripts:true});
    $(updateId).innerHTML = 
      "<div align='center' style='margin:2em'><img src='/img/loading.gif'></div>";
  },
  
  submit: function(updateId, url, formId) {
	new Ajax.Updater(updateId, url, {parameters:Form.serialize(formId), 
	  asynchronous:true, evalScripts:true});
	$(updateId).innerHTML = 
	  "<div align='center' style='margin:2em'><img src='/img/loading.gif'></div>";
  },
  
  cssWindow: function(url, t, w, h, c, m) {
	t = (t)? t : "&nbsp;";
	w = (w)? w : 700;
	h = (h)? h : 450;
	c = (c)? c : "mac_os_x";
	m = (m)? false : true;
	win = new Window({className:c, title:t, width:w, height:h, destroyOnClose:true, showEffect:Element.show, hideEffect:Element.hide, maxWidth:750, maxHeight:550});
	win.setAjaxContent(url, {asynchronous:true, evalScripts:true});
	win.showCenter(m);
  },
  
  cssDialog: function(URL, w, h) {
  	w = (w)? w : 400;
	h = (h)? h : 300;
  	Dialog.info({url:URL}, {width:w, height:h, showProgress: true});
  }, 
  
  openWindow: function(url, w, h) {
	w = (w)? w : 700;
	h = (h)? h : 450;
	win = window.open(url, "pop", "width="+w+",height="+h+",scrollbars=yes,resizable=yes");
	win.focus();
  },
  
  onToggle: function(a, toggleId, url, showLabel, hideLabel) {
	showLabel = (showLabel)? showLabel : "<img src='/img/toggle_down.jpg' title='show' />";
	hideLabel = (hideLabel)? hideLabel : "<img src='/img/toggle_up.jpg' title='hide' />";
	if ($(toggleId).visible()) {
	  a.innerHTML = showLabel;
	} else {
	  a.innerHTML = hideLabel;
	  if (url) {
	  	updater(toggleId, url);
	  }
	}
	Effect.toggle(toggleId);
  },
  
  unset: function(id) {
    $(id).value = '';
  },
  
  contact: function() {
  	Utils.cssWindow('/home/contact', 'Contact');	
  },
  
  selectAll: function(checkboxObj, checkboxesObj) {
	if (checkboxObj.checked == true) {
  		for (i=0; i<checkboxesObj.length; i++) {
  			checkboxesObj[i].checked = true;		
  		}
  	} else {
  		for (i=0; i<checkboxesObj.length; i++) {
  			checkboxesObj[i].checked = false;		
  		}
  	}
  }  
}