//////////////////// EJEMPLOS DE FUNCIONES JAVASCRIPT //////////////////
//																	  //
//  Solo como ejemplo, ya que deben adaptarse a cada caso particular  //
//																	  //
////////////////////////////////////////////////////////////////////////
//document.onmousedown=derecha
function pop(ruta,ancho, alto) // crea un popup
{
//alert("aca");
//var website="popap.html";// pagina a abrir !!!!
var heightspeed = 6; // velocidad vertical (a mayor numero menor velocidad)
var widthspeed = 20; // velocidad horizontal (mayor numero menor velocidad)
var leftdist = 200; // distancia hasta el borde izquierdo
var topdist = 200; //distancia hasta el borde superior
var AN= ancho *1; 
var AL= alto * 1;

if (document.all) 
	{
		var winwidth = AN;
		var winheight = AL;
		var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
		for (sizeheight = 1; sizeheight <winheight; sizeheight += heightspeed) { sizer.resizeTo("1", sizeheight);  }
		for (sizewidth = 1; sizewidth <winwidth; sizewidth += widthspeed)      { sizer.resizeTo(sizewidth, sizeheight); }
		sizer.location = ruta;

		}else{ 

		window.location = ruta; 

	}

}

var IE = document.all?true:false;
function popup(website, ancho, alto)
{
var   w = window.screen.availWidth;
var   h = window.screen.availHeight;
var ancho= ancho *1; 
var alto= alto * 1;

var leftdist = (w-ancho)/2; // distancia hasta el borde izquierdo
var topdist = (h -alto)/2; //distancia hasta el borde superior
//alert("left= "+leftdist+" top= "+topdist+" h="+h+" w= "+w+" alto= "+alto+" ancho= "+ancho);
window.open(website,'','toolbar=0,menubar=0,location=0,scrollbars=1,status=1,height='+ alto +',width=' + ancho  +",left=" + leftdist + ",top=" + topdist);
}
////para validar texto
////para validar texto
function valida_texto(e,c)//
{
	var key;
	if (navigator.appName == "Netscape") // me fijo
	{
		key= e.which;
	}
	else
	{
		key= window.event.keyCode; // leo la tecla en ASCII que ingreso
	}
	c=c.toLowerCase();
//	alert(key);
//	alert(c);
	switch(c)
	{
		case "c"://Si es Caracter
			if (key  !=63 && key !=40 && key !=41 && key != 36 && key != 39 && key!=37 ||key==8 ||key==0)
			{
				break;
			}
			else
			{
				return false;
			}
		case "e"://si es entero
			if (key  >47 && key <59 ||key==8 ||key==0)
			{
				break;
			}
			else
			{
				return false;
			}
		case "d"://si es decimal
			if (key  >47 && key <59 || key==46 ||key==8 ||key==0)
			{
				break;
			}
			else
			{
				return false;
			}
		case "r"://si es digito verificador
			if (key  >47 && key <59 || key==75 || key==107 ||key==8 ||key==0)
			{
				break;
			}
			else
			{
				return false;
			}
	}	
}
////////funcion para validar el rut
function valida_rut(rutp,digitop,formu,campo,accionn,e)
{
	
	rut=rutp.value;
	df=digitop.value;
	x=2;
    sumatorio=0;
    for (i=rut.length-1;i>=0;i--)
	{
        if (x>7)
		  {x=2;}
        sumatorio=sumatorio+(rut.charAt(i)*x);
        x++;
     }	
	 digito=(sumatorio%11);
     digito=11-digito;
     switch (digito)
	 {
        case 10:
            digito="K";
            break;
        case 11:
            digito="0";
            break; 
     }
		if (IE)
		{
		  if (window.event.keyCode >  45)
				  {
								 if (df.toUpperCase()==digito)
									{ 
										 campo.value=accionn;
										  formu.submit();
										
										 return true;
									}else
									{
										 alert(" Rut Incorrecto !!. Por Favor verifique El Rut!");  
										 digitop.select();

										 return false;
									}
			  }
		}
		else 
	{

		 if (e.which > 45)
		 {
				if (df.toUpperCase()==digito)
						{ 
					 campo.value=accionn;
					 formu.submit();
					 return true;
					}
					else
					{
					 alert(" Rut Incorrecto !!. Por Favor verifique El Rut!");  
					 digitop.select();
					 return false;
					}
		 }		 
		}
}

