function testEmail(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
}

function validaEmail(form)
{		
		form.validado.value="0";
		if (testEmail(form.email.value)==false)
		{	form.email.value='Email inválido';
			return false;
		}
		if (form.resumen.value=='')
		{	form.resumen.value='Especifique su inquietud';
			return false;
		}
		form.validado.value="1";
		return true;
}

function RefreshImage(valImageId) 
{
	var objImage = document.images[valImageId];
	if (objImage == undefined) 
	{
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function Submit()
{
	document.add.submit();
	//alert (document.add.id_cli.value);
}

function valida_envia(){
    //valido el nombre
		if(document.cuenta.tipo[0].selected == true ){
			alert('Debe Seleccionar un Tipo de Cuenta');
			//document.cuenta.tipo.select();
			return false
		}

		if(document.cuenta.txtDocCI[0].selected == true ){
			alert('Debe Seleccionar un Tipo de Documento');
			document.cuenta.tipo.focus();
			document.cuenta.tipo.select();
			//document.cuenta.tipo.select();
			return false
		}

    if (document.cuenta.strCAPTCHA.value.length==0){
       alert("Tiene que escribir los Caracteres de la Imagen CAPTCHA")
       document.cuenta.strCAPTCHA.focus()
       return 0;
    }
}

function habilitar(form)
{
    if ((document.cuenta.txtDocCI[1].selected == true) || (document.cuenta.txtDocCI[2].selected == true) || (document.cuenta.txtDocCI[3].selected == true) || (document.cuenta.txtDocCI[4].selected == true) || (document.cuenta.txtDocCI[5].selected == true))
    {
	    document.cuenta.txtCedula.disabled = false;
    }
    else
    {
			document.cuenta.txtCedula.disabled = true;
    }
}

function nombreMenu(form)
{
    if ((document.add.tipomenu[2].selected == true))
    {
			document.add.name.style.visibility ='hidden';
			document.add.sp.style.visibility = 'visible';
    }
    else
    {
			document.add.sp.style.visibility = 'hidden';
			document.add.name.style.visibility ='visible';
    }
}

function CountLeft(field, count, max) {
	if (field.value.length > max)
		field.value = field.value.substring(0, max);
	else
		count= max - field.value.length;
}

function actTxtDoc()
{
	if (document.cuenta.tipo.value == '')
	{
		document.cuenta.txtDoc.disabled=true;
	}
	else 
	{
		document.cuenta.txtDoc.disabled=false;
	}
	if (document.cuenta.txtDoc.value == '')
	{
		document.cuenta.txtDocCI.disabled=true;
	}
	else 
	{
		document.cuenta.txtDocCI.disabled=false;
		if (document.cuenta.txtDoc.value=='Cedula')
		{
			document.cuenta.txtDocCI[3].disabled = true;
			document.cuenta.txtDocCI[4].disabled = true;
			document.cuenta.txtDocCI[5].disabled = true;
		}
		else
		{
			document.cuenta.txtDocCI[1].disabled = false;
			document.cuenta.txtDocCI[2].disabled = false;
			document.cuenta.txtDocCI[3].disabled = false;
			document.cuenta.txtDocCI[4].disabled = false;
			document.cuenta.txtDocCI[5].disabled = false;
		}
	}
}

function CambiaTam()
{
	var NV = new Is();
	//alert (NV);
		if (document.cuenta.txtDocCI.value == 'V')
		{
			if (NV.ie)
			{
				if (document.cuenta.txtDoc.value=='Cedula')
				{
					CountLeft(document.cuenta.txtCedula,this.left,7);
				}
				else
				{
					CountLeft(document.cuenta.txtCedula,this.left,8);
				}
			}
			else if (NV.ns)
			{
				if (document.cuenta.txtDoc.value=='Cedula')
				{
					CountLeft(document.cuenta.txtCedula,this.left,8);
				}
				else
				{
					CountLeft(document.cuenta.txtCedula,this.left,9);
				}
			}
		}
		else
		{
			if (NV.ie)
			{
				CountLeft(document.cuenta.txtCedula,this.left,8);
			}
			else if (NV.ns)
			{
				CountLeft(document.cuenta.txtCedula,this.left,9);
			}
		}
}

function CambiaTam2()
{
	if (document.cuenta.txtDoc.value=='Cedula')
			{
			document.getElementById("txtCedula").maxLength=8;
			}
	else
			{
			document.getElementById("txtCedula").maxLength=9;
			}
	}

function rellenar(quien,que)
{
	cadcero='';
	if (document.cuenta.txtDocCI.value=='V') {
		for(i=0;i<(8-que.length);i++)
		{
			cadcero+='0';
		}
		quien.value=cadcero+que;
	}
}


function validaDoc(doc)
{
    if ((form.txtDocCI[1].selected == true) || (form.txtDocCI[2].selected == true))
    {
	    doc = 'V';
    }
    else
    {
			doc = 'E';
    }
		return doc
}

/* Función genérica para abrir nuevas ventanas */
function openWindow(address, name, options)
{
	var newwin = null;
	newwin = window.open(address,name,options);
	if (newwin.opener == null) {
		newwin.opener = self;
	}
}

/* Funcion generica para bloquear botón derecho mouse */
function click(e){
	var code; 
	
	if(document.all)
		code = event.button; 
	else
		code = e.button;
	
	if(code==2){
		alert('Copyright© 2005 Magitel - Todos los derechos reservados');
	}
}

/* Abre una ventana con la página de seleccionar categorías */
function openDetallesWindow(address)
{
	openWindow(address,'selprod','scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, width=650, height=500');
}

/* Abre una ventana con la página de seleccionar categorías */
function openCategoriesWindow(address)
{
	openWindow(address,'selcat','scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, width=500, height=500');
}

/* Abre una ventana con la página html de sugerencias de regalos */
function openSugerenciasWindow(address)
{
	openWindow(address,'selsug','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=500,height=500');
}

/* Abre una ventana para ver una imagen en el módulo administrativo */
function openImageWindow(image)
{
	openWindow(path+'admin/shared/p_verimagen.asp?image='+image,'image','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=540,height=540');
}

/* Abre una ventana para ver una imagen en el site */
function openSiteImageWindow(image)
{
	openWindow(path+'site/shared/p_verimagen.asp?image='+image,'image','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=540,height=540');
}

/* Abre una ventana para ver una imagen en el site Lista de Bodas */
function openSiteImageWindowBodas(image)
{
	openWindow(path+'site/lista_bodas/shared/p_verimagen.asp?image='+image,'image','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=540,height=540');
}

/* Abre una ventana para ver una imagen en el site para Secciones del Administrador*/
function openSiteImageWindowSec(image)
{
	var pathimg
	pathimg='imagenes/site/varios/'
	openWindow(path+'site/shared/p_verimagen.asp?image='+path+image,'image','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=920,height=600');
}


function valida_template(operacion)
{
	if (document.add.name.value=='')
	{
		alert ('Indique el nombre del template');
		document.add.name.focus();
		return false;
	}
	if (operacion==0){ //si es nuevo valida que se haya seleccionado la imagen
		if (document.add.file.value=='')
		{
			alert ('Seleccione el archivo');
			document.add.file.focus();
			return false;
		}
	}
	return true;
}

function valida_evento()
{
	if (document.add.titulo.value=='')
	{
		alert ('Indique el título del evento/promoción');
		document.add.titulo.focus();
		return false;
	}
	if (document.add.resumen.value=='')
	{
		alert ('Indique el resumen del evento/promoción');
		document.add.resumen.focus();
		return false;
	}
	if (document.add.contenido.value=='')
	{
		alert ('Indique el contenido del evento/promoción');
		document.add.contenido.focus();
		return false;
	}
	if (document.add.fecha.value=='')
	{
		alert ('Indique la fecha del evento/promoción');
		document.add.fecha.focus();
		return false;
	}
	if (document.add.tipo.value=='')
	{
		alert ('Indique si es un evento o una promoción');
		document.add.tipo.focus();
		return false;
	}
	if (document.add.file1.value=='')
	{
		alert ('Seleccione el archivo');
		document.add.file1.focus();
		return false;
	}
	return true;
}


function checkCheckBox(boton)
{
	if (boton.checked == false )
	{
		alert('Por favor, recuerde que debe aceptar los Términos y Condiciones del Portal');
		return false;
	}else {
		return true;
	}
}


function valnumeric(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("Recuerde que sólo debe ingresar números.");
		field.focus();
		field.select();
	}
}

function viewcard(field)
{
	if (field == 3)
	{
		alert("Recuerde Si esta utilizando la Tarjeta American Express.\nFavor en el Colocar de Seguridad los 4 Números del Código Alfa, \nUbicado Frente de la Tarjeta.");
		field.focus();
		field.select();
	}
}

function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}

