var lastSelectedNavigatorTab = null;

function change(obj, on, keres)
{
 if (keres == 1) {
  if (on) obj.style.backgroundImage = "url('img/keres_bg_mouseover.png')"; 
  else obj.style.backgroundImage = "url('img/keres_bg.png')"; 
 }
 else {
  if (on) obj.style.backgroundImage = "url('img/kinal_bg_mouseover.png')"; 
  else obj.style.backgroundImage = "url('img/kinal_bg.png')"; 
 }
}

function changeStyleOn(obj) {
 if (obj == null) return;
 if (obj.tagName != "TD" && obj.tagName != "td") return;
 if (obj.className.indexOf("_on") < 0) {
  obj.className = obj.className + "_on";
  obj.childNodes[0].style.color = "#ffffff";
 }
}

function changeStyleOff(obj) {
 if (obj == null) return;
 if (obj.tagName != "TD" && obj.tagName != "td") return;
 if (obj.className.indexOf("_on") > 0) {
  obj.className = obj.className.substring(0, obj.className.length - 3);
  obj.childNodes[0].style.color = "#8a2f02";
 }
}


function mouseOnNavigatorTab(obj) {
 if (obj == null) return;
 if (obj.tagName != "TD" && obj.tagName != "td") return;
 if (obj.style.backgroundImage.indexOf("selected") < 0) {
  setTabToSelect(obj);
 }
}

function mouseFromNavigatorTab(obj) {
 if (obj == null) return;
 if (obj.tagName != "TD" && obj.tagName != "td") return;
 if (obj.style.backgroundImage.indexOf("selected") > 0) {
  if (obj != lastSelectedNavigatorTab) setTabToBase(obj);
 }
}

function setTabToBase(obj)
{
  var t = obj.id.substring(4);
  document.getElementById('nav_l_' + t).src = "img/navigator_base_tab_left.png";
  document.getElementById('nav_r_' + t).src = "img/navigator_base_tab_right.png";
  document.getElementById('navl_' + t).style.color = "#ffffff";
  obj.style.backgroundImage = "url('img/navigator_base_tab.png')";
}
function setTabToSelect(obj)
{
  var t = obj.id.substring(4);
  document.getElementById('nav_l_' + t).src = "img/navigator_selected_tab_left.png";
  document.getElementById('nav_r_' + t).src = "img/navigator_selected_tab_righ.png";
  document.getElementById('navl_' + t).style.color = "#000000";
  obj.style.backgroundImage = "url('img/navigator_selected_tab.png')";
}

function nav_change(file, id)
{
 if (lastSelectedNavigatorTab != null) setTabToBase(lastSelectedNavigatorTab);
 var obj = document.getElementById('nav_' + id);
 setTabToSelect(obj);
 lastSelectedNavigatorTab = obj;
 if (file != "") {
  ajax_loadContent('navig_content', file);
 }
}