var timer = new Array();
var mainmenu_active_item = null;

function changeStyle(element, property, value){
  //alert("change "+ element+"-"+property+" to "+value)
  if(property.indexOf("-") != -1){
    var propArr = property.split("-");
    property = propArr[0]+propArr[1].substr(0,1).toUpperCase()+propArr[1].substr(1);
  }
  if(document.getElementById){
    if(document.getElementById(element)){
      document.getElementById(element).style[property] = value;
    }
  }
  else if(document.all){
    if(document.all[element]){
      document.all[element].style[property] = value;
    }
  }
}

function openWindow(url, t, width, height, properties){
  var left = screen.width/2 - width/2;
  var top = screen.height/2 - height/2;
  var props = "left="+left+", top="+top+", width="+width+", height="+height+", "+properties;
  win = window.open(url, t, props);
}

function confirmLink(link, text){
  if(confirm(text)){
    self.location.href = link;
  }
}

//Start PULLDOWN-MENU
function mainmenuHideSub(menuitem, ignore_mainmenu_item_style){
	
  if(!ignore_mainmenu_item_style)ignore_mainmenu_item_style = false;
  
  changeStyle("pulldownmenu_"+menuitem, "visibility", "hidden");
  if(ignore_mainmenu_item_style != true){
    if(document.getElementById("mainmenu_item_"+menuitem).className != mainmenu_active_item){
      changeStyle("mainmenu_item_"+menuitem, "backgroundImage", "url(images/mainmenu_item.gif)");
    }
  }
  
  if(mainmenu_active_item && mainmenu_active_item != menuitem){
    mainmenuIn(mainmenu_active_item);	
  }
}

function mainmenuOut(menuitem){
  if(mainmenu_active_item != menuitem){
    timer[menuitem] = setTimeout("mainmenuHideSub('"+menuitem+"')", 300);
  }
}

function mainmenuIn(menuitem){
  if(mainmenu_active_item && mainmenu_active_item != menuitem){
    mainmenuHideSub(mainmenu_active_item, true);	
  }
  changeStyle("pulldownmenu_"+menuitem, "visibility", "visible");
  if(document.getElementById("mainmenu_item_"+menuitem).className != mainmenu_active_item){
    changeStyle("mainmenu_item_"+menuitem, "backgroundImage", "url(images/mainmenu_item_hover.gif)");
  }
  clearTimeout(timer[menuitem]);
}
//End PULLDOWN-MENU