function validar_formulario()
{
	var i =0;
	var men="";

	for(i=0; i<document.forms[0].elements.length; i++)
	{
		check=0;
		var cad_men = document.forms[0].elements[i].id; 
		var largo=cad_men.length;
		var cad_val=cad_men.substring(0,1)
		var mensaje=cad_men.substring(1,largo)
	   		if(cad_val=="*")
		{
			switch (document.forms[0].elements[i].type)
			{
				//********** Caso si es texto  o campo password
				case "text"|| "password":
					if(document.forms[0].elements[i].value==0)
					{	
						men= men + "-     "+ mensaje +"\n" 	
					}	
		
					break;
				//********* caso si en un select combo
				case "select-one":
					if(document.forms[0].elements[i].value==0)
					{	
						men= men + "-     "+ mensaje +"\n" 	
					}
					
					break;
				 //**********caso si un select multiple
				case "select-multiple":
					nombreobj=document.forms[0].elements[i].name;
					longitud=nombreobj.length
					caso=nombreobj.substring(longitud-2,longitud)
					if(document.forms[0].elements[i].value==0)
					{	
						men= men + "-     "+ mensaje +"\n" 
					}	
					break;
				
				//************Caso del text area
				
				case "textarea":
					if(document.forms[0].elements[i].value==0)
					{	
						men= men + "-     "+ mensaje +"\n" 	
						document.forms[0].elements[i].value=0;
					}	
					break;
				
				//************** Caso del radio
				case "radio":
					var e 
					for (e=0;i<document.forms[0].elements[i].length;e++)
					{ 
					   if (document.fcolores.colorin[e].checked) 
						  break; 
					} 						
					break;
				//*************** Caso checkbox
				case "checkbox":
					if(document.forms[0].elements[i].checked==false)
					{	
						men= men + "-     "+ mensaje +"\n" 
					}
					break;
			}
		}
		 if(cad_val=="/")
		{
				if(document.forms[0].elements[i].value.indexOf("@") == -1 || document.forms[0].elements[i].value.indexOf(".") ==-1)
				{
					 men= men + "-     "+ mensaje +"\n" 	
				}
			
		}
		
	}
	if (men!="")
	 {
		 menF="_________________________\n";
		 menF=menF+"Le ha faltado introducir los siguientes datos: \n \n \n";
		 menF=menF+men +" \n"
		 menF=menF + "_________________________ \n";
		 menF=menF + "¡Por favor pulse enter, rellene los datos y pruebe de nuevo!";
		 alert(menF)
		return false;
	}
}
function deshabilitar()
{
//	alert("deshabilitar");
	for(i=0; i<document.forms[0].elements.length; i++)
	{
		document.forms[0].elements[i].disabled=true;
	}
}
function habilitar()
{
//	alert("deshabilitar");
	for(i=0; i<document.forms[0].elements.length; i++)
	{
		document.forms[0].elements[i].disabled=false;
	}
}

