window.onload = function(){
 SetMenu();
 SetForm();
 Initialize();
};

function SetMenu(){
 ['globalMenu', 'tleftArea', 'schoolRecital'].each(
  function(id){
   var div = $(id);
   if(div){
    div.select('a').each(
     function(anchor){
      var src = anchor.down().src;
      if(regexp = src.match(/[^_]\.(gif|jpg|png)$/)){
       var image = new Image();
       image.src = src.replace(/\.(gif|jpg|png)$/, '_.' + regexp[1]);
       anchor.onmouseover = function(){
        ChangeImage(this);
       };
       anchor.onmouseout = function(){
        RestoreImage(this);
       };
      }
     }
    );
   }
  }
 );
}
function SetForm(){
 if(form = $(document.forms[0])){
  Event.observe(form, 'keypress',
   function(event){
    var tag = event.element().tagName.toLowerCase();
    var type = event.element().type;
    if(event.keyCode == Event.KEY_RETURN && (tag == 'input' && !(type == 'button' || type == 'submit') || tag == 'select')){
     var input = form.getInputs('submit').first();
     if(input){
      input.click();
     }
     event.stop();
    }
   }
  );
 }
}
function Initialize(){
}

function Open(href, size){
 var pos = [Math.floor((screen.availWidth - size[0]) / 2), Math.floor((screen.availHeight - size[1]) / 3)];
 open(href, '_blank', ['left='+pos[0], 'top='+pos[1], 'width='+size[0], 'height='+size[1], 'menubar=no', 'toolbar=no', 'location=no', 'directories=no', 'scrollbars=yes', 'status=yes', 'resizable=yes'].join(','));
}
function Redirect(href, msec){
 href = (href || location.href);
 setTimeout('location.href="'+href+'"', msec ? msec : 0);
}

function ChangeImage(parent){
 var image = parent.down();
 if(regexp = image.src.match(/[^_]\.(gif|jpg|png)$/)){
  image.src = image.src.replace(/\.(gif|jpg|png)$/, '_.' + regexp[1]);
 }
}
function RestoreImage(parent){
 var image = parent.down();
 if(regexp = image.src.match(/_\.(gif|jpg|png)$/)){
  image.src = image.src.replace(/_\.(gif|jpg|png)$/, '.' + regexp[1]);
 }
}
