function ConfirmDel(page)
{
var Delreg = confirm("¿Desea eliminar este registro?");
if (Delreg == true)
{
window.location=page;
}
}
function validarbuscar(keyword){
if (keyword == '' && keyword.length < 3){
alert('Ingrese un criterio de búsqueda o largo incorrecto');
} else {
document.buscador.submit();
}
}

function validarsolicitud(rut){
if (rut == '' && rut.length < 9){
alert('Ingrese el RUT');
} else {
document.solicitar.submit();
}
}

function validarlogin(user,password){
if (user == '' || password == ''){
alert('Ingrese usuario y/o contraseña');
} else {
document.login.submit();
}
}

function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("UREUS Multimedia");
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function getOffsetLeft (el) {
var ol = el.offsetLeft;
while ((el = el.offsetParent) != null)
ol += el.offsetLeft;
return ol;
}

function getOffsetTop (el) {
var ot = el.offsetTop;
while((el = el.offsetParent) != null)
ot += el.offsetTop;
return ot;
}

function findCoor(table) {
var tableLeft = getOffsetLeft(table);
var tableTop = getOffsetTop(table);
//alert(tableLeft + ':' + tableTop);
document.getElementById('Layer1').style.top= tableTop + 100
document.getElementById('Layer1').style.left= tableLeft - 50
}

function findCoordinates(table) {
var tableLeft = getOffsetLeft(table);
var tableTop = getOffsetTop(table);


document.getElementById('Empresa').style.left= tableLeft + 274;
document.getElementById('Empresa').style.top= tableTop + 78;
document.getElementById('Servicios').style.left= tableLeft + 359;
document.getElementById('Servicios').style.top= tableTop + 78;
document.getElementById('Utilidades').style.left= tableLeft + 444;
document.getElementById('Utilidades').style.top= tableTop + 78
//document.getElementById('Layer1').style.top= tableTop + 700
//document.getElementById('Layer1').style.left= tableTop + 100
}

         var txt0="Diseño Web - Multimedia - E-learning - Animación 3D - Diseño Gráfico Computacional - E-marketing - Aplicaciones Web - Software ";
         var txt1="UREUS Multimedia";
         var txt2=txt0+"          "+txt1+"          ";
         var wait=100;
         var refresco=null;

function baner_barraestado() {
        window.status=txt2;
        txt2=txt2.substring(1,txt2.length)+txt2.charAt(0);
        refresco=setTimeout("baner_barraestado()",wait);
        }
        
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function add_homepage()
{
        var name = navigator.appName;
        var useragent = navigator.userAgent;
        var version = parseInt(navigator.appVersion);

        if ( useragent.indexOf("MSIE") != -1)
        {
                var macIndex = navigator.userAgent.toLowerCase().indexOf("mac");
        if ( macIndex != -1 )
                {

        }
                else
                {
                        var index = navigator.userAgent.indexOf("MSIE ");
                        if ( index != -1 )
                        {
                                version = parseInt(navigator.userAgent.substring(index+5,index+6));
                        }
                        if ( version == 4)
                        {
                                alert("Usted esta usando Microsoft Explorer 4 y esta aplicación no funciona con este navegador");
                        }
                        else if ( version > 4)
                        {
                                document.body.setHomePage('http://www.ureus.com');
                        }
                }
        }
        else
        {
                alert("Usted esta usando Nestcape y no se puede dejar como pagina de inicio.");
        }
}


function valida_buscar(){
	a=document.forms['busqueda']['clave'].value;
	if (a=="")
	{
		alert("Ingrese Frase o Palabra para Buscar");
		return false;
	}
	else
	{
		return true;
	}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function checkFields( rut, dv, clave )
{
	var tmpstr = "";
	for ( i=0; i < rut.length ; i++ )
		if ( rut.charAt(i) != ' ' && rut.charAt(i) != '.' && rut.charAt(i) != '-' )
			tmpstr = tmpstr + rut.charAt(i);
	rut = tmpstr;
	if ( rut == "" )
	{
		alert( "Ingrese su rut");
		window.document.password.rut.focus();
		window.document.password.rut.select();
		return false;
	}

	if ( dv == "" )
	{
		alert( "Falta el digito verificador");
		window.document.password.dv.focus();
		window.document.password.dv.select();
		return false;
	}

	largo = rut.length;
	if ( !checkRutField( rut ) )
		return false;
	if ( !checkDV( rut, dv ) )
		return false;
	window.document.password.rut.value = rut;
	return true;
}

function checkCDV( dvr )
{
	dv = dvr + ""
	if ( dv != '0' && dv != '1' && dv != '2' && dv != '3' && dv != '4' && dv != '5' && dv != '6' && dv != '7' && dv != '8' && dv != '9' && dv != 'k'  && dv != 'K')
	{
		alert("El rut es incorrecto");
		window.document.password.rut.focus();
		window.document.password.rut.select();
		return false;
	}
	return true;
}

function checkDV( rut,dv )
{
	largo = rut.length;
	if ( largo < 1 )
	{
		alert("El rut esta incompleto")
		window.document.password.rut.focus();
		window.document.password.rut.select();
		return false;
	}

	if ( !checkCDV( dv ) )
		return false;
	if ( rut == null || dv == null )
			return 0
	var dvr = '0'
	suma = 0
	mul  = 2
	for (i= rut.length -1 ; i >= 0; i--)
	{
		suma = suma + rut.charAt(i) * mul
		if (mul == 7)
			mul = 2
		else
			mul++
	}
	res = suma % 11
	if (res==1)
		dvr = 'k'
	else if (res==0)
		dvr = '0'
	else
	{
		dvi = 11-res
		dvr = dvi + ""
	}

	if ( dvr != dv.toLowerCase() )
	{
		alert("EL rut es incorrecto")
		window.document.password.rut.focus();
		window.document.password.rut.select();
		return false
	}
    return true;
}

function checkRutField(texto)
{
	var tmpstr = "";
	for ( i=0; i < texto.length ; i++ )
		if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
			tmpstr = tmpstr + texto.charAt(i);
	texto = tmpstr;
	largo = texto.length;

	if ( largo < 1 )
	{
		alert("Debe ingresar el rut completo")
		window.document.password.rut.focus();
		window.document.password.rut.select();
		return false;
	}

	for (i=0; i < largo ; i++ )
	{
		if ( texto.charAt(i) !="0" && texto.charAt(i) != "1" && texto.charAt(i) !="2" && texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) !="5" && texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) !="8" && texto.charAt(i) != "9" )
		{
			alert("El valor ingresado no corresponde a un R.U.T valido");
			window.document.password.rut.focus();
			window.document.password.rut.select();
			return false;
		}
	}
	return true;
}

