var n = 0;
var countInterval;

function checkearNavegador() {
			var browser=navigator.appName;
			var version=navigator.appVersion;
				if (browser == "Microsoft Internet Explorer") {
					var botones = new Array();
						for (i=1; i<=8; i++) {
							botones[i] = document.getElementById('link_'+i);
							botones[i].data = i;
							botones[i].onmouseover = function() { if (countInterval) { clearInterval(countInterval); } cambiarItem(this.id, this.data); }
							botones[i].onmouseout = function() { n=0; countInterval = setInterval(count, 50); }
						}
				}
}
		
function cambiarItem(cual, data) {
			var botones = new Array();
			var subBotones = new Array();
			for (i=data; i>0; i--) {
				document.getElementById('link_'+i).style.background = "url(images/bg.png)";
			}
			
			for (i=data; i<=8; i++) {
				botones[i] = document.getElementById('link_'+i);
				botones[i].style.background = "url(images/bg.png)";
			}
			if (document.URL.indexOf("sistemas") != -1) { 
			document.getElementById(cual).style.background = "url(../../images/bg_hover.png)";
			} else {
			document.getElementById(cual).style.background = "url(images/bg_hover.png)";
			}
			i = 0;
			a = document.getElementsByTagName("a");
			while (el = a[i++]) {
				if (el.className == "out") {
					a[i-1].onmouseout = function() { n=0; countInterval = setInterval(count, 50); this.style.background="url(images/test_transparencia.png)"; }
					a[i-1].onmouseover = function() { this.style.background="#ff9900"; if (countInterval) { clearInterval(countInterval); } }
				}
			}
}



function count() { 
	n = n+0.8;
	if (n == 0.8) {
		for (i=1; i<=8; i++) {
		document.getElementById('link_'+i).style.background = "url(images/bg.png)";
		}
		clearInterval(countInterval);
	}
}


function openWin(){
	myWindow=window.open('e-pami/e-pami.html','epami','toolbar=no,menubar=no,scrollbars=no,resizable=no,top=0,left=0,width=540,height=360');
	myWindow.focus();
}

function popup(url, titulo, options) { 
	myWindow=window.open(url,titulo,options);
	myWindow.focus();
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}	
