// ivt

// validaciones

// solo numeros

function isNumber(inputStr) {
    for (var i = 0; i < inputStr.length; i++) {
        var oneChar = inputStr.substring(i, i + 1)
        if (oneChar < "0" || oneChar > "9") {
            alert("Porfavor, solo numeros")
            return false
        }
    }
    return true
}

function upperCase(x)
{
var y=document.getElementById(x).value;
document.getElementById(x).value=y.toUpperCase();
}

function IsEmail(Expression)
{
        if (Expression == null)
                return (false);

        var supported = 0;
        if (window.RegExp)
        {
                var tempStr = "a";
                var tempReg = new RegExp(tempStr);
                if (tempReg.test(tempStr)) supported = 1;
        }
        if (!supported)
                return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
        var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
        var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
        return (!r1.test(Expression) && r2.test(Expression));
}
//Enter your name:
//<input type="text" id="fname"
//onchange="upperCase(this.id)">

// fin validaciones

function PopW(url)
{
window.open(url,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=100,height=20');
}
 function ventana_tuc(page) {
						window.open(page,'infotuts2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=650,height=500');
						}

function centrar(x,y)
 {
    resizeTo(x, y);
    x = (screen.width - x ) / 2;
    y = (screen.height - y) / 2;
    moveTo(x, y);
}

function mailpage()
{
  mail_str = "mailto:nombre@dominio.com?subject=visita esta página. Es muy buena!! " + document.title;
  mail_str += "&body=Hola amigo. Te recomiendo que visites esta página " + document.title;
  mail_str += ". Enlace: " + location.href;
  location.href = mail_str;
}

// end-ivt
function click(e) { //3.0
if (document.all) {
if (event.button == 2 || event.button == 3 || event.button == 6 || event.button == 7) {
Tip('<a href=javascript:self.print()>imprimir</a><br><br><a href=javascript:self.history.back(1)>Regresar</a><br><br><a href=javascript:self.close()>Cerrar</a>',CLICKCLOSE, true,STICKY, true,CLOSEBTN,true,SHADOW,true) ; return false;
}
}
 if (document.layers) {
   if (e.which == 3) {
 alert(message);
 return false;
  }
 }
}
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
function MM_displayStatusMsg(msgStr) { //v1.0
 status=msgStr;
  document.MM_returnValue = true;
}
 function onKeyDown() {
  var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
  if (event.ctrlKey && (pressedKey == 'c' ||
                        pressedKey == 'v' ||
                        pressedKey == 'u')) {
    // disable key press porcessing
    alert('Esa combinacion esta prohibida en EXPLORER');
    event.returnValue = false;
  }
}
if (document.layers) {
  document.captureEvents(Event.KEYDOWN | Event.KEYPRESS | Event.KEYUP);
}
document.onkeydown='javascript:onKeyDown();'
document.onkeypress='javascript:onKeyDown();'
document.onkeyup='javascript:onKeyDown();'


// By Mike Hall (MHall75819@aol.com)

var NS4 = (document.layers);
var IE4 = (document.all);

var win = window;    // Con frames usar top.nombre.window;
var n   = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.

  if (NS4) {

    // Look for match starting at the current point. If not found, rewind
    // back to the first match.

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    // If not found in either direction, give message.

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();

    // Find the nth match from the top of the page.

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }

    // If found, mark it and scroll it into view.

    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }

    // Otherwise, start over at the top of the page and find first match.

    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }

      // Not found anywhere, give message.

      else
        alert("Not found.");
    }
  }

  return false;
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	return cadena;
}

// Documento JavaScript
// Esta función cargará las paginas
function Ajax(url, id_contenedor){
var pagina_requerida = false
if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
pagina_requerida = new XMLHttpRequest()
} else if (window.ActiveXObject){ // pero si es IE
try {
pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){ // en caso que sea una versión antigua
try{
pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
pagina_requerida.onreadystatechange=function(){ // función de respuesta
cargarpagina(pagina_requerida, id_contenedor)
}
pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
pagina_requerida.send(null)
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor){
	var cadena, cadenafinal ;
if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
 {  cadena=unescape(pagina_requerida.responseText) ;
document.getElementById(id_contenedor).innerHTML=cadena }
}



function displayMessage(url)
{

	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(400,200);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function displayStaticMessage(messageContent,cssClass)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(300,150);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes
	messageObj.display();


}

function closeMessage()
{
	messageObj.close();
}