function limpia_select(select_limpiar,titulo)
{
	var  j;
	// ****** elimina todos los items del select
//	alert(select_limpiar.options.length);
	for (i = select_limpiar.options.length; i >= 0; i--)
	{
		select_limpiar.options[i] = null; 
	}
	//******* coloca el primer items  del select*******
	
		select_limpiar.options[0] = new Option(titulo);
	
}
//****************************************************************
//		FUNCION PARA CARGAR UN SELECT EN FORMA LOCAL
//****************************************************************
function cargar_select(id,arreglo_buscar,select_llenar,titulo)
{
	// ****	id				= id que se tiene que encontrar
	// **** arreglo_buscar	= arreglo en el cual se buscaran los id que coincidan con id
	// **** select_llenar	= select que se llenara con los datos encontrados del arreglo
	// **** titulo			= titulo del primer item que tendrï¿½el select

	var i, j;
	var prompt;
	// ****** elimina todos los items del select
//	alert(select_llenar.options.length);
	for (i = select_llenar.options.length; i >= 0; i--)
	{

		select_llenar.options[i] = null; 
	}

	//******* coloca el primer items  del select*******
	prompt = (arreglo_buscar != null) ? titulo:"0" //goodPrompt : badPrompt;
	if (prompt == null)
	{
		j = 0;
	}
	else
	{
		select_llenar.options[0] = new Option(prompt,"0");
		j = 1;
	}
	// ***** si el arreglo es diferente de vacio, comienza agregar items ******
	if (arreglo_buscar != null)
	{
		for (i = 0; i < arreglo_buscar.length; i++) 
		{
			//*** si coincide el id con el id del arreglo*****
			if(id==arreglo_buscar[i][1])
			{
				var Vvalue=arreglo_buscar[i][0];
				var Vtexto=arreglo_buscar[i][2];
//				alert(Vvalue);
				var variable = new Option(Vtexto,Vvalue,"","");
				select_llenar.options[j]=variable;
				j++;
			}
		}
	// ** deja seleccionado el primer elemento de la lista****
		select_llenar.options[0].selected = true;
	}
}

//****************************************************************
//		FUNCION PARA SABER INFORMACION DEL NAVEGADOR
//****************************************************************

