
	// Valido browser
	function checkIt(string) {
		return navigator.userAgent.toLowerCase().indexOf(string) + 1;
	}

	// Control ventana detalle busqueda
	var oldOfertaId = 0;
	function verOferta(obj, id, width) {
		var iWidth = width ? width : 420;
		document.getElementById("vOferta").style.display = "none";
		if (oldOfertaId != id && id != 0) {
			document.getElementById("iOferta").src = "busqueda_resumen.php?bqID=" + id;
			document.getElementById("lOferta").innerHTML = "Busqueda " + id;
			document.getElementById("vOferta").style.width = iWidth;
			document.getElementById("vOferta").style.top = findPosY(obj) + 5;
			document.getElementById("vOferta").style.left = findPosX(obj) + 5;
			document.getElementById("vOferta").style.display = "block";
			oldOfertaId = id;

		} else 
			oldOfertaId = 0
	}

	// Control ventana miITL
	function viewMiITL() {
		if (document.getElementById("vMiITL").style.display != "none") {
			document.getElementById("iMiITL").src = "";
			document.getElementById("vMiITL").style.display = "none";
		} else {
			document.getElementById("iMiITL").src = "miITL.php";
			var winl = (screen.width - 450) / 2;
			var wint = ((screen.height - 250) / 2) - 100;
			document.getElementById("vMiITL").style.top = wint;
			document.getElementById("vMiITL").style.left = winl;
			document.getElementById("vMiITL").style.display = "block";
		}
	}

	// Control ventana miITL
	function closeMiITL() {
		window.parent.document.getElementById("iMiITL").src = "";
		window.parent.document.getElementById("vMiITL").style.display = "none";
	}

	// Enmascaro un campo para slo aceptar numeros
	function onlyNumber() {
	    if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46)
		    if ((event.keyCode < 96 || event.keyCode > 105) && event.keyCode != 8 && event.keyCode != 37 && event.keyCode != 39)
		        event.returnValue = false;
	}

	// Enmascaro un campo para solo aceptar alafnumericos
	function onlyAlpha() {
	    if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46)
		    if ((event.keyCode < 96 || event.keyCode > 105))
			    if ((event.keyCode < 65 || event.keyCode > 90))
					event.returnValue = false;
	}

	// Recargo window
	function reloadSelf() {
		window.location.reload()
	}

	// Recargo parent
	function reloadParent() {
		var urlParent = window.parent.document.location.toString().split('#');
		window.parent.document.location = urlParent[0];
	}

	// Ventana de edicion
	var metodoHistory = "";
	function windowAction(source, obj, title) {
		var windowAction = new getObj('windowAction');
		var sTitulo = new getObj('sTitulo');
		var iAction = new getObj('iAction');
		var posX = findPosX(obj);
		var posY = findPosY(obj);

		if (metodoHistory == source) {
			windowAction.style.display = "none";
			metodoHistory = "";
			iAction.obj.src = "";

		} else {
			iAction.obj.src = source;
			sTitulo.obj.innerHTML = title;
			windowAction.style.top = posY + 5;
			windowAction.style.left = posX - 480;
			windowAction.style.width = 500;
			windowAction.style.display = "block";
			metodoHistory = source;
		}
	}

	// Ventana de edicion personalizada
	function windowActionParent(source, posX, posY, title) {
		var windowAction = new getParentObj('windowAction');
		var sTitulo = new getParentObj('sTitulo');
		var iAction = new getParentObj('iAction');

		if (metodoHistory == source) {
			windowAction.style.display = "none";
			metodoHistoryPersonal = "";
			iAction.obj.src = "";

		} else {
			iAction.obj.src = source;
			sTitulo.obj.innerHTML = title;
			windowAction.style.top = posY - 20;
			windowAction.style.left = posX - 20;
			windowAction.style.display = "block";
			metodoHistoryPersonal = source;
		}
	}

	// Ventana de edicion personalizada
	var metodoHistoryPersonal = "";
	function windowActionPersonal(source, posX, posY, title) {
		var windowAction = new getParentObj('windowActionPersonal');
		var sTitulo = new getParentObj('sTituloPersonal');
		var iAction = new getParentObj('iActionPersonal');

		if (metodoHistory == source) {
			windowAction.style.display = "none";
			metodoHistoryPersonal = "";
			iAction.obj.src = "";

		} else {
			iAction.obj.src = source;
			sTitulo.obj.innerHTML = title;
			windowAction.style.top = posY - 20;
			windowAction.style.left = posX - 20;
			windowAction.style.display = "block";
			metodoHistoryPersonal = source;
		}
	}

	// Cierro ventana de edicion
	function windowClose() {
		var windowAction = new getObj('windowAction');
		windowAction.style.display = "none";
		var iAction = new getObj('iAction');
		iAction.obj.src = "";
		metodoHistory = "";
	}

	// Cierro ventana de edicion
	function windowCloseParent() {
		var windowAction = new getParentObj('windowAction');
		windowAction.style.display = "none";
		var iAction = new getParentObj('iAction');
		iAction.obj.src = "";
		metodoHistory = "";
	}

	// Cierro ventana de edicion
	function windowCloseParentPersonal() {
		var windowAction = new getParentObj('windowActionPersonal');
		windowAction.style.display = "none";
		var iAction = new getParentObj('iAction');
		iAction.obj.src = "";
		metodoHistory = "";
	}

	// Calculo altua del iframe
	function setHeight(ref, pref) {
		var altura = setObjHeight(ref); var prefijo = pref ? pref : '';
		if (altura > 0) {
			var contenedor = new getParentObj('windowAction' + prefijo); 
			var contenido = new getParentObj('iAction' + prefijo);
			contenedor.style.height = (altura + 15); 
			contenido.style.height = (altura + 25);
		}
	}

	// Calculo altua del iframe
	function iSetHeightMiITL(ref) {
		var altura = setObjHeight(ref);
		if (altura > 0) {
			var contenedor = new getParentObj('vMiITL'); 
			var contenido = new getParentObj('iMiITL');
			contenedor.style.height = (altura + 35); 
			contenido.style.height = (altura + 37);
		}
	}

	// Reposiciono ventana ubicacion hacia arriba
	function setPositionDown() {
		var contenedor = new getParentObj('windowAction'); 
		var top = contenedor.style.top.split("px"); 
		var height = contenedor.style.height.split("px"); 
		contenedor.style.top = top[0] - (height[0] / 2) - 40;
	}

	// Reposiciono ventana ubicacion hacia arriba
	function resizeParent(px) {
		var contenedor = new getParentObj('windowAction');
		var iAction = new getObj('iAction');

		var left = contenedor.style.left.split("px");
		var width = contenedor.style.width.split("px");

		contenedor.style.left = (left[0] - (px - width[0]));
		contenedor.style.width = px;
	}






	function setObjHeight(obj) {
		var bloque = new getObj(obj); return bloque.obj.clientHeight;
	}
	function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curleft += obj.offsetLeft; obj = obj.offsetParent;
			}
		}
		else if (obj.x) curleft += obj.x;
		return curleft;
	}
	function findPosY(obj) {
		var curtop = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop; obj = obj.offsetParent;
			}
		}
		else if (obj.y) curtop += obj.y;
		return curtop;
	}
	function getObj(name) {
		if (document.getElementById) {
			this.obj = document.getElementById(name); this.style = document.getElementById(name).style;
		} else if (document.all) {
			this.obj = document.all[name]; this.style = document.all[name].style;
		} else if (document.layers) {
			this.obj = document.layers[name]; this.style = document.layers[name];
		}
	}
	function getParentObj(name) {
		if (window.parent.document.getElementById) {
			this.obj = window.parent.document.getElementById(name); this.style = window.parent.document.getElementById(name).style;
		} else if (window.parent.document.all) {
			this.obj = window.parent.document.all[name]; this.style = window.parent.document.all[name].style;
		} else if (window.parent.document.layers) {
			this.obj = window.parent.document.layers[name]; this.style = window.parent.document.layers[name];
		}
	}
