var dir = "";	// dnd sta el directorio principal
var nav = DetectarNavegador();
if (NavegadorValido(nav)) {
	document.writeln('<link rel="StyleSheet" href="'+dir+'estilosjs.css" media="screen" type="text/css"/>');
}

function NavegadorValido(nav) {
	var nombre = nav.substring(0,2);
	var version = parseInt(nav.charAt(2));
	switch (nombre) {
		case "IE":
			if (version >= 5) {
				return (true);
			} else {
				return (false);
			}
			break;
		case "NS":
			if (version >= 5) {
				return (true);
			} else {
				return (false);
			}
			break;
		case "OP":
			if (version >= 5) {
				return (true);
			} else {
				return (false);
			}
			break;
		case "KO":
			if (version >= 2) {
				return (true);
			} else {
				return (false);
			}
			break;
		default: return (false);
	}
}

function DetectarNavegador() {
	var detectar = navigator.userAgent.toLowerCase();
	var navegador,version,thestring;

	if (checkIt('konqueror')) navegador = "KO"	// Konqueror
	else if (checkIt('opera')) navegador = "OP"	// Opera
	else if (checkIt('msie')) navegador = "IE"	// Internet Explorer
	else if (!checkIt('compatible')) {
		navegador = "NS";			// Netscape
		version = detectar.charAt(8);
	} else navegador = "--";

	if (!version) version = detectar.charAt(place + thestring.length);

	function checkIt(string) {
		place = detectar.indexOf(string) + 1;
		thestring = string;
		return place;
	}
	return (navegador + version);
}

function heightDeVentanaUtil(nav) {
	switch (nav) {
		case "KO2":
		case "NS5":
		case "OP5": return(window.innerHeight); break;
		case "IE5":
		case "IE6":
		case "OP6":
		case "OP7": return(document.body.clientHeight); break;
	}
}

function widthDeVentanaUtil(nav) {
	switch (nav) {
		case "KO2":
		case "NS5":
		case "OP5": return(window.innerWidth); break;
		case "IE5":
		case "IE6":
		case "OP6":
		case "OP7": return(document.body.clientWidth); break;
	}
}

function mostrar(Id, nav) {
	document.getElementById(Id).style.visibility = 'visible';
}

function ocultar(Id, nav) {
	document.getElementById(Id).style.visibility = 'hidden';
}

function arrastrar(Id, x1, y1, x2, y2, pasos, s, nav) {
	// arrastra 'Id' de ('x1','y1') a ('x2','y2') en 'pasos' cantidad de pasos y 's' segundos
	var x1x2 = x2 - x1;
	var y1y2 = y2 - y1;
	var i;
	for (i=1; i<=pasos; i++) {
		setTimeout('mover("' + Id + '",' + (x1 + (i * (x1x2/pasos))) + ',' + (y1 + (i * (y1y2/pasos))) + ',"' + nav + '")', ((i * (s/pasos)) * 1000));
		i++;
	}
	// igual en el ultimo paso i*pxMov no es exactamente igual a (x2,y2), y como tiene q kedar igual...
	setTimeout('mover("' + Id + '",' + x2 + ',' + y2 + ',"' + nav + '")', ((i * (s/pasos)) * 1000));
}

function mover(Id,x,y,nav) {
	// mueve Id a (x,y)
	switch (nav) {
		case "KO2":
		case "IE5":
		case "IE6":
		case "NS5": {
			document.getElementById(Id).style.top = y + 'px';
			document.getElementById(Id).style.left = x + 'px';
		}
		break;
		case "OP5":
		case "OP6":
		case "OP7": {
			document.getElementById(Id).style.top = y;
			document.getElementById(Id).style.left = x;
		}
		break;
	}
}