function datosUsuario(){     
    document.write("screen.height - " + screen.height + 
                "<br>screen.availHeight - " + screen.availHeight + 
                "<br>screen.width - " + screen.width + 
                "<br>screen.availWidth - " + screen.availWidth + 
                "<br>screen.updateInterval - " + screen.updateInterval + 
                "<br>screen.fontSmoothingEnabled - " + screen.fontSmoothingEnabled + 
                "<br>screen.bufferDepth - " + screen.bufferDepth + 
                "<br>screen.colorDepth - " + screen.colorDepth + 
                "<br>navigator.appCodeName - " + navigator.appCodeName + 
                "<br>navigator.appMinorVersion - " + navigator.appMinorVersion + 
                "<br>navigator.appName - " + navigator.appName + 
                "<br>navigator.appVersion - " + navigator.appVersion + 
                "<br>navigator.cookieEnabled - " + navigator.cookieEnabled + 
                "<br>navigator.cpuClass - " + navigator.cpuClass + 
                "<br>navigator.javaEnabled - " + navigator.javaEnabled() + 
                "<br>navigator.mimeTypes.length - " + navigator.mimeTypes.length + 
                "<br>navigator.onLine - " + navigator.onLine + 
                "<br>navigator.platform - " + navigator.platform + 
                "<br>navigator.plugins.length - " + navigator.plugins.length + 
                "<br>navigator.systemLanguage - " + navigator.systemLanguage +     
                "<br>navigator.taintEnabled() - " + navigator.taintEnabled() + 
                "<br>navigator.userAgent - " + navigator.userAgent + 
                "<br>navigator.userLanguage - " + navigator.userLanguage); 
}
//http://www.digitalstudio.es/faq-java.htm
function funciones_java()
{
	var cad = "Cesar Zumelzo",i; 
	var ja = new Array(); 

ja = cad.split("o"); 

with(document) { 
write("La cadena es: "+cad+"<BR>"); 
write("Longitud de la cadena: "+cad.length+"<BR>"); 
write("Haciendola ancla: "+cad.anchor("b")+"<BR>"); 
write("En grande: "+cad.big()+"<BR>"); 
write("Parpadea: "+cad.blink()+"<BR>"); 
write("Caracter 3 es: "+cad.charAt(3)+"<BR>"); 
write("Fuente FIXED: "+cad.fixed()+"<BR>"); 
write("De color: "+cad.fontcolor("#FF0000")+"<BR>"); 
write("De color: "+cad.fontcolor("salmon")+"<BR>"); 
write("Tamaño 7: "+cad.fontsize(7)+"<BR>"); 
write("<I>orl</I> esta en la posicion: "+cad.indexOf("orl")); 
write("<BR>En cursiva: "+cad.italics()+"<BR>"); 
write("La primera <I>l</I> esta, empezando a contar por detras,"); 
write(" en la posicion: "+cad.lastIndexOf("l")+"<BR>"); 
write("Haciendola enlace: "+cad.link("doc.htm")+"<BR>"); 
write("En pequeño: "+cad.small()+"<BR>"); 
write("Tachada: "+cad.strike()+"<BR>"); 
write("Subindice: "+cad.sub()+"<BR>"); 
write("Superindice: "+cad.sup()+"<BR>"); 
write("Minusculas: "+cad.toLowerCase()+"<BR>"); 
write("Mayusculas: "+cad.toUpperCase()+"<BR>"); 
write("Subcadena entre los caracteres 3 y 10: "); 
write(cad.substring(2,10)+"<BR>"); 
write("Entre los caracteres 10 y 3: "+cad.substring(10,2)+"<BR>"); 
write("Subcadenas resultantes de separar por las <B>o:</B><BR>"); 
for(i=0;i<ja.length;i++) write(ja[i]+"<BR>"); 
} 

}
function paginas(voy,des,cuan,acc)
{
//	alert("hola");
	with (document.frm1)
	{
		switch(voy)
		{
			case "adelante": //para avanzar 1 hacia adelante
				if(des==0)
				{
					desde.value=des+cuan; 
				}else
				{
					desde.value=des;
				}
				break;
			case "atras": //para avanzar 1 hacia atras
					desde.value=des;
				break;
			default:
				desde.value=des; //para ir a una página en especial
		}
		cuantos.value=cuan;
		accion.value=acc;
		submit();
	}
} 

var marked_row = new Array;
	  function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function uno(src) 
{ 
//	alert(src);
	with(document) 
	{
		var cel = getElementById(src); 
		with(cel) 
		{ 
			style.backgroundColor="yellow"; style.cursor='hand'; } if (src != 1) { getElementById('1').style.backgroundColor="white"; 
		} 
	} 
} 
function dos(src,color) 
{ 
	//alert(color);
	with(document) 
	{ 
		var cel = getElementById(src); 
		with(cel) 
		{ 
			style.backgroundColor=color; style.cursor='default'; 
		} 
	} 
} 
function ini() 
{ 
	with(document) 
	{ 
		getElementById('1').style.backgroundColor = "yellow"; 
	}
} 

function ruta(cadena,idd)
{

	var arreglo=new Array();
	var cad=cadena;
	var j=0;
	var a="";
	for(i=0;i<cad.length;i++) 
	{
		if(cad.substring(i,i+1)=="-")
		{
			arreglo[j]=a;
			j++;
			a="";
		}
		else
		{
			a=a+cad.substring(i,i+1);
		}
	}
/*for(i=0;i<arreglo.length;i++) 
{
	alert(arreglo[i]);
}*/
if(arreglo[3]=="LCRUDO")
{
//	popup(arreglo[0]+"?idi="+idd,arreglo[1],arreglo[2]);
	document.location=arreglo[0]+"?id_relacion="+idd,arreglo[1],arreglo[2];
}

if(arreglo[3]=="L")
{
	popup(arreglo[0]+"?id_relacion="+idd,arreglo[1],arreglo[2]);
}

if(arreglo[3]=="T")
{
	
	popup(arreglo[0]+"?id="+idd+"&tabla="+arreglo[4],arreglo[1],arreglo[2]);
}
if(arreglo[3]=="Z")
{
	inicio(arreglo[0]);
}
if(arreglo[3]=="BF")
{
	with (document.frm1)
	{
		if (confirm("Esta seguro de Borrar la Foto??") )
		{
			accion.value="borrar_foto"
			idi.value=idd;
			submit();
		}
	}
}
if(arreglo[3]=="B")
{
	with (document.frm1)
	{
		if (confirm("Esta seguro de Borrar el Registro") )
		{
		accion.value="borrar"
		idi.value=idd;
		submit();
	}
	
	}
}
}
function buscar(cam)
	{
		document.frm1.accion.value="buscar";
		document.frm1.campo.value=cam;
		document.frm1.submit();
	}
