// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


validateForms = function() {
	for(i=0;i<document.forms.length;i++) {
		new Validation(document.forms[i],{immediate : true}); // OR new Validation(document.forms[0]);
	};
}
//if (window.attachEvent) window.attachEvent("onload", validateForms);
Event.observe(window, 'load', validateForms, false);

function openBox(closeChildren,openThis) {
	$(closeChildren).childElements().each(function(item){item.removeClassName('newmail')});
	openThis.parentNode.addClassName('newmail');	
}





function openWin(name,target,width,height) {
  	dlg = window.open (target,name,"width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	dlg.focus();
}
function newWin(name,target) {
  	dlg = window.open (target,name,"width='100%',height='100%',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
	dlg.focus();
}
function openChild(file,window) {
	childWindow=open(file,window,'resizable=yes,width=800,height=500,scrollbars=yes');
	// if (childWindow.opener == null) childWindow.opener = self;
	childWindow.opener = self;
}

function deleteThis(itemtype,itemidfield,itemid) {
	var oktoSend=confirm("Are you sure you want to delete this "+itemtype+"?");
	if (oktoSend){
		itemidfield.value=itemid;
		itemidfield.form.action.value='delete';
		itemidfield.form.submit();
	}
}

function updateForm(action,itemidfield,itemid,itemvaluefield,itemvalue) {
		itemidfield.value=itemid;
		itemvaluefield.value=itemvalue;
		itemidfield.form.action.value=action;
		itemidfield.form.submit();
}