/* 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© 2007 ISKIA - 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 módulo administrativo */
function openImageWindowBig(image)
{
	openWindow(path+'admin/shared/p_verimageng.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 módulo administrativo */
function openImageWindowSmall(image)
{
	openWindow(path+'admin/shared/p_verimagens.asp?image='+image,'image','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=340,height=190');
}

/* 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 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) );
}

/**************/



function MM_changeProp2(objName) { //v6.0
  
  switch (objName)
{ 
	case "acerca": 
			document.getElementById("atencion").style.display = "none";
			document.getElementById("servicio").style.display = "none";
			document.getElementById("asesoria").style.display = "none";
			document.getElementById("micuenta").style.display = "none";
			document.getElementById(objName).style.display = "block";
			break;
	case "atencion": 
			document.getElementById("acerca").style.display = "none";
			document.getElementById("servicio").style.display = "none";
			document.getElementById("asesoria").style.display = "none";
			document.getElementById("micuenta").style.display = "none";
			document.getElementById(objName).style.display = "block";
			break;
	case "servicio": 
			document.getElementById("acerca").style.display = "none";
			document.getElementById("atencion").style.display = "none";
			document.getElementById("asesoria").style.display = "none";
			document.getElementById("micuenta").style.display = "none";
			document.getElementById(objName).style.display = "block";
	case "asesoria": 
			document.getElementById("acerca").style.display = "none";
			document.getElementById("servicio").style.display = "none";
			document.getElementById("atencion").style.display = "none";
			document.getElementById("micuenta").style.display = "none";
			document.getElementById(objName).style.display = "block";
			break;
	case "micuenta": 
			document.getElementById("acerca").style.display = "none";
			document.getElementById("atencion").style.display = "none";
			document.getElementById("servicio").style.display = "none";
			document.getElementById("asesoria").style.display = "none";
			document.getElementById(objName).style.display = "block";
			break;
	
	default:break;
}


}

/************* Funcioneque validan 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));
}
//-->



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 FirtsUppercase(element){
	if (element.length==1){
		element.value=toUpperCase(element)
	}
	
	
}
