// JavaScript Document
function mostrarSolapa(sTipo, iTipo, iNum, oAEle, sNameDivEle){
	//si no exite nuestro contenedor de objetos solapas activas, lo creamos
	if(!document['__aSolActs']) document['__aSolActs'] = new Object;
	
	//si no exite el objeto solapa activa en nuetros arreglo, lo creamos
	o = document['__aSolActs']['oSolAct'+sTipo+iTipo];
	if(!o){
		o = new Object;
		o['sNameDivEle'] = 'contSolapa';
		o['oAEle'] = false;
	}
	
	//si completaron sNameDivEle
	if(!!sNameDivEle){ 
		o['sNameDivEle'] = sNameDivEle;
	}
	
	//restablecemos el anterior
	if(!!o['oAEle']){
		o['oAEle'].className = "solapaOff";
		o['oDivEle'].style.display = 'none';
	}
	
	//establecemos en nuevo
	o['oAEle'] = oAEle;
	o['oAEle'].className = 'solapaOn';//ESTE 
	o['oDivEle'] = document.getElementById(o['sNameDivEle']+iNum);
	o['oDivEle'].style.display = 'block';
	
	//cancelamos el evento
	if(Nav.esIE && event){
		event.cancelBubble = true;
		event.returnValue = false;
	}
	
	//reasignamos el objeto
	document['__aSolActs']['oSolAct'+sTipo+iTipo] = o;
	
	//controlamos el alto del lateran
	if(controlarAltoLateral) controlarAltoLateral();
}

