function vaciarCmb(nombre){
	var objeto = document.getElementById(nombre);
	objeto.options.length = 1;
/*	can = objeto.options.length;
	if(can>1){
		for(i=1; i<can; i++){
			objeto.remove(i);
			objeto.options[i]=null;
		}
	}*/
}

function mandar(formulario, pagina){
//	document.getElementById(formulario).target = '_self';
	document.forms[formulario].target = '_self';
//	document.getElementById(formulario).method = 'post';
	document.forms[formulario].method = 'post';
//	document.getElementById(formulario).action = pagina;
	document.forms[formulario].action = pagina;
//	document.getElementById(formulario).submit();
	document.forms[formulario].submit();
}

function irA(enlace){
	document.location.href = enlace;
}

function cambiaImg(esto, accion, activo, imagen){
//activo = 1 - noactivo = 0 o cualquier cosa
	if(activo==1){
		if(accion=='entrar'){
			esto.style.cursor = 'pointer';
			esto.src = esto.src.replace(imagen, imagen+'sel');
		}else{
			if(accion=='salir'){
				esto.style.cursor = 'default';
				esto.src = esto.src.replace(imagen+'sel', imagen)
			}
		}
	}
	return true;
}

function llenarTxt(obj, valor){
	document.getElementById(obj).value = "";
	document.getElementById(obj).value = valor;
}

function showdiv(event, id, titulo){
	var ie6 = false;
	var ie7 = false;
	var ie8 = false;
	var ns = false;
	if (navigator.appName.indexOf('Explorer')>0){
	   	if(navigator.userAgent.indexOf('MSIE 6')>0 && navigator.userAgent.indexOf('MSIE 7')==-1) {
   		   ie6 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 7')>0){
   		   ie7 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 8')>0){
   		   ie8 = true;
		}
	}else{
   		ns = true;
	}
	//determina un margen de pixels del div al raton
	marginRight=10;
	marginTop=10;

	//La variable IE determina si estamos utilizando IE
	var IE = document.all?true:false;
	var tempX = 0;
	var tempY = 0;

	//document.body.clientHeight = devuelve la altura del body
	if(ie6 || ie7 || ie8){ //para IE
		//event.y|event.clientY = devuelve la posicion en relacion a la parte superior visible del navegador
		//event.screenY = devuelve la posicion del cursor en relaciona la parte superior de la pantalla
		//event.offsetY = devuelve la posicion del mouse en relacion a la posicion superior de la caja donde se ha pulsado
		tempX = event.clientX;
		tempY = event.clientY;
		if(window.pageYOffset){
			tempY=(tempY+window.pageYOffset);
			tempX=(tempX+window.pageXOffset);
		}else{
			tempY=(tempY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));
			tempX=(tempX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));
		}
	}else{ //para netscape
		//window.pageYOffset = devuelve el tamaņo en pixels de la parte superior no visible (scroll) de la pagina
		document.captureEvents(Event.MOUSEMOVE);
		tempX = event.pageX;
		tempY = event.pageY;
	}

	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}

	//modificamos el valor del id posicion para indicar la posicion del mouse
	document.getElementById(id).innerHTML = "<img src='/images/prod/pro_" + titulo + "_pre.jpg' border='1' style='border-color: #333333'>";

	//window.alert(event.pageYOffset+" - "+document.body.pageYOffset+" - "+screen.pageYOffset+" - "+this.pageYOffset+" - "+window.pageYOffset);

	document.getElementById(id).style.top = (tempY+marginTop)+"px";
	document.getElementById(id).style.left = (tempX+marginRight)+"px";
	document.getElementById(id).style.display='block';
	return;
}

