﻿
//------------------------------------------------------------------------------------
//------------top menu items-----------------------------------------
function topmenu_showTopMenu(divID){
    showTopMenu(divID,500,500);
}
function topmenu_hideTopMenu(){
    hideTopMenu(500);
}

//------------------------------------------------------------------------------------
//------------top menu items-----------------------------------------


//------------------------------------------------------------------------------------
//------------Below functions are used by many differnt place-----------------------------------------
//------------------------------------------------------------------------------------
var lastMenuOvered = ""
var otimer = "";
var ctimer = "";
function showTopMenu(divID,inspeed,outspeed)
{
    //hideAllMainDropdownMenus();
    cancelhide(ctimer);
    if (lastMenuOvered != divID){
       lastMenuOvered =  divID
       
       dohideTopMenus(divID,outspeed)
       otimer = setTimeout("doShowTopMenu('" + divID + "'," +inspeed + ")", 500);
     }
}
function hideTopMenu(outspeed)
{
    cancelshow(otimer);
    ctimer = setTimeout("dohideTopMenus(''," + outspeed +")", 500);
}
function doShowTopMenu(divID,speed){
    var theobject = jQuery("#" + divID)
      var theoptical =  theobject.css("opacity") 
      var thevisible = theobject.is(':visible')
    if (!thevisible || theoptical < 1 )
    {
        //theobject.fxStop()
        if (!thevisible){
            theoptical = 0
            theobject.show();
        }
        if(theoptical < 1){
             theobject.css({'opacity':theoptical})
        }
        theobject.stop().animate({ opacity: 1 }, 'fast');
    }
}
function dohideTopMenus(notdivID,speed)
{
   jQuery(".submenuholder").each(
        function(){
            var theobject = jQuery(this);
            var theid = theobject.attr("ID")
            if (theobject.is(':visible')){
                if (theid != notdivID ){
                    theobject.fadeOut(speed);
                }
            }
        }
   )
   lastMenuOvered = "";
}
function dohideTopMenu(divID,speed){
    var theobject  = jQuery("#"+divID)
    if (theobject.is(':visible')){
           theobject.fadeOut(speed);
      }
}


function cancelshow(thetimer){
if (thetimer == null || typeof thetimer == 'undefine'){
    thetimer = otimer;
}
     if(thetimer != "") {
	    clearTimeout(thetimer);
	    thetimer = "";
	}
}
function cancelhide(thetimer){
if (thetimer == null || typeof thetimer == 'undefine'){
    thetimer = ctimer;
}
      if(thetimer != "") {
	    clearTimeout(thetimer);
	    thetimer = "";
	}
}


//--------------------------------------------------------------------------//



// set the default button     
function fnTrapKD(btnID, event){

var btn = document.getElementById(btnID)
if (btn){
 if (document.all){

  if (event.keyCode == 13){

   event.returnValue=false;

   event.cancel = true;

btn.focus();
 btn.click();

  }

 }

 else if (document.getElementById){

  if (event.which == 13){

   event.returnValue=false;

   event.cancel = true;

eval(btn.focus());
 eval(btn.click());

  }

 }

 else if(document.layers){

  if(event.which == 13){

   event.returnValue=false;

   event.cancel = true;
  alert("3") 
btn.focus();
 btn.click();

  }

 }

}
}