function mostrarDia(iTipo, iNum, oAEle, sNameDivEle){
	//si no exite nuestro contenedor de objetos dias activos, lo creamos
	if(!document['__aDiaActs']) document['__aDiaActs'] = new Array;
	
	//si no exite el objeto dia activa en nuetros arreglo, lo creamos
	o = document['__aDiaActs']['oDiaAct'+iTipo];
	if(!o){
		o = new Object;
		o['sNameDivEle'] = 'dia';
	}
	
	//si completaron sNameDivEle
	if(!!sNameDivEle){
		o['sNameDivEle'] = sNameDivEle;
	}
	
	//restablecemos el anterior
	if(!!o.oAEle){
		o['oAEle'].className = "circuitoDiaOff";
		o['oDivEle'].style.display = 'none';
	}
	
	//establecemos en nuevo
	o['oAEle'] = oAEle;
	o['oAEle'].className = 'circuitoDiaOn';
	o['oDivEle'] = document.getElementById(o['sNameDivEle']+iNum);
	o['oDivEle'].style.display = 'block';
	
	//cancelamos el evento
	if(Nav.esIE && event){
		event.cancelBubble = true;
		event.returnValue = false;
	}
	
	//reasignamos el objeto
	document['__aDiaActs']['oDiaAct'+iTipo] = o;
	
	//controlamos el alto del lateran
	if(controlarAltoLateral) controlarAltoLateral();
}
/*		
var agrandarLetra = function(contenedores,tamanioInicial,intervalo,limiteInferior,limiteSuperior,agrandar,achicar){
	var oClase = this;
	this.arreglo = new Array();
	this.contenedores = contenedores.split(",");
	this.tamanioInicial = tamanioInicial;
	this.tamanio = tamanioInicial;
	this.limiteInferior = limiteInferior;
	this.limiteSuperior = limiteSuperior;
	if(agrandar != ""){
		var agrandar = document.getElementById(agrandar);
		if(agrandar)agrandar.onclick = function(){oClase.modTam(1);}
	}
	if(achicar != ""){
		var achicar = document.getElementById(achicar);
		if(achicar)achicar.onclick = function(){oClase.modTam(-1);}
	}

	this.modTam = function(direccion){
		if((this.tamanio + (direccion)*intervalo)>this.limiteInferior && (this.tamanio + (direccion)*intervalo)<this.limiteSuperior)this.tamanio = (this.tamanio+(direccion)*intervalo)
		else{
			if((this.tamanio + (direccion)*intervalo)<this.limiteSuperior)this.tamanio = this.limiteInferior;
			else this.tamanio = this.limiteSuperior;
		}
		for(i=0;i<this.contenedores.length;i++){
			if(!this.arreglo[this.contenedores[i]])	this.arreglo[this.contenedores[i]] = document.getElementById(this.contenedores[i]);
			this.arreglo[this.contenedores[i]].style.fontSize = this.tamanio+"px";
		}
		controlarAltoLateral();
	}
}
*/
var MES = 2592000000;
var Cookie = function(){
	var oClase = this;
	this.cookie = document.cookie;
	this.arrCookie = new Array();	
	this.arreglo = function(){
		var valores = document.cookie
		valores = valores.split(";");	
		var array = new Array();	
		for(n=0;n<valores.length;n++){
			var terminos = valores[n].split("=");
			if(terminos[0].substr(0,1)==' ')var nombre = terminos[0].substr(1,(terminos[0].length));
			else var nombre = terminos[0];
			this.arrCookie[nombre]=terminos[1];
		//alert(this.arrCookie[nombre]);
		}
	}
	this.campo = function(campo){
		if(this.arrCookie[campo]) return this.arrCookie[campo];
		else return 300;
	}
	this.escribirCookie = function(inscripcion){
		var conv = Date();
		var miliseg = Date.parse(conv);
		miliseg2 = miliseg + MES;
		var resultado = new Date(miliseg2);
		document.cookie = inscripcion+";expires="+resultado.toGMTString();	
	}
	this.arreglo();
}
var agrandarLetra = function(contenedores,tamanioInicial,intervalo,limiteInferior,limiteSuperior,agrandar,achicar){
	var oClase = this;
	this.arreglo = new Array();
	var oCook = new Cookie();
	this.contenedores = contenedores.split(",");
	if(oCook.arrCookie['tamLetra'] && oCook.arrCookie['tamLetra'] != "")this.tamanioInicial = oCook.arrCookie['tamLetra'];
	else this.tamanioInicial = tamanioInicial;
	this.tamanio = parseInt(this.tamanioInicial);
	this.limiteInferior = limiteInferior;
	this.limiteSuperior = limiteSuperior;
	if(agrandar != ""){
		var agrandar = document.getElementById(agrandar);
		if(agrandar)agrandar.onclick = function(){oClase.modTam(1);}
	}
	if(achicar != ""){
		var achicar = document.getElementById(achicar);
		if(achicar)achicar.onclick = function(){oClase.modTam(-1);}
	}
	this.modTam = function(direccion){
		if((this.tamanio + (direccion)*intervalo)>this.limiteInferior && (this.tamanio + (direccion)*intervalo)<this.limiteSuperior)this.tamanio = (this.tamanio+(direccion)*intervalo)
		else{
			if((this.tamanio + (direccion)*intervalo)<this.limiteSuperior)this.tamanio = this.limiteInferior;
			else this.tamanio = this.limiteSuperior;
		}
		for(i=0;i<this.contenedores.length;i++){
			if(!this.arreglo[this.contenedores[i]])	this.arreglo[this.contenedores[i]] = document.getElementById(this.contenedores[i]);
			this.arreglo[this.contenedores[i]].style.fontSize = this.tamanio+"px";
		}
		oCook.escribirCookie("tamLetra="+this.tamanio);	

	}
	for(i=0;i<this.contenedores.length;i++){
		if(!this.arreglo[this.contenedores[i]])	this.arreglo[this.contenedores[i]] = document.getElementById(this.contenedores[i]);
		this.arreglo[this.contenedores[i]].style.fontSize = this.tamanio+"px";
	}
	
}

