// make javascript.js
var lala = 0;
function ayuda( o, texto ){
var div = document.getElementById( "ayuda" );
var divT = document.getElementById( "atext" );
lala=1;
divT.innerHTML = texto;
if (o.offsetParent) {curleft = o.offsetLeft;
curtop = o.offsetTop;
while (o = o.offsetParent) {curleft += o.offsetLeft;
curtop += o.offsetTop;
}}
div.style.display='block';
div.style.top = ( curtop + 10 - div.offsetHeight )+'px';
div.style.left = ( curleft - 25 )+'px';}
document.onclick=function(){var div = document.getElementById( "ayuda" );
if( lala == 2 ){lala = 0;
div.style.display='none';}
if( lala == 1 )lala++;}
function toggle( o, h ){if( o.style.display == 'none' && ! h ) o.style.display = ''
else o.style.display = 'none';
return o;
}
function validaRequeridos( form ){var campos = getElementsByClassName( 'req', '', form );
for( var i = 0; i < campos.length; i++ ){if( campos[i].value == '' ){alert( "Debe completar todos los campos obligatorios antes de enviar" );
campos[i].style.borderColor='red';
campos[i].focus();
return false;}}
return true;}
function getElementsByClassName(className, tag, elm){var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
var tag = tag || "*";
var elm = elm || document;
var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
var returnElements = [];
var current;
var length = elements.length;
for(var i=0; i<length; i++){current = elements[i];
if(testClass.test(current.className)){current.style.borderColor='';
returnElements.push(current);}}
return returnElements;}
function makeRequest(url, span) {var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();} else if (window.ActiveXObject) { // IE
try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}}}
if (!http_request) {alert('Giving up :( Cannot create an XMLHTTP instance');
return false;}
if( span ) http_request.onreadystatechange = function() { alertContents(http_request, span); };
http_request.open('GET', url, true);
http_request.send(null);}
function G( id ){return document.getElementById( id );}
function sortablear(){var tablas = document.getElementsByTagName( 'TABLE' );
var ths = tablas[0].getElementsByTagName( 'TH' );
for( i = 0; i < ths.length; i++ ){ths[i].style.cursor = 'pointer';
ths[i].onclick = Function( 'sortColumn("' + i + '","'+ths.length+'")' );}}
function sortColumn( n, c ){
var tablas = document.getElementsByTagName( 'TABLE' );
var ths = tablas[0].getElementsByTagName( 'TH' );
var tds = tablas[0].getElementsByTagName( 'TD' );
var trs = tablas[0].getElementsByTagName( 'TR' );
for( i = 0; i < ths.length; i++ ){ths[i].style.backgroundColor = i == n ? '#ffcc66' : '#ffc080';
if( ths[i].colSpan > 1 ) c = parseInt( c ) + ths[i].colSpan - 1;}
var a = 0;
var trs2 = new Array();
var col = new Array();
for( i = 0; i < tds.length; i++ ){if( ( i % c ) == n ) col[a++] = tds[i].innerHTML.replace( /.*>(.*)<.*/, "$1" );}
col = ths[n].className.indexOf( 'numeros' ) > -1 ? col.sort(function(a,b){ return a -b; }) : col.sort();
if( ths[n].sort == 1 ){
col.reverse();
ths[n].sort = -1;} else ths[n].sort = 1;
var l = trs.length;
for( i = 1; i < l; i++ ) trs2[i] = trs[0].parentNode.removeChild( trs[1] );
for( j = 0; j < col.length; j++ ){for( i = 1; i < l; i++ ){if( ! trs2[i] ) continue;
au = trs2[i].getElementsByTagName('TD');
if( au[n].innerHTML.replace( /.*>(.*)<.*/, "$1" ) == col[j] ){trs[0].parentNode.appendChild( trs2[i] ).className = j % 2 > 0 ? 'odd' : 'even';
trs2[i] = null;
break;}}}}
