function abrir_ventana(name){
	
	ventana = window.open(name, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
}

// 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();

// Funcion que invoca el metodo submit adecuado de una forma
// La forma de la llamada es: <A href="" onclick="changeActionAndSubmit('carritoProductos', '../compra/xt_orderform_clearitems.asp'); return false">
function changeActionAndSubmit(form, newAction) {
	document.forms[form].action = newAction;
	document.forms[form].submit();
}

function submitForm(form) {
	document.forms[form].submit();
}

// Funcion que modifica el action de una forma
function changeAction(form, newAction) {
	document.forms[form].action = newAction;
}

// Funcion que modifica los valores de los input de una forma
function changeValue(form, layerName, inputName, newValue) {
	if(is.ns4) {
		if (layerName == "") {
			for (i=0; i < inputName.length; i++) {   
				eval("document['"+form+"']."+inputName[i]+".value = '"+newValue[i]+"'");
			}
			document[form].submit();
		}
		else {
			document[layerName].document[form].tienda.value = "hyper";
			for (i=0; i < inputName.length; i++) {   
				eval("document['"+layerName+"'].document['"+form+"']."+inputName[i]+".value = '"+newValue[i]+"'");
			}
			document[layerName].document[form].submit();
		}
	} else if(is.ie4) {
		for (i=0; i < inputName.length; i++) {   
			eval("document.forms['"+form+"']."+inputName[i]+".value = '"+newValue[i]+"'");
		}
		document.forms[form].submit();
	}
}

function isSelected(anchorName, imgName) {
	var newImg = eval(imgName + "_f2");
	document.anchors[anchorName].href = "";
	document.anchors[anchorName].onclick = "return false";
	document.anchors[anchorName].onmouseover = "return false";
	document.anchors[anchorName].onmouseout = "return false"
	document.images[imgName].src = newImg;
}

function validar_concurso()
{
		if ((document.concurso.nombre_completo.value == '') || (document.concurso.cedula.value == '') || (document.concurso.edad.value == '') || (document.concurso.lugar.value == '') || (document.concurso.dianacimiento.value == '') || (document.concurso.mesnacimiento.value == '') || (document.concurso.anonacimiento.value == '') || (document.concurso.tlf.value == '') || (document.concurso.direc_hab.value == '') || (document.concurso.email2.value == '') || (document.concurso.oficio.value == ''))
		{
			var mensaje = 'Debe completar los siguientes campos:\n ';
			var mensaje2 = '';
			var RegExPattern = /^[0-9]+$/;
			var RegExPattern2 = /^[A-Za-z]+$/;
			var RegExPattern3 = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			
				if (document.concurso.nombre_completo.value == '')
				{
					mensaje = mensaje + '\n- Nombre completo';
				}
			
				if (document.concurso.cedula.value == '')
				{
					mensaje = mensaje + '\n- Cedula';
				}
				else
				{
					if (!document.concurso.cedula.value.match(RegExPattern))
					{
						mensaje2 = mensaje2 + '\n- El campo Cedula debe ser numeros';
					}
				}
				
				if (document.concurso.edad.value == '')
				{
					mensaje = mensaje + '\n- Edad';
				}
				else
				{
					if (!document.concurso.edad.value.match(RegExPattern))
					{
						mensaje2 = mensaje2 + '\n- El campo Edad debe ser numeros';
					}
				}
				
				if (document.concurso.lugar.value == '')
				{
					mensaje = mensaje + '\n- Lugar';
				}
				else
				{
					if (!document.concurso.lugar.value.match(RegExPattern2))
					{
						mensaje2 = mensaje2 + '\n- El Campo Lugar debe ser letras';
					}
				}
			
				if ((document.concurso.dianacimiento.value == '') || (document.concurso.mesnacimiento.value == '') || (document.concurso.anonacimiento.value == ''))
				{
					mensaje = mensaje + '\n- Fecha Nacimiento';
				}
				else if (!document.concurso.anonacimiento.value.match(RegExPattern))
				{
					mensaje2 = mensaje2 + '\n- El campo Fecha Nacimiento debe ser numeros';
				}
				else
				{
					if (parseFloat(document.concurso.anonacimiento.value)<1900)
					{
						mensaje2 = mensaje2 + '\n- El campo Fecha Nacimiento';
					}
					else
					{
						if ((document.concurso.mesnacimiento.value == 4) || (document.concurso.mesnacimiento.value == 6) || (document.concurso.mesnacimiento.value == 9) || (document.concurso.mesnacimiento.value == 11) || (document.concurso.mesnacimiento.value == 2))
						{
							if (document.concurso.mesnacimiento.value == 2 && document.concurso.dianacimiento.value > 28 || document.concurso.dianacimiento.value > 30)
							{
								mensaje2 = mensaje2 + '\n- El campo Fecha Nacimiento';
							}
						}
					}
				}
				
				if (document.concurso.tlf.value == '')
				{
					mensaje = mensaje + '\n- Telefono';
				}
				else
				{
					if (!document.concurso.tlf.value.match(RegExPattern))
					{
						mensaje2 = mensaje2 + '\n- El campo Telefono debe ser numeros';
					}
				}
				
				if (document.concurso.direc_hab.value == '')
				{
					mensaje = mensaje + '\n- Direccion Habitacion';
				}
				
				if (document.concurso.email2.value == '')
				{
					mensaje = mensaje + '\n- E-mail';
				}
				else
				{
					if (!document.concurso.email2.value.match(RegExPattern3))
					{
						mensaje2 = mensaje2 + '\n- El campo E-mail';
					}
				}
				
				if (document.concurso.oficio.value == '')
				{
					mensaje = mensaje + '\n- Oficio';
				}
				
				if (mensaje2 != '')
				{
					mensaje = mensaje + '\n\nLos siguientes campos son incorrectos: \n';
					mensaje = mensaje + mensaje2;
				}
			
			alert(mensaje);
			return false;
		}
	
	document.concurso.submit();	
}

function mostrar_ocultar_capas(presionado)
{
	for (i=1; i<=4; i++)
	{
		nombre_capa = "capa_" + i;
			
			//La capa que esta activa
			if (document.getElementById(nombre_capa).style.display == 'block')
			{
				capa_activa = i;
				document.getElementById(nombre_capa).style.display == 'none'; //Se oculta
				
					//Se presiono anterior
					if (presionado == 1)
					{
						document.getElementById("capa_link_2").style.display = "block"; //Siguiente
						
							if ((i - 1) == 1)
							{
								document.getElementById("capa_link_1").style.display = "none"; //Anterior
							}
							else
							{
								document.getElementById("capa_link_1").style.display = "block"; //Anterior
							}
					}
					//Se presiono siguiente
					else
					{
						document.getElementById("capa_link_1").style.display = "block"; //Anterior
						
							if ((i + 1) == 4)
							{
								document.getElementById("capa_link_2").style.display = "none"; //Siguiente
							}
							else
							{
								document.getElementById("capa_link_2").style.display = "block"; //Siguiente
							}
					}
			}
	}
	
	for (i=1; i<=4; i++)
	{
		//Presiono anterior
		if (presionado == 1)
		{
			if (capa_activa - 1 != i)
			{
				nombre_capa = "capa_" + i;
				document.getElementById(nombre_capa).style.display = "none";
			}
			else
			{
				nombre_capa = ("capa_" + (capa_activa - 1));
				document.getElementById(nombre_capa).style.display = "block";
			}
		}
		else
		{
			if (capa_activa + 1 != i)
			{
				nombre_capa = "capa_" + i;
				document.getElementById(nombre_capa).style.display = "none";
			}
			else
			{
				nombre_capa = ("capa_" + (capa_activa + 1));
				document.getElementById(nombre_capa).style.display = "block";
			}
		}
	}
}