function ampliar(imagen,pie) {
//document.datos.imagen.value = img
//document.datos.titulo.value = tit
//document.datos.descripcion.value = des
//img = eval('document.img'+img+'.src')
var w=300
var h=250
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',menu=0,scrollbars=0,resizable=0,toolbar=0,status=0,location=0,menubar=0'
win = window.open("ampliar.php?imagen="+imagen+"&pie="+pie+"", "ampliar", winprops)
win.blur
if (parseInt(navigator.appVersion) >= 4) {win.window.focus();}
//win.resizeTo(w,h);
//win.moveTo(winl,wint);
}

function ir_a(pag) {
//document.datos.imagen.value = img
//document.datos.titulo.value = tit
//document.datos.descripcion.value = des
//img = eval('document.img'+img+'.src')
var w=750
var h=450
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',menu=1,scrollbars=1,resizable=1,toolbar=1,status=1,location=1,menubar=1'
win_ir_a = window.open(pag, "ir_a", winprops)
win_ir_a.blur
if (parseInt(navigator.appVersion) >= 4) {win_ir_a.window.focus();}
//win.resizeTo(w,h);
//win.moveTo(winl,wint);
}

function ver(pag) {
//document.datos.imagen.value = img
//document.datos.titulo.value = tit
//document.datos.descripcion.value = des
//img = eval('document.img'+img+'.src')
var w=750
var h=550
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',menu=0,scrollbars=1,resizable=0,toolbar=0,status=0,location=0,menubar=0'
win = window.open(pag, "ver", winprops)
win.blur
if (parseInt(navigator.appVersion) >= 4) {win.window.focus();}
//win.resizeTo(w,h);
//win.moveTo(winl,wint);
}

//mouseover image
function makevisible(cur,which){
strength=(which==0)? 1 : 0.8

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

//fade imagen
var baseopacity=0

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",20)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=4
else if (window.highlighting)
clearInterval(highlighting)
}

//
function valmax(campo,max,mensaje){
elcampo = eval('window.document.forms[0].'+campo);
if (elcampo.value.length > max) {
	alert(mensaje + " debe tener un máximo de "+max+" caracteres");
	elcampo.focus();
	return true;
}else{
	return false;
}
}

//
function valnull(campo,mensaje){
elcampo = eval('window.document.forms[0].'+campo);
if (elcampo.value == "" || elcampo.value == null) {
	alert(mensaje);
	elcampo.focus();
	return true;
}else{
	return false;
}
}

//
function isEmail(direccion){
var s = Trim(direccion);
var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (s.length == 0 ) return true;
if (filter.test(s)){
	return true;
}else{
	return false;
}
}

//
function valmail(elcampo, max, titulo, num) {
  var checkStr = eval('window.document.forms[0].'+elcampo+'.value');
  var Reason  = "Email "+ titulo + " ("+ num +") incorrecto.  \n\nVerifíquelo. \n\n"
  var Success = "Email "+ titulo + " ("+ num +") correcto."
  var ix = (checkStr.length - 4)
  var RC = true;
  var x = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = ExtValid = RL = 0;
  for (i = 0;  i < checkStr.length;  i++)
  {
    if (checkStr.charAt(i) == '@')
      AtSignValid++;
    else if (checkStr.charAt(i) == '.')
    {
      if (x == (i-1))
        DoublePeriod++;
      else
      {
        x = i;
        PeriodValid++;
      }
    }
    else if (checkStr.charAt(i) == ' ')
      SpaceValid ++;
  }
  if (checkStr.indexOf(".com", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".edu", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".net", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".org", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".gov", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".mil", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".cc", ix) > -1)
    ExtValid++;
  RL = Reason.length;
  if (AtSignValid != 1)
    Reason += "\nEl Email "+ titulo + " ("+ num +") es inválido. Sólo se permite un '@'";
  if (PeriodValid == 0)
    Reason += "\nEl Email "+ titulo + " ("+ num +") debe contener al menos un punto.";
  if (SpaceValid > 0)
    Reason += "\nNo se permiten espacios. El Email "+ titulo + " ("+ num +") contiene " + SpaceValid + " espacio";
  if (SpaceValid > 1)
    Reason += "s.";
  if (checkStr.length > max)
    Reason += "\nEl Email "+ titulo + " ("+ num +") no debe exceder los " + max + " caracteres.";
  if (RL != Reason.length)
  {
alert(reason)
 return false;
  }
  return true;
}

//
function IsDate(dd,mm,yyyy) {
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;
if (mm !="" && !(mm > 0 && mm < 13)){alert ("El mes es inválido. Ingrese un número de 1 a 12.");return false;}
if (dd !="" && !(dd > 0 && dd < 32)){alert ("El día es inválido. Ingrese un número de 1 a 31.");return false;}
if ((dd!="" && mm!="") && dd > daysInMonth[parseInt(mm,10)]){alert ("El día es inválido para el mes elegido.");return false;}
if (yyyy !="" && !(yyyy > 1898 && yyyy < 2200)){alert ("El año es inválido. Ingrese un número de 1900 and 2200.");return false;}
if ((mm=="2" || mm=="02" && dd!="" && yyyy!="") && dd > daysInFebruary(yyyy)){alert ("El día es inválido para el año elegido.");return false;}
return true;
}

//
function IsNum(passedVal) {
	if (passedVal == "") {
		return true
	}
	can=0
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i)!=="." && passedVal.charAt(i)!==","){
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
		}else{	
		can=can+1
		}
	}
	if (can==2) {return false}
	return true
}

function Trim(str) {
	var resultStr = "";
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	return resultStr;
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		// Loop through string starting at the end as long as there
  		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
 		// When the loop is done, we're sitting at the last non-space char,
 		// so return that char plus all previous chars of the string.
  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function InStr(strSearch, charSearchFor)
{
            for (i=0; i < strSearch.length; i++)
            {
                  if (charSearchFor == Mid(strSearch, i, 1))
                  {
                        return i;
                  }
            }
            return -1;
}

//-->

