
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' marked';
            } else {
                this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
        }

        // ... and disable label ...
        var labeltag = rows[i].getElementsByTagName('label')[0];
        if ( labeltag ) {
            labeltag.onclick = function() {
                return false;
            }
        }
        // .. and checkbox clicks
        var checkbox = rows[i].getElementsByTagName('input')[0];
        if ( checkbox ) {
            checkbox.onclick = function() {
                // opera does not recognize return false;
                this.checked = ! this.checked;
            }
        }
    }
}
window.onload=PMA_markRowsInit;

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];
        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
        }
    }

    return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
    }

    return true;
}

function vkey( pad )
{
	if( pad == 10) 
	{
		
		if ((document.frmpad.t1.value.length>5) && (document.frmpad.t2.value.length>5) && (document.frmpad.t3.value.length>5) && (document.frmpad.t1.value!=document.frmpad.t2.value))
		{	
			if (document.frmpad.t2.value!=document.frmpad.t3.value)
			{ 
				alert ("Las dos nuevas contraseñas son diferentes"); 
				document.frmpad.t2.value="";
				document.frmpad.t3.value="";
			}else
			{
				if (pasto(document.frmpad.t2.value))
				{
					document.frmpad.submit();
				}
				else
				{
					ki=confirm ("¿La contraseña que ha ingresado no es segura, desea usarla?");
					if (ki==false)
					{
						document.frmpad.t2.value="";
						document.frmpad.t3.value="";
					}
					else
					{
						document.frmpad.submit();	
					}
				}
			}
		}
		else
		{
			alert ("La contraseña debe tener seis digitos y ser diferente a la anterior");
			document.frmpad.t2.value="";
			document.frmpad.t3.value="";
		}
	}
	if( pad == 11) 
	{
		if(document.frmpad.t3.value!=""){document.frmpad.t3.value=""; document.frmpad.t1.className = "textoff"; document.frmpad.t2.className = "textoff"; document.frmpad.t3.className = "texton";}
		else {
			if(document.frmpad.t2.value!="" ){document.frmpad.t2.value=""; document.frmpad.t1.className = "textoff"; document.frmpad.t2.className = "texton"; document.frmpad.t3.className = "textoff";}
			else {
				if(document.frmpad.t1.value!="")
				{
					document.frmpad.t1.value=""; 
					document.frmpad.t1.className = "texton"; document.frmpad.t2.className = "textoff"; document.frmpad.t3.className = "textoff";
				}
			}
		}
	}    
	if ((pad<10))
	{
		if(document.frmpad.t1.value=="" || document.frmpad.t1.value.length<6){document.frmpad.t1.value += pad; document.frmpad.t1.className = "texton"; document.frmpad.t2.className = "textoff"; document.frmpad.t3.className = "textoff";}
		else {
			if(document.frmpad.t2.value=="" || document.frmpad.t2.value.length<6 ){document.frmpad.t2.value += pad; document.frmpad.t1.className = "textoff"; document.frmpad.t2.className = "texton"; document.frmpad.t3.className = "textoff";}
			else {
				if(document.frmpad.t3.value=="" || document.frmpad.t3.value.length<6)
				{
					document.frmpad.t3.value += pad; 
					document.frmpad.t1.className = "textoff"; document.frmpad.t2.className = "textoff"; document.frmpad.t3.className = "texton";
				}
			}
		}
	}
	
	document.frmpad.t2.focus(); 
}
function pasto(po)
{
ok=[];
ok[1]=111111;
ok[2]=222222;
ok[3]=333333;
ok[4]=444444;
ok[5]=555555;
ok[6]=666666;
ok[7]=777777;
ok[8]=888888;
ok[9]=999999;
ok[10]=123456;
ok[11]=123654;
ok[12]=123789;
ok[13]=123987;
ok[14]=321456;
ok[15]=321654;
ok[16]=321789;
ok[17]=321987;
ok[18]=456123;
ok[19]=456321;
ok[20]=456789;
ok[21]=456987;
ok[22]=654123;
ok[23]=654321;
ok[24]=654789;
ok[25]=654987;
ok[26]=789123;
ok[27]=789321;
ok[28]=789456;
ok[29]=789654;
ok[30]=987123;
ok[31]=987321;
ok[32]=987456;
ok[33]=987654;
ok[34]=112233;
ok[35]=332211;
ok[36]=445566;
ok[37]=665544;
ok[38]=778899;
ok[39]=998877;
ok[40]=159753;
ok[41]=159357;
ok[42]=951753;
ok[43]=951357;
ok[44]=100000;
ok[45]=200000;
ok[46]=300000;
ok[47]=400000;
ok[48]=500000;
ok[49]=600000;
ok[50]=700000;
ok[51]=800000;
ok[52]=900000;
for (var i=0;i<52;i++)
{
	if (po==ok[i])
	{
		po=0;
		break;
	}
}
return po;
}
function nkey( pad )
{
	if( pad == 10) 
	{
		if ((document.frmpad.t1.value.length>0) && (document.frmpad.t2.value.length>0))
		{	
			document.frmpad.submit();
		}
		else
		{
			alert ("Introduce el codigo y la contraseña");
		}
	}
	if( pad == 11) 
	{
		document.frmpad.t2.value="";
	}    
	if ((pad<10) && (document.frmpad.t2.value.length<6))
	{
		document.frmpad.t2.value += pad; 
	}
	document.frmpad.t2.focus(); 
}
function reload() 
{
	document.frmpad.t3.value = "1";
	document.frmpad.submit();
}
function disableRightClick() 
{
	return false;
}
function acceptNum(evt)
{	
	var key = nav4 ? evt.which : evt.keyCode;	
	return (key <= 13 || (key >= 48 && key <= 57));
}
function help()
{
	abrir("http://<? echo $_SERVER['HTTP_HOST']; ?>/help.php");
}
function abrir(pagina) 
{
	var opciones="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=nos,width=750,height=550,top=40,left=50";
	window.open(pagina,"otra",opciones);
}

