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

function SetMenu(){
 ['mainmenu', 'pricemenu0'].each(
  function(id){
   var div = $(id);
   if(div){
    div.select('a').each(
     function(anchor){
      switch(id){
       case 'pricemenu0':
        var div = anchor.up();
        if(div.className == 'blind'){
         div.setOpacity(anchor.href == location.href ? 0.01 : 0.0);
         div.setStyle({top : (navigator.userAgent.match(/[^\w]MSIE(\s+)[567]\./) ? -1 : 0) + 'px', height : (div.previous().down().down().height - 2) + 'px'});
         anchor.onmouseover = function(){
          ShowBlind(this);
         };
         anchor.onmouseout = function(){
          HideBlind(this);
         };
        }
        break;
       default:
        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);
         };
        }
        break;
      }
     }
    );
   }
  }
 );
}
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]);
 }
}

function ShowBlind(anchor){
 var div = anchor.up();
 if(div.getOpacity() == 0.0){
  div.visualEffect('Morph', {from : 0.0, to : 1.0, duration : 0.3, style : {height : (div.down().down().height + 1) + 'px'}});
 }
 div.setOpacity(1.0);
}
function HideBlind(anchor){
 var div = anchor.up();
 if(div.getOpacity() == 1.0){
  div.visualEffect('Morph', {from : 0.99, to : 1.0, duration : 0.3, style : {height : (div.previous().down().down().height - 2) + 'px'}});
 }
 div.up().up().select('div.blind').each(
  function(div){
   div.setOpacity(0.0);
  }
 );
}

