//Para el administrador de contenidos
function getIFrameDocument(aID){
	if (document.getElementById(aID).contentDocument){  
    	return document.getElementById(aID).contentDocument;
  	} else {
    	return document.frames[aID].document;
   	}
}
 
function doRichEditCommand(opt, aName, aArg){
	getIFrameDocument(opt).execCommand(aName,false, aArg);
  	document.getElementById(opt).contentWindow.focus();
} 
    
function addLink(opt){
	var myUrl = prompt("Please enter a URL:", "");
  	getIFrameDocument(opt).execCommand("createLink", false, myUrl);
}    


// view soruce

function getSource(){
  document.getElementById("sourceView").innerHTML = replace(getIFrameDocument("editorWindow").body.innerHTML,"<","&lt;");
}
    
function replace(string,text,by) {
	var stringLength = string.length
  	var textLength = text.length;
  	if ((stringLength == 0) || (textLength == 0)) return string;

  	var i = string.indexOf(text);
  	if ((!i) && (text != string.substring(0,textLength))) return string;
  	if (i == -1) return string;

  	var newstr = string.substring(0,i) + by;

  	if ( (i+textLength) < stringLength)
    	newstr += replace(string.substring(i+textLength,stringLength),text,by);
  	return newstr;
}

      
function color(sComando, opt){          
    if (!document.execCommand){ 
        alert("Función no disponible"); 
        return false; 
    } 
    
    var iColor = document.getElementById("dialogHelper").ChooseColorDlg(0xFFFFFF); 
     
    var sColor = iColor.toString(16); 
    sColor = "#" + "000000".substring(0, 6 - sColor.length) + sColor; 
    
    getIFrameDocument(opt).execCommand(sComando, false, sColor);
  	document.getElementById(opt).contentWindow.focus(); 


} 

function comando_documento(sComando, bInterfaz_de_usuario, Anadido,opt){ 
	if (!document.execCommand){ 
	    alert("Función no disponible"); 
	    return false; 
	} 
	getIFrameDocument(opt).execCommand(sComando, false, Anadido); 
  	document.getElementById(opt).contentWindow.focus();
	 
} 
function codigo(objBoton, opt){ 
	
    getIFrameDocument(opt).body.innerText = getIFrameDocument(opt).body.innerHTML;
    document.getElementById(opt).contentWindow.focus();
    
}

function ocultarCodigo(objBoton, opt) {
	getIFrameDocument(opt).body.innerHTML = getIFrameDocument(opt).body.innerText;
 	document.getElementById(opt).contentWindow.focus();             
} 
// Termina el editor de contenidos

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/* estos si van*/
//****************************************************
function showhide(este){
	obj = document.getElementById(este);
    if (obj.style.display == "") {
        obj.style.display = "none"
    } else {
        obj.style.display = ""
    }
	
}

function requerido(campo,forma) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;	}
	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("Por favor asegurese el campo "+tempobj.id+" ha sido llenado.");
			return false;
		} else {
			return true;
		}
	}
}


//****************************************************
function emailCheck1() { 
  	txt=document.frm.R_email.value; 
	if (txt.indexOf("@")<3){ 
	   alert("Disculpe. La direccion del email no es correcta. Porfavor" 
	   +" chequee el prefijo y luego coloque el simbolo '@'."); 
	} 
	if ((txt.indexOf(".")<7)){ 
	   alert("Disculpe. La direccion del email no es correcta. Porfavor" 
	   +" chequee el nombre del servidor, el punto '.' y el sufijo que esta despues del simbolo '@'.\n(Esto incluye: " 
	   +" .com, .net, .org, .gov, .mil\nO sufijo de paises: .ar, .cz, .us, .es, .fr, .uk, etc. etc)"); 
	} 
} 
//****************************************************
function emailCheck (emailStr,campo) {
	var datos = "Este campo es emailStr "+ emailStr + " este campo :" + campo
	alert(datos)
	//return false
	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 numeros!");
		field.focus();
		field.select();
   }
}
//****************************************************************