function validatePassLength(campo)
{
	//var RegExPattern = /(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{5,20})$/; 
	
	
	var errorMessage = 'Clave Incorrecta.\nDebe incluir la clave según las especificaciones.'; 
	//if ((!campo.value.match(RegExPattern)) && (campo.value!=''))
	
	
	if (campo.value.length <=4) 	
	{
		alert('Clave Incorrecta.\nDebe incluir la clave según las especificaciones.'); 
		campo.focus(); 
	} 
} 

/************* Funcion que valida solo Letras ************************************/
//patron = /\d/; // Solo acepta números
//patron = /\w/; // Acepta números y letras
//patron = /\D/; // No acepta números
//patron =/[A-Za-z\s]/; Solo letras pero sin las letras ñ y Ñ 
//patron =/[A-Za-zñÑ\s]/; // igual que el ejemplo, pero acepta también las letras ñ y Ñ

function acceptletras(e) {
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; 
    patron =/[A-Za-zñÑ\s]/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te); 
} 
/**************/


/************* Funcion que validan alfanumericos ************************************/
function acceptAlfaNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	,Tabs =0
var nav4 = window.Event ? true : false;
var key = nav4 ? evt.which : evt.keyCode;	

return ((key >=48 && key <=57) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || (key ==8)|| (key==13)|| (key==9) || (key==0) );
}
/**************/


