/* estos si van*/
//****************************************************
function showhide(este){
	if (este.style.display=='none'){
		este.style.display='';
	}
else {
	este.style.display='none'
}
}

function requerido(campo,forma) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;
		//break;
	}
	if (!lleno) {
		alert('Asegurese que el campo '+campo.name+' ha sido llenado');
		return false;
	}
else {
	forma.submit();
	return true;
	}
}

function req(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,2)=="R_") {
if (((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Asegúrese que el campo "+tempobj.id+" ha sido llenado.");
return false;
}
else
return true;
}
//****************************************************
function emailCheck (emailStr,campo) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Error, la direccion de correo es incorrecta")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    // user is not valid
    alert("Error, la direccion de correo es incorrecta")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Error, la direccion de correo es incorrecta")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Error, la direccion de correo es incorrecta")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("Error, la direccion de correo es incorrecta")
   return false
}

if (len<2) {
   alert("Error, la direccion de correo es incorrecta")
   return false
   
}

return true;
}
//****************************************************************
function validarn(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Debe ingresar solo números!");
field.focus();
field.select();
   }
}
//****************************************************************
function sololetras(which) {
var valido= "\"'";
	if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password"){
			for (var j=0; j<tempobj.value.length; j++) {
var ok="yes";
			temp = tempobj.value.substring(j, j+1);
				if (valido.indexOf(temp) == "-1") ok = "no";
			
		if (ok == "yes") {
		alert("No debe ingresar comillas simples o dobles ("+tempobj.id+")");
		tempobj.focus();
		tempobj.select();
		return false;
		}
		}
		}
	}
	}
}
//****************************************************************
function vergemelos(form) {
var ok = "yes";
		if (form.elements["R_clave1"].value!=form.elements["R_clave2"].value) ok = "no";
		
		if (ok == "no") {
		alert ("La clave no concuerda con su confirmación");
		form.elements["R_clave1"].focus();
		return false;
	}
}


function checkPw(este) {
var otro=este.name
otro=otro.replace("2","1");
if (este.value != eval("document.all."+otro+".value")) {
alert ("\No coinciden "+eval("document.all."+otro+".id")+ " y " +este.id)
eval("document.all."+otro+".focus()")
return false;
}
}

function startTimer() {
setTimeout('Aviso()',540000);
setTimeout('Logout()',599990);
}
function Logout() {
window.location.href="abandon.asp"
return false;
}
function Aviso() {
window.open('Aviso.htm','aviso','scrollbars=no,status=no,menubar=no,resizable=no,location=no,directories=no,top=220,left=200,width=400,height=120');
return false;
}

function cretb(){
var Filas=  prompt ("Introduzca el número de filas de la Tabla", "5" );
var Columnas=  prompt ("Introduzca el numero de columnas de la Tabla", "5" );
  document.body.all.tags('div')['html1'].focus();
 var newTable = document.body.all.tags('div')['html1'].document.createElement('TABLE');
 for(y=0; y<Filas; y++)
 {
 var newRow = newTable.insertRow();
 
 for(x=0; x<Columnas; x++)
 {
  newRow.bgColor='#f0f0f0';
  var newCell = newRow.insertCell();
 
 if ((y==0)&&(x==0)) newCell.id='ura';
 }
 }
 newTable.border = 1
 newTable.cellSpacing=0
 newTable.cellpadding=0
 newTable.style.fontSize=11
 newTable.width = Columnas * 50;
 if (document.body.all.tags('div')['html1'].document.selection.type=='Control')
 {
 sel.pasteHTML(newTable.outerHTML);
 }
 else
 {
 sel = document.body.all.tags('div')['html1'].document.selection.createRange();
 sel.pasteHTML(newTable.outerHTML);
 }
 
 var r = document.body.all.tags('div')['html1'].document.body.createTextRange();
 var item=document.body.all.tags('div')['html1'].document.getElementById('ura');
 item.id='';
 r.moveToElementText(item);
 r.moveStart('character',r.text.length);
 r.select();
}

function cmdExec(cmd,opt) {
document.body.all.tags('div')['html1'].document.execCommand(cmd,"",opt);
document.body.all.tags('div')['html1'].focus();
}

function AddLink()
{//Identify selected text
var sText = document.selection.createRange();
if (!sText==""){
    //Create link
     document.execCommand("CreateLink");
     //Replace text with URL
     if (sText.parentElement().tagName == "A"){
       //sText.parentElement().innerText=sText.parentElement().href;
       //document.execCommand("ForeColor","false","#0000ff");
     }    
  }
else{ 
    alert("Selecciona el texto primero!");
  }   
}

function validarn(field) {
var valid = "0123456789."
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Debe ingresar solo números!");
field.focus();
field.select();
   }
}

function versuma(which,tipo) {
var sac = 0;
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,3)=="PED") {
if (tempobj.checked==true) {
	sac += 1;
	}
	}
	}
if (sac == 0) {
alert("Debe seleccionar al menos 1 "+tipo);
return false;
}
else
return true;
}

function nochr(field) {
var valid = "0123456789.ABCDEFGHIJKLMNOPQRSTVWXYZ,abcdefghijklmnopqrstvwxyz \""
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Por favor, no introduzca caracteres especiales");
field.focus();
field.select();
   }
}

function Iimage() {
	window.open("Iimages.asp","Fotos","scrollbars=yes,maximize=no,width=500,height=400");
  }
function InsertImage(archivo) {
 // Clear the selection if it's an image (would cause an error otherwise)
	archivo = '<img src="' + archivo + '" border="0">';
	document.all.tags('div')['html1'].innerHTML=document.all.tags('div')['html1'].innerHTML+archivo;
	document.body.all.tags('div')['html1'].focus();
//}
}


function addSrcToDestList(nn) {
destList = window.document.forms[nn].destList;
srcList = window.document.forms[nn].srcList; 
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
//Check if this value already exist in the destList or not
//if not then add it otherwise do not add it.
var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
      }
   }
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text); 
destList.options[len].value = srcList.options[i].value; 
len++;
         }
      }
   }
}

function deleteFromDestList(nn) {
var destList  = window.document.forms[nn].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
      }
   }
}

function sall(nn){
var list = window.document.forms[nn];
//if (list.destList.length!=0){
for (i=0; i<list.destList.length; i++) {
	list.destList.options[i].selected = true; 
}
//}
list.submit()
}
function insertnre() {
destList = window.document.forms[0].destList;
var len = destList.length;
destList.options[len] = new Option(document.forms(0).nombre.value); 
destList.options[len].value = document.forms(0).email.value+'|'+document.forms(0).nombre.value; 
document.forms(0).nombre.value='';
document.forms(0).email.value='';
len++;
}

var tgs = new Array( 'div','td','tr','font');
//var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var szs = new Array( '9px','11px','13px','15px','17px','19px','21px','23px' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}