function buscarA()
{
	document.frm1.accion.value="buscar";
	document.frm1.submit();
}


function encabezados(desde,cuantos,orden,sentido,accion)
{
	document.frm1.posicion.value=window.document.body.scrollTop;
//	document.frm1.ordenar.value="si";
//	document.frm1.ncampo.value=campos;
//	document.frm1.ncampo.name=campos;
	document.frm1.desde.value=desde;
	document.frm1.cuantos.value=cuantos;
	document.frm1.orden.value=orden
	document.frm1.sentido.value=sentido;
	document.frm1.accion.value=accion;
	document.frm1.submit();
}


    imagen1=new Image;imagen1.src="clases/imagenes_clases/siguiente.gif"
	imagen2=new Image;imagen2.src="clases/imagenes_clases/siguiente2.gif"
	imagen3=new Image;imagen3.src="clases/imagenes_clases/anterior.gif"
	imagen4=new Image;imagen4.src="clases/imagenes_clases/anterior2.gif"
	function cambiar(x)
	{       
		switch(x)
			{
			
			case 1:
					document.images['ejemplo'].src=imagen2.src;
			break;
			case 2:
					document.images['ejemplo'].src=imagen1.src;
			break;
			}
	}

	function cambiar2(x)
	{       
		switch(x)
			{
			
			case 1:
					document.images['ejemplo2'].src=imagen4.src;
			break;
			case 2:
					document.images['ejemplo2'].src=imagen3.src;
			break;
			}
	}	

		function derecha(e) {
			if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
			alert(' Derechos Resevados')
			return false;
		}

		else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)){
		alert(' Derechos Resevados')
		}
}

//************************************** Funciones de acciones de formularios ******************

function limpiar()  // limpiar la pantalla para un nuevo registro
{
	document.frm1.accion.value="limpiar_campos";
	document.frm1.submit();

}


function limpiar2(foco)
{
	
		document.frm1.envio.value="ACEPTAR";
		var i =0;
	for(i=0; i<document.forms[0].elements.length; i++)
	{
		
			switch (document.forms[0].elements[i].type)
			{
		
				case "text"|| "password":
					document.forms[0].elements[i].value="";
					break;
				case "select-one":
					document.forms[0].elements[i].value=0
					break;
				 //**********caso si un select multiple
				case "select-multiple":
					document.forms[0].elements[i].value=0
					break;
				case "textarea":
							document.forms[0].elements[i].value="";

					break;
			}
	}	
		foco.focus();
}	