function validarMonto(field, valor) {
	if (field.value > valor) {
		alert("La cantidad debe ser menor o igual a "+ valor);
		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 cretb(este){
	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')[este].focus();
 	var newTable = document.body.all.tags('div')[este].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')[este].document.selection.type=='Control') {
 		sel.pasteHTML(newTable.outerHTML);
 	} else {
 		sel = document.body.all.tags('div')[este].document.selection.createRange();
 		sel.pasteHTML(newTable.outerHTML);
 	}
 
 	var r = document.body.all.tags('div')[este].document.body.createTextRange();
 	var item=document.body.all.tags('div')[este].document.getElementById('ura');
 	item.id='';
 	r.moveToElementText(item);
 	r.moveStart('character',r.text.length);
 	r.select();
}

function cmdExec(cmd,opt) {
	cmp1= document.getElementById(opt) ;
	document.execCommand(cmd,false, opt); 
  	cmp1.focus(); 
	//document.body.all.tags('div')[opt].document.execCommand(cmd,"",opt);
	//	document.body.all.tags('div')[opt].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 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', 'P','p');
//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 ];
	}
}

function muestr(fila){
	fila.bgColor='#c5c5c5';
}
function esc(fila){
	fila.bgColor='';
}

function validarbotonradio() { 
	var s = "no"; 
	with (document.frm){ 
		for ( var i = 0; i < ruhuman.length; i++ ) { 
			if ( ruhuman[i].checked ) {
				if (ruhuman[i].value == "2") {
					s= "si"; 
					window.alert("Ha indicado que no Eres un Humano. Por favor verifique.");
					break;
				} else {
					s= "si"; 
					break;	
				}
				 
			} 
		} 
		if ( s == "no" ){ 
			window.alert("Por favor asegurese el campo Eres un Humano? ha sido llenado.");
			
		} 
	} 
} 

isIE=document.all?true:false;
var isNS4=document.layers?true:false; 
var isNS6=navigator.userAgent.indexOf("Gecko")!=-1?true:false;
var bC=new Array('#FFE759','white');
var C=new Array('black','#d58200');

function doIt(pref,_v) {
	var X=eval("document.exf1."+pref+[_v]+".checked?0:1");
  	if(isIE) {
    	eval("t"+_v+".style.backgroundColor=bC[X]");
    	eval("t"+_v+".style.color=C[X]");
  	}
  	if(isNS6) {
    	document.getElementById("t"+_v).style.backgroundColor=bC[X];
    	document.getElementById("t"+_v).style.color=C[X];
  	}
}

function checkAll(prefijo,cant) {
	for (var j = 1; j <= cant; j++) {
		box = eval("document.exf1."+prefijo + [j]);	
		if (box.checked == false) box.checked = true;
		var X=eval("document.exf1."+prefijo+[j]+".checked?0:1");
	  	if(isIE) {
	    	eval("t"+j+".style.backgroundColor=bC[X]");
	    	eval("t"+j+".style.color=C[X]");
	  	}
	  	if(isNS6) {
	    	document.getElementById("t"+j).style.backgroundColor=bC[X];
	    	document.getElementById("t"+j).style.color=C[X];
	  	}
   }
}
		
function uncheckAll(prefijo,cant) {
	for (var j = 1; j <= cant; j++) {
		box = eval("document.exf1."+prefijo + [j]);
		if (box.checked == true) box.checked = false;
		var X=eval("document.exf1."+prefijo+[j]+".checked?0:1");
	  	if(isIE) {
	    	eval("t"+j+".style.backgroundColor=bC[X]");
	    	eval("t"+j+".style.color=C[X]");
	  	}
	  	if(isNS6) {
	    	document.getElementById("t"+j).style.backgroundColor=bC[X];
	    	document.getElementById("t"+j).style.color=C[X];
	  	}
	}
}
function doCheckAll(prefijo) {
	with (document.frmprd) {
    for (var i=0; i < elements.length; i++) {
        if (elements[i].type == 'checkbox' && elements[i].name == prefijo)
        	elements[i].checked = true;        	
    	}
  	}
}