function showdivCadena(event, id, titulo){
	var ie6 = false;
	var ie7 = false;
	var ie8 = false;
	var ns = false;
	if (navigator.appName.indexOf('Explorer')>0){
	   	if(navigator.userAgent.indexOf('MSIE 6')>0 && navigator.userAgent.indexOf('MSIE 7')==-1) {
   		   ie6 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 7')>0){
   		   ie7 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 8')>0){
   		   ie8 = true;
		}
	}else{
   		ns = true;
	}
	//determina un margen de pixels del div al raton
	marginRight=10;
	marginTop=10;

	//La variable IE determina si estamos utilizando IE
	var IE = document.all?true:false;
	var tempX = 0;
	var tempY = 0;

	//document.body.clientHeight = devuelve la altura del body
	if(ie6 || ie7 || ie8){ //para IE
		//event.y|event.clientY = devuelve la posicion en relacion a la parte superior visible del navegador
		//event.screenY = devuelve la posicion del cursor en relaciona la parte superior de la pantalla
		//event.offsetY = devuelve la posicion del mouse en relacion a la posicion superior de la caja donde se ha pulsado
		tempX = event.clientX;
		tempY = event.clientY;
		if(window.pageYOffset){
			tempY=(tempY+window.pageYOffset);
			tempX=(tempX+window.pageXOffset);
		}else{
			tempY=(tempY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));
			tempX=(tempX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));
		}
	}else{ //para netscape
		//window.pageYOffset = devuelve el tamaņo en pixels de la parte superior no visible (scroll) de la pagina
		document.captureEvents(Event.MOUSEMOVE);
		tempX = event.pageX;
		tempY = event.pageY;
	}

	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}

	//modificamos el valor del id posicion para indicar la posicion del mouse
	document.getElementById(id).innerHTML = titulo;

	//window.alert(event.pageYOffset+" - "+document.body.pageYOffset+" - "+screen.pageYOffset+" - "+this.pageYOffset+" - "+window.pageYOffset);

	document.getElementById(id).style.top = (tempY+marginTop)+"px";
	document.getElementById(id).style.left = (tempX+marginRight)+"px";
	document.getElementById(id).style.display='block';
	return;
}

function showdivCadenaImg(event, id, titulo, rutaImg){
	var ie6 = false;
	var ie7 = false;
	var ie8 = false;
	var ns = false;
	if (navigator.appName.indexOf('Explorer')>0){
	   	if(navigator.userAgent.indexOf('MSIE 6')>0 && navigator.userAgent.indexOf('MSIE 7')==-1) {
   		   ie6 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 7')>0){
   		   ie7 = true;
	   	}else if(navigator.userAgent.indexOf('MSIE 8')>0){
   		   ie8 = true;
		}
	}else{
   		ns = true;
	}
	//determina un margen de pixels del div al raton
	marginRight=10;
	marginTop=10;

	//La variable IE determina si estamos utilizando IE
	var IE = document.all?true:false;
	var tempX = 0;
	var tempY = 0;

	//document.body.clientHeight = devuelve la altura del body
	if(ie6 || ie7 || ie8){ //para IE
		//event.y|event.clientY = devuelve la posicion en relacion a la parte superior visible del navegador
		//event.screenY = devuelve la posicion del cursor en relaciona la parte superior de la pantalla
		//event.offsetY = devuelve la posicion del mouse en relacion a la posicion superior de la caja donde se ha pulsado
		tempX = event.clientX;
		tempY = event.clientY;
		if(window.pageYOffset){
			tempY=(tempY+window.pageYOffset);
			tempX=(tempX+window.pageXOffset);
		}else{
			tempY=(tempY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));
			tempX=(tempX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));
		}
	}else{ //para netscape
		//window.pageYOffset = devuelve el tamaņo en pixels de la parte superior no visible (scroll) de la pagina
		document.captureEvents(Event.MOUSEMOVE);
		tempX = event.pageX;
		tempY = event.pageY;
	}

	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}

	//modificamos el valor del id posicion para indicar la posicion del mouse
	titulo = '<img src="'+rutaImg+'" border="0" style="border:1px solid #000000; margin-top:5px; " /><p>'+titulo+'</p>';
	document.getElementById(id).innerHTML = titulo;

	//window.alert(event.pageYOffset+" - "+document.body.pageYOffset+" - "+screen.pageYOffset+" - "+this.pageYOffset+" - "+window.pageYOffset);

	document.getElementById(id).style.top = (tempY+marginTop)+"px";
	document.getElementById(id).style.left = (tempX+marginRight)+"px";
	document.getElementById(id).style.display='block';
	return;
}

