var obj = null;
var hovering = false;
var IE7_PNG_SUFFIX = ".png";


function checkHover() {
  if(!hovering && obj){

     $('#subitems'+ obj[0].id.substring(4,6)).hide();
  }
} //checkHover


$(document).ready(function() {

  
  if(typeof sIFR == "function"){

    // This is the preferred "named argument" syntax
    sIFR.replaceElement(named({sSelector:"h1.flash", sFlashSrc:"metaCaps.swf", sColor:"#c41230", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:20, nPaddingBottom:20,sWmode:"opaque", sFlashVars:"textalign=left&offsetTop=0;"}));

    // This is the preferred "named argument" syntax
    sIFR.replaceElement(named({sSelector:"h2.flash", sFlashSrc:"metaCaps.swf", sColor:"#373737", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:20, nPaddingBottom:20,sWmode:"opaque", sFlashVars:"textalign=left&offsetTop=0;"}));

    // This is the preferred "named argument" syntax
    sIFR.replaceElement(named({sSelector:"h3.flash", sFlashSrc:"metaCaps.swf", sColor:"#000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:20, nPaddingBottom:20,sWmode:"opaque", sFlashVars:"textalign=left&offsetTop=0;"}));
  }


  $(".menu_item").hover(
    function () {
      //$(this).children('img').attr('src','/images/menu_'+$(this).attr('id')+'_hover.png');

      if (obj){

        $('#subitems'+ obj[0].id.substring(4,6)).hide();
        obj = null;
      } //if
   
      if(hovering)
         hovering = false;

  
      $('#subitems'+this.id.substring(4,6)).show();

    }, 
    function () {
      //$(this).children('img').attr('src','/images/menu_'+$(this).attr('id')+'.png');

      obj = $(this);
      setTimeout(
         "checkHover()",
      200);
  });

  $('.menu_subitems').hover(function(){
    //$(this).prev().children('img').attr('src','/images/menu_'+$(this).prev().attr('id')+'_hover.png');
    hovering = true;
   },function(){

    //$(this).prev().children('img').attr('src','/images/menu_'+$(this).prev().attr('id')+'.png');

    hovering = false;
    setTimeout(
       "checkHover()",
    200);
  });

  $(".menu_sub_middle").find('li').hover(
    function(){
      $(this).css('background','#FAFEE7');
      defaultPath = $(this).children('img').attr('src');
      $(this).children('img').attr('src',defaultPath.substring(0,defaultPath.length-4) + "_hover.png");
    }, 
    function () {
      $(this).css('background','none');
      defaultPath = $(this).children('img').attr('src');
      $(this).children('img').attr('src',defaultPath.substring(0,defaultPath.length-10) + ".png");
    }
  );

  $('input[name=\'search\']').click(function(){
     $(this).val('');
     $(this).css({backgroundColor: '#FDFDF4'});            
  });

});

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

