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

// Mirrors the value of one form field into another, so that when
// you change field1, field2 is automatically updated with the same
// value. field1 and field2 are both strings containing the id of
// the field elements
function mirrorFieldValues(field1,field2) {
	//$(field2).disabled = true;
	new Form.Element.Observer(field1,1,function() {
		$(field2).value = $F(field1);
	});
}

// create a rollover effect for the element give in parameter 
function core_rollover(element, backgroundColor, highlightColor) {
  if (((typeof element == 'object') || 
        (typeof element == 'function')) && 
        (element.length))
    element = element;
  else
    element = $(element);

  Event.observe(element, 'mouseover', function(e) { Element.setStyle(element,{backgroundColor: highlightColor}); }, false);
  Event.observe(element, 'mouseout', function(e) { Element.setStyle(element,{backgroundColor: backgroundColor}); }, false);       
}

// create a rollover effect on each element which owns a specific className for IE !
function rolloverForIE(className, backgroundColor, highlightColor) {
    if (/MSIE/.test(navigator.userAgent) == false)
      return;

    if (className == null || className.length == 0)
      return false;

		var nodesList = document.getElementsByClassName(className);
		
		$A(nodesList).each(function(node) {
		    if (/headerRow/.test(node.className) == false)
				  core_rollover(node, backgroundColor, highlightColor);
			});
}