function accion_envio()
{
	if(validar_formulario()==false)
	{
		return;
	}

	if (document.frm1.envio.value=="ACEPTAR")
	{
	
		document.frm1.accion.value="insertar";
	}
	else if (document.frm1.envio.value=="MODIFICAR")
	{
		document.frm1.accion.value="modificar";
	}
	else if (document.frm1.envio.value=="BORRAR")
	{
		document.frm1.accion.value="borrar";
	}
//	alert(document.frm1.envio.value);
	document.frm1.submit();
}


	function buscardato(idi,desde,cuantos)
	{
		document.frm1.accion.value="encuentra";
		document.frm1.desde.value=desde;
		document.frm1.cuantos.value=cuantos;
		document.frm1.idi.value=idi;
		document.frm1.submit();
	}
	function tb(e,obj)
	{
		var key=0;
				if (navigator.appName=="Netscape") // me fijo
				{
					if (e.which==13)
					{
						//e.which=0;
					  obj.select();

					}
				}
	else
			{
				 if(window.event.keyCode==13)
				{		
				
							 window.event.keyCode=9;
				}
			}
	}


	function veri_codigo(e)
	{
		if (navigator.appName=="Netscape") // me fijo
				{
							if (e.which==13)
								{
									document.frm1.accion.value="busca_codigo";
									document.frm1.submit();
								}
				}else
			{
				 if(window.event.keyCode==13)
					{
									document.frm1.accion.value="busca_codigo";
									document.frm1.submit();
					}
			}
	}


function veri_codigo(e)
	{
		if (navigator.appName=="Netscape") // me fijo
				{
							if (e.which==13)
								{
									document.frm1.accion.value="busca_codigo";
									document.frm1.submit();
								}
				}else
			{
				 if(window.event.keyCode==13)
					{
									document.frm1.accion.value="busca_codigo";
									document.frm1.submit();
					}
			}
	}




function cierra()
{
       window.opener.document.frm1.submit();
       window.close();
}

// Funcion para fpd 
function imprimir_pdf()
{
	var answer=confirm("¿Desea Ver todos los registros, o solo los que buscó? .\n 'Aceptar' para ver todos, 'Cancelar' para lo seleccionado.")
	if (answer) {
		document.frm1.tipo_informe.value="todos";
	}
	else 
	{
		document.frm1.tipo_informe.value="seleccion";
	}
	document.frm1.target="popup";
	document.frm1.action="genera_pdf/informe_general.php";
	document.frm1.submit();
	document.frm1.target="";
	document.frm1.action="";
}
function imprimir_xls()
{
	//var answer=confirm("¿Desea Ver todos los registros, o solo los que buscó? .\n 'Aceptar' para ver todos, 'Cancelar' para lo seleccionado.")
	//if (answer) {
	//	document.frm1.tipo_informe.value="todos";
//	}
//	else 
//	{
		document.frm1.tipo_informe.value="seleccion";
//	}
	document.frm1.target="popup";
	document.frm1.action="genera_pdf/crea_xls.php";
	document.frm1.submit();
	document.frm1.target="";
	document.frm1.action="";
}

function posi(y)
{
	scroll(0,y);
}

function validarut(rutp,digitop)
{
	
	rut=rutp.value;
	df=digitop.value;
	x=2;
    sumatorio=0;
	//if(df=="")
	//{return false;}
    for (i=rut.length-1;i>=0;i--)
	{
        if (x>7)
		  {x=2;}
        sumatorio=sumatorio+(rut.charAt(i)*x);
        x++;
     }	
	 digito=(sumatorio%11);
     digito=11-digito;
     switch (digito)
	 {
        case 10:
            digito="K";
            break;
        case 11:
            digito="0";
            break; 
     }
	// alert(df.toUpperCase());
	 //alert(digito);
	 if (IE)
	{
		//if (window.event.keyCode >  45)
		//  {
			 if (df.toUpperCase()==digito)
				{ 
					 //campo.value=accionn;
					//  formu.submit();
					
					 return true;
				}else
				{
					 alert(" Rut Incorrecto !!. Por Favor verifique El Rut!");  
					 digitop.select();
					 return false;
				}
		//}
	}
	else 
	{
		//if (e.which > 45)
		//{
			if (df.toUpperCase()==digito)
			{ 
				 //campo.value=accionn;
				 //formu.submit();
				 return true;
			}
			else
			{
				alert(" Rut Incorrecto !!. Por Favor verifique El Rut!");  
				digitop.select();
				return false;
			}
		// }		 
	}
}