var bajarAdjunto = function(objetoContenedor,objetoClick,cantidad){
	var ob = document.getElementById(objetoClick);
	var objCont = objetoContenedor;
	if(ob){
		if(parseInt(cantidad)>0)ob.onclick = function(){popupAbrir(objCont)}
		else ob.style.display = "none";
	}

}
var enviarMail = function(nombreEnvio,emailEnvio,mensaje,emailDestino,error,archivoRequest,objetoCerrar){
	var oClase = this;
	var ER_EMAIL = /^[a-z0-9_\.\-]+@[a-z0-9_\-]+(\.[a-z0-9_\-]{2,20})*\.[a-z]{2,4}$/;
	this.req = new Request(oClase);
	this.nombre = document.getElementById(nombreEnvio);
	this.email = document.getElementById(emailEnvio);
	this.mensaje = document.getElementById(mensaje);
	this.error = document.getElementById(error);
	this.destino = document.getElementById(emailDestino);
	var blockeo = document.getElementById("blockeadorEnvio");
	var msjEnviando = document.getElementById("mensajeEnviando");
	var archivoReq = archivoRequest;
	var oCerrar = objetoCerrar;
	this.enviar = function(){
		var err = "";
		var v = "";
		if(this.nombre.value == ""){
			err += "<div>Ingrese el nombre</div>";
			this.nombre.style.border = "1px solid #FF0000";
		}
		else{
			this.nombre.style.border = "";
			v += "nombre|=|"+this.nombre.value;
		}
		if(!ER_EMAIL.test(this.email.value.toLowerCase())){
			err += "<div>Email incorrecto</div>";
			this.email.style.border = "1px solid #FF0000";
		}
		else{
			this.email.style.border = "";
			v += "|&|email|=|"+this.email.value;
		}
		if(!ER_EMAIL.test(this.destino.value.toLowerCase())){
			err += "<div>Email de destino incorrecto</div>";
			this.destino.style.border = "1px solid #FF0000";
		}
		else{
			this.destino.border = "";
			v += "|&|destino|=|"+this.destino.value;
		}
		if(this.mensaje.value == ""){
			err += "<div>Debe ingresar el mensaje</div>";
			this.mensaje.style.border = "1px solid #FF0000";
		}
		else{
			this.mensaje.border = "";
			v += "|&|mensaje|=|"+this.mensaje.value;
		}
		if(err == ""){
			if(blockeo)blockeo.style.display = "block";
			if(msjEnviando)msjEnviando.style.display = "block";
			this.req.pedir(archivoReq,v);
		}
		else{
			this.error.className = "mensajeError";
			this.error.innerHTML = err;	
			this.error.style.display = "block";
		}
		
	}
	this.limpiar = function(){
		this.nombre.value = "";	
		this.nombre.style.border = "";
		this.email.value = "";
		this.email.style.border = "";
		this.mensaje.value = "";
		this.mensaje.style.border = "";
		this.error.value = "";
		this.error.style.border = "";		
		this.destino.value = "";
		this.destino.style.border = "";		
	}
	this.cerrar = function(){
		this.error.style.display = "none";
		this.limpiar();
		popupCerrar(oCerrar);
	}
	this.onRequestLoad = function(){
		if(this.req.respuestaHTML == "enviado"){
			this.error.className = "mensajeExito";	
			this.error.innerHTML = "El mensaje ha sido enviado.";
			this.limpiar();
			setTimeout(function(){oClase.error.style.display = "none"},5000);
		}
		else{
			this.error.className = "mensajeError";	
			this.error.innerHTML = "El mensaje no ha podido ser enviado.";
		}
		this.error.style.display = "block";
		if(blockeo)blockeo.style.display = "none";
		if(msjEnviando)msjEnviando.style.display = "none";
	}
	if(Nav.esIE || Nav.esIE7) blockeo.style.filter = 'alpha(opacity=45)';
	else blockeo.style.MozOpacity = ".45";
}
var visualizarSolapas = function(valor){
	if(document['__aSolActs']){
		for(i in document['__aSolActs']){
			if(document['__aSolActs'][i].oDivEle)document['__aSolActs'][i].oDivEle.style.visibility = valor;
		}
	}
}

var eventoBanner = function(){
	var oClase = this;
	var archivo = "xmlHttpRequest/clickBanner.php";
	this.req = new Request(oClase);	
	this.hacerClick = function(idBanner,linkBanner,noOpen){
		this.req.pedir(archivo,"idBanner|=|"+idBanner+"|&|");
		if(!noOpen)window.open(linkBanner,'link','height=400,width=800px,scrollbars=yes');
	}
	this.onRequestLoad = function(){
		//alert(this.req.respuestaHTML);	
	}
}
var clickBanner = new eventoBanner();