function UnCheckAll2(prefijo) {
	with (document.frmprd) {
    for (var i=0; i < elements.length; i++) {
    	if (elements[i].type == 'checkbox' && elements[i].name == prefijo)
        	elements[i].checked = false;           	
    	}
  	}
}
function esFechaValida(fecha){
    if (fecha != undefined && fecha.value != "" ){
        if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){
            alert("formato de fecha no válido (dd/mm/aaaa)");
            return false;
        }
        var dia  =  parseInt(fecha.value.substring(0,2),10);
        var mes  =  parseInt(fecha.value.substring(3,5),10);
        var anio =  parseInt(fecha.value.substring(6),10);
 
    switch(mes){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8: 
        case 10:
        case 12:
            numDias=31;
            break;
        case 4: case 6: case 9: case 11:
            numDias=30;
            break;
        case 2:
            if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
            break;
        default:
            alert("Fecha introducida errónea");
            return false;
    }
 
        if (dia>numDias || dia==0){
            alert("Fecha introducida errónea");
            return false;
        }
        return true;
    }
}
 
function comprobarSiBisisesto(anio){
if ( ( anio % 100 != 0) && ((anio % 4 == 0) || (anio % 400 == 0))) {
    return true;
    }
else {
    return false;
    }
}

function Sumar(Linea, Campo) {
    var objCamp1="";
    var objCamp3="";
    var objCamp2="";
    if (Campo =="1") {
		objCamp1=document.getElementById("R_CostoDominio"+Linea);
		objCamp2=document.getElementById("R_PagoDominio"+Linea);
	} else {
		objCamp1=document.getElementById("R_CostoHosting"+Linea);
		objCamp2=document.getElementById("R_PagoHosting"+Linea);
	}    	
    
	objCamp3=document.getElementById("Total"+Linea);
	if (objCamp3.value =='') {
		objCamp3.value =0;
	}
   	if ((objCamp1.value!='')){
   		if (objCamp2.checked == false) {
   			objCamp3.value = parseInt (objCamp3.value) - parseInt(objCamp1.value) ;
   		} else {
   			objCamp3.value = parseInt (objCamp3.value) + parseInt(objCamp1.value) ;
   		}
    }
}