function mandarNuevaVentana(formulario, pagina, ancho, alto){
	var izq = (screen.width - ancho) / 2;
	var arr = (screen.height - alto) / 2;
	var nVentana = "ventana" + parseInt(Math.random()*100); //para que no se repita el nombre de la ventana
	
	v=window.open("", nVentana, "width=" + ancho + ", height= " + alto + ", left =" + izq + ", top =" + arr + ", toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, titlebar=no, menubar=no");
	document.getElementById(formulario).method = 'post';
	document.getElementById(formulario).action = pagina;
	document.getElementById(formulario).target = nVentana;
	document.getElementById(formulario).submit();
	return nVentana;
//	v.resizeTo(ancho, alto);
//	v.moveTo(izq, arr);
//	v.focus();
}

function mandarNuevaVentanaNombre(cTitulo, formulario, pagina, ancho, alto){
	var izq = (screen.width - ancho) / 2;
	var arr = (screen.height - alto) / 2;
	
	v=window.open("", cTitulo, "width=" + ancho + ", height= " + alto + ", left =" + izq + ", top =" + arr + ", toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, titlebar=no, menubar=no");
	document.getElementById(formulario).method = 'post';
	document.getElementById(formulario).action = pagina;
	document.getElementById(formulario).target = cTitulo;
	document.getElementById(formulario).submit();
//	return nVentana;
//	v.resizeTo(ancho, alto);
//	v.moveTo(izq, arr);
//	v.focus();
}


function abrirEnlaceVentanaNuevaDimensionada(enlace, titulo, ancho, alto){
	v = window.open(enlace, titulo, "toolbar=no, width=" + ancho + ", height=" + alto + ", location=no, directories=no, status=no, scrollbars=yes, resizable=no, titlebar=no, menubar=no, left=" + (screen.width-ancho)/2 + ", top=" + (screen.height-alto)/2);
	v.resizeTo(ancho, alto);
	v.focus();
}

function IsNumeric(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++){
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){
         blnResult = false;
      }
   }
   return blnResult;
}

function isDate(dd,mm,yyyy){
	var d = new Date(mm + "/" + dd + "/" + yyyy);
	return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy;
}

function isMarked(ctrl){
	var arrayValores = Array();
	for(i=0;i<ctrl.length;i++)
		if(ctrl[i].checked){
			arrayValores[0] = 1;
			arrayValores[1] = ctrl[i].value;
			break;
		}else{
			arrayValores[0] = 0;
			arrayValores[1] = null;
		}
	return arrayValores;
}

function mandarEnter(e,frm,page){
	var tecla = (document.all)?e.keyCode:e.which;
	if(tecla==13)
		mandar(frm,page);
}

function fechaHoraActual(){
	var fFechaHora = new Date();
	
	var nYear = fFechaHora.getYear();
	var nMonth = fFechaHora.getMonth();
	var nDay = fFechaHora.getDate();
	var nHour = fFechaHora.getHours();
	var nMin = fFechaHora.getMinutes();
	var nSec = fFechaHora.getSeconds();
	
	var aFechaHora = new Array();
	aFechaHora[0] = nYear;
	aFechaHora[1] = nMonth;
	aFechaHora[2] = nDay;
	aFechaHora[3] = nHour;
	aFechaHora[4] = nMin;
	aFechaHora[5] = nSec;
	
	return aFechaHora;
	
}

function cambiarImagen(id,imagen){
	document.getElementById(id).src = imagen;
	return true;
}