/************* Funcion que valida solo numeros ************************************/
var nav4 = window.Event ? true : false;
function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57

var key = nav4 ? evt.which : evt.keyCode;	

return (key <= 13 || (key >= 48 && key <= 57)|| key==44);
}
//-->

/************* Funcion que valida email ************************************/
function validarEmail(valor) {
	//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3,4})+$/.test(valor)){
	if (/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/.test(valor)){
		//alert("La dirección de email " + valor + " es correcta.");
	} else {
		alert("La dirección de email es incorrecta.");
	}
}

function valEmail(valor){
    re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(valor))    {
			alert("La dirección de email es incorrecta.");
			return false;
    }else{
			alert("La dirección de email es correcta.");
			return true;
    }
}

function valida_pago()
	{
		var fecha=document.getElementById('f_date_b').value;
		var confirma=document.getElementById('num_confirma').value;
		var monto=document.getElementById('monto').value;
		if (fecha=="")
			{
			alert("Debe especificar una fecha de pago.");	
			return false;
			}
		if (confirma=="")
			{
			alert("Debe especificar un numero de confirmación.");	
			return false;
			}
		if (monto=="")
			{
			alert("Debe especificar el monto");	
			return false;
			}
		return true;
		}

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_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una direccion de email.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' Debe contener un numero.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- El '+nm+' es requerido para enviar la solicitud .\n'; }
} if (errors) alert('Errores en el formulario:\n\n'+errors);
document.MM_returnValue = (errors == '');
} 

/**************/

/************** Funcion para colocar la primera Letra en Mayuscula *****************/
function FirtsUppercase(element){
	if (element.length==1){
		element.value=toUpperCase(element)
	}
}



/*****************************************************************************************************************************/

	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_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_findObj2(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_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];}
	}

function validatePass(campo)
{
	var RegExPattern = /(^[a-zA-Z0-9]{5,20})$/; 
	var errorMessage = 'Clave Incorrecta. Recuerde que la Clave debe contener entre 5 y 20 caracteres, entre los cuales puede usar cualquier letra (a-z) y/o n&uacute;mero (0-9). No están permitido los caracteres especiales.'; 
	if (!(campo.value.match(RegExPattern)) && (campo.value!=''))
	{
		alert(errorMessage); 
		campo.focus(); 
	} 
} 
function telefonos()
{
 if (document.CreateAccount.txtCodigoPais.value != "" && document.CreateAccount.txtCodigoArea.value != "" && document.CreateAccount.txtNumTelefono.value != "")
 {
 document.CreateAccount.txtTelefono.value = document.CreateAccount.txtCodigoPais.value + document.CreateAccount.txtCodigoArea.value + document.CreateAccount.txtNumTelefono.value;
 }
 else { document.CreateAccount.txtTelefono.value = ""; }
}

// Funcion para determinar el tipo de navegador
function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}

var is = new Is();

<!-- ******************************************* SCRIPT MENU ************************************ -->
var empezar = true;
var anclas = new Array ("ancla1","ancla2");
var capa2
var retardo
var ocultar

function muestra(capa2){
menu = document.getElementById(capa2);
menu.style.visibility='visible';
if((document.getElementById("ly_order") != null) && (menu.id=='divcpersonal'))
document.all("ly_order").style.visibility='hidden';
}
function oculta(capa2){
//alert (capa2);
menu = document.getElementById(capa2);
menu.style.visibility='hidden';
if((document.getElementById("ly_order") != null) && (menu.id=='divcpersonal'))
document.getElementById("ly_order").style.visibility='visible';
}

function muestra_coloca2(capa2){
if (empezar){
for (i=0;i<capas2.length;i++){
if (capas2[i] != capa2) oculta(capas2[i])
}
clearTimeout(retardo)
muestra(capa2)
}
}

function muestra_coloca(capa2){
document.getElementById("contenido").style.position=""
if (empezar){
ocultar =capa2
clearTimeout(retardo)
retardo = setTimeout("muestra_coloca2('" + ocultar + "')",100)
}

}

function oculta_retarda(capa2){
document.getElementById("contenido").style.position="relative"
if (empezar){
ocultar =capa2
clearTimeout(retardo)
retardo = setTimeout("oculta('" + ocultar + "')",150)
}

}

function muestra_retarda(ind)
	{
	document.getElementById("contenido").style.position=""	
		if (empezar){
			clearTimeout(retardo)
		}
	}
	
function valida_busqueda(tipo)
{
	
	if (tipo==1){
	var textos=document.getElementById("id_categ");
	var valor = textos.options[textos.selectedIndex].value;
	textos=document.getElementById("id_linea");
	var valore = textos.options[textos.selectedIndex].value;
	textos=document.getElementById("key2");
	var formulario=document.getElementById("busqueda_1");
	if ((valor=="") && (valore=="") && (textos.value==""))
		{
		alert("Debe seleccionar una busqueda valida");
		}
	else
		{
		formulario.submit();
		}
	//return true;
	}
}


<!-- ******************************************* FIN SCRIPT MENU ************************************ -->