function cerrarVentana()
	{
	  	var window = window.self;
	  	window.opener = window.self;
	  	window.close();
	}
	
	function esVacio(campo,etiqueta){
		if (campo.value.length==0){
			alert("El campo \"" + etiqueta + "\" no puede estar vacio");
			campo.focus();
			return true;
		}else{
			for(var i=0; i<campo.value.length; i++)
				if((campo.value.charAt(i)=='')||(campo.value.charAt(i)=='\t')){
					alert("El campo \"" + etiqueta + "\" no puede estar vacio");
					campo.focus();
					return true;
				}
			return false;
		}
	}

	function longitudDeCampo(campo){
		return campo.value.length;
	}

	function tieneLongitudMinima(campo,nombreCampo,longitudMinima){
			if (longitudDeCampo(campo)<longitudMinima){
				alert("El campo \"" + nombreCampo + "\" debe contener al menos "+longitudMinima+" caracteres");
				campo.focus();
				return false;
			}else{
				return true;	
			}
	}
	
	function exedeLongitudMaxima(campo,nombreCampo,longitudMaxima){
			if (longitudDeCampo(campo)>longitudMaxima){
				alert("El campo \"" + nombreCampo + "\" no puede contener más de "+longitudMaxima+" caracteres");
				campo.focus();
				return true;
			}else{
				return false;	
			}
	}

	function esCampoVacio(campo){
		if (campo.value.length==0){
			return true;
		}else{
			return false;
		}
	}

	function esNumero(campo,etiqueta){
		numeros="0123456789";
		for (var i=0; i<campo.value.length;i++){
			if(numeros.indexOf(campo.value.charAt(i))<0){
				alert("El campo \"" + etiqueta + "\" solo puede contener caracteres numéricos sin decimal (ni . ni ,)");
				campo.focus();
				return false;
			}
		}
		return true;
	}
	
	function IsUnsignedReal(YourNumber)
	{
		var Template = /^((d+(.d*)?)|((d*.)?d+))$/ //Formato de numero real sin signo
		return (Template.test(YourNumber)) ? 1 : 0 //Compara "YourNumber" con el formato "Template" y si coincidevuelve verdadero si no devuelve falso
	}
	
	function esNumeroReal(campo,etiqueta){
		numeros="0123456789.";
		for (var i=0; i<campo.value.length;i++){
			if(numeros.indexOf(campo.value.charAt(i))<0){
				alert("El campo \"" + etiqueta + "\" solo puede contener caracteres numéricos y como separador  decimal un punto");
				campo.focus();
				return false;
			}
		}
		punto=0;
		puntos=".";
		for (var i=0; i<campo.value.length;i++){
			if(!(puntos.indexOf(campo.value.charAt(i))<0)){
				punto=punto+1;
				if (i==0){
					alert("El campo \"" + etiqueta + "\" no puede iniciar con un punto");
					campo.focus();
					return false;
				}
				
				if (punto>1){		
					alert("El campo \"" + etiqueta + "\" solo puede contener como separador decimal un solo punto");
					campo.focus();
					return false;
				}
				
				if (i==campo.value.length-1){
					alert("El campo \"" + etiqueta + "\" no puede terminar con un punto");
					campo.focus();
					return false;
				}
			}
		}
		return true;
	}
	
	function indexSeleccionadoDelCombo(slcCombo){
		return slcCombo.selectedIndex;
    }
    function totalDeItemsDelCombo(slcCombo){
		return slcCombo.length;
    }
    
	function valueSeleccionadoDelCombo(slcCombo){
		i=indexSeleccionadoDelCombo(slcCombo);
		return slcCombo.options[i].value;
	}
	
	function textSeleccionadoDelCombo(slcCombo){
		i=indexSeleccionadoDelCombo(slcCombo);
		return slcCombo.options[i].text;
	}
	
	function seSeleccionoValorDelCombo(slcCombo,valorDeNoSeleccion,campo){
		i=valueSeleccionadoDelCombo(slcCombo);
		
		if (i==valorDeNoSeleccion){
			alert("Debe selecionar "+ campo)
			slcCombo.focus();
			return false;
		}
		return true;
	}
	
	function seSeleccionoValorDelCombo2(slcCombo,valorDeNoSeleccion,campo,slcCombo2,valorDeNoSeleccion2,campo2){
		i=valueSeleccionadoDelCombo(slcCombo);
		j=valueSeleccionadoDelCombo(slcCombo2);
		
		if (i==valorDeNoSeleccion && j==valorDeNoSeleccion2){
			alert("Debe selecionar "+ campo+ " ó " + campo2)
			slcCombo.focus();
			return false;
		}
		return true;
	}
	
	//CHECK
	function checkCheckeado(chkCheck){
		return chkCheck.checked;
    }
	
	
	function hayRadioButtonSeleccionado(nombreRadio,nombreFila){
		//caso de que quede solo uno es decir no es un arreglo
		if (nombreRadio.checked) return true;
		//caso de que halla varios
		for(i=0;i<nombreRadio.length;i++){
	        if(nombreRadio[i].checked) return true;
		}
	
		alert ("Debe selecionar "+ nombreFila);
		return false;
	}
	
	function valueDeRadioButtonSeleccionado(nombreRadio){
		if (nombreRadio.checked){ 
			return nombreRadio.value;
		}
		//caso de que halla varios
		for(i=0;i<nombreRadio.length;i++){
	        if(nombreRadio[i].checked){ 
				return nombreRadio[i].value;
			}
		}
		return "";
	}
	
	function irAPagina(pagina){
		window.location.href = pagina;
	}
	
	function IrAPaginaAnterior(){
		javascript:history.back();
	}
	
	function IrAPaginaSiguiente(){
		javascript:history.forward();
	}
	
	function mostrarPaginaEnMarco(pagina,marco){
		window.open(pagina,marco);
	}
	
	function mostrarPaginaEnMarco(pagina,marco){
		window.open(pagina,marco);
	}
	//otro metodo para redireccionar paginas
	//window.leftFrame.location.href='left.php';
	
	
	
	//validar la hora
	function horaValida(txtHora,nombre){ 
	if (txtHora.text != ""){ 
			numeros="0123456789: apm";
			for (var i=0; i<txtHora.value.length;i++){
				if(numeros.indexOf(txtHora.value.charAt(i))<0){
					alert("Debe verificar el campo \"" + nombre + "\"");
					campo.focus();
					return false;
				}
			}
			return true;
	}

		alert("Introduzca una hora valida en "+nombre);
		txtFecha.focus();
		return false; 
   	}  	
	
	
		
//****************************************************************validar fecha desde aqui
	//esta es la que se llama
   	function fechaValida(txtFecha,nombre){ 
        if (txtFecha.text != ""){ 
			if (!valDia(txtFecha)){
				alert("Verifique el día y el mes de "+nombre);
        		txtFecha.focus();
				return false;
			}else if (!valMes(txtFecha)){
				alert("Verifique el mes de "+nombre);
        		txtFecha.focus();
				return false;
			}else if(!valAno(txtFecha)){
				alert("Verifique el año de "+nombre);
        		txtFecha.focus();
				return false;
			}else if(!valSep(txtFecha)){
				alert("Los separadores deben ser '/' en "+nombre);
        		txtFecha.focus();
				return false;
			} 		 
			return true;
        }
        
		alert("Introduzca una fecha valida en "+nombre);
        txtFecha.focus();
		return false; 
		 
   	}  	
	
	
   	function valSep(txtFecha){ 
    	var bOk = false; 
    	var sep1 = txtFecha.value.charAt(2); 
    	var sep2 = txtFecha.value.charAt(5); 
    	bOk = bOk || ((sep1 == "/") && (sep2 == "/")); 
    	return bOk; 
   	} 

   	
    function valAno(txtFecha){  
    	var bOk = false; 
    	var aux= txtFecha.value.substr(6, 4);
		if (esCadenaNumerica(aux)){
			bOk = true;
		}
    	return bOk; 
   	} 
   
   	function valMes(txtFecha){ 
		var bOk = false; 
    	var aux= txtFecha.value.substr(3, 2);
		if (esCadenaNumerica(aux)){
			var nMes = parseInt(aux, 10);	
			bOk = (nMes >= 1) && (nMes <= 12);
		}
    	return bOk; 
   	} 
   	
   	function valDia(txtFecha){ 
    	bOk = false; 
    	aux= txtFecha.value.substr(0, 2);
		if (esCadenaNumerica(aux)){
			nDia = parseInt(aux, 10);	
			bOk = (nDia >= 1) && (nDia <= finMes(txtFecha));
		}
    	return bOk; 
   	}
   
   function finMes(txtFecha){ 
    	var nMes = parseInt(txtFecha.value.substr(3, 2), 10); 
    	var nRes = 0; 
    	switch (nMes){ 
     		case 1: nRes = 31; break; 
     		case 2: nRes = 28; break; 
		    case 3: nRes = 31; break; 
		    case 4: nRes = 30; break; 
		    case 5: nRes = 31; break; 
		    case 6: nRes = 30; break; 
		    case 7: nRes = 31; break; 
		    case 8: nRes = 31; break; 
		    case 9: nRes = 30; break; 
		    case 10: nRes = 31; break; 
		    case 11: nRes = 30; break; 
		    case 12: nRes = 31; break; 
    	} 
    	return nRes; 
   	} 

   	function esCadenaNumerica(cadena){
		numeros="0123456789";
		for (var i=0; i<cadena.length;i++){
			if(numeros.indexOf(cadena.charAt(i))<0){
				return false;
			}
		}
		return true;
	}

