function desplieguePremio(pIdTrabajo, pIdCategoria)
{
	var contenido = document.getElementById('desplieguePremio');
	x_DesplegarPremio(pIdTrabajo, pIdCategoria,
	function(pCadena)
	{
			contenido.innerHTML = pCadena;
	});
}


function cargaImagenInfo(pIdNoticia, pSufijoImg)
{
	var cont = document.getElementById('imgGrande');
	cont.innerHTML = "<img src='informacion/I1_" + pIdNoticia + "-" + pSufijoImg + ".jpg' />";
	
	var epig = document.getElementById('epigrafe');
	x_RetornarEpigrafeInfo(pIdNoticia, pSufijoImg,
	function(pCadena)
	{
			epig.innerHTML = pCadena;
	});
}

function cargaImagen(pIdNoticia, pSufijoImg)
{
	var cont = document.getElementById('imgGrande');
	cont.innerHTML = "<img src='noticias/N1_" + pIdNoticia + "-" + pSufijoImg + ".jpg' />";
	
	var epig = document.getElementById('epigrafe');
	x_RetornarEpigrafe(pIdNoticia, pSufijoImg,
	function(pCadena)
	{
			epig.innerHTML = pCadena;
	});
}

function cargaImagenRegional(pIdNoticia, pSufijoImg)
{
	var cont = document.getElementById('imgGrande');
	cont.innerHTML = "<img src='regionales/noticias/N1_" + pIdNoticia + "-" + pSufijoImg + ".jpg' class='imagen-borde' />";
	
//	var epig = document.getElementById('epigrafe');
//	x_RetornarEpigrafe(pIdNoticia, pSufijoImg,
//	function(pCadena)
//	{
//			epig.innerHTML = pCadena;
//	});
}

function desplegarContenido(pImagen)
{
	var contenedor = document.getElementById('arqContenidos');
	contenedor.innerHTML = "<img src='" + pImagen + "' />";
	location.href = "#despliegue";
}

function cargarImagen(pIDNoticia, pArchivo)
{
	var oVisor = document.getElementById("imgVisor-" + pIDNoticia);
	if(oVisor) oVisor.src = pArchivo;
}

function abrirImagen(pIDNoticia, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "Colegio de Arquitectos de la Provincia de Cordoba",
			width: pAncho,
			height: pAlto,
			left: 200,
			top: 250,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?idregistro=" + pIDNoticia + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}

function recuperarClave(pForm)
{
	with(pForm)
	{
		if(usuario.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				x_RecuperarClave(usuario.value, email.value, function(pCadena)
				{
					if(pCadena == "S")
						alert("Su clave ha sido enviada a su email.");
					else
						alert("Usuario o email incorrecto.");
				});
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su nombre.");
			usuario.focus();
		}
	}
	return false;
}

function desplegarCapa(idCapa)
{
	var tFormVisible = document.getElementById(idCapa);
	
	if (tFormVisible.className == "oculto")
	tFormVisible.className = "visible";
	else
	tFormVisible.className = "oculto";
}

function cerrarSesion()
{
	x_CerrarSesion();
	location.href = "home.php";
}

function validarLoginUsuario(pForm)
{
	with(pForm)
		if (txtUsuario.value.length > 0 && txtClave.value.length > 0) {
		x_ValidarLoginUsuario(txtUsuario.value, txtClave.value, function(pCadena)
		{
			if(pCadena == "S")
				location.href = "usuarios.php";
			else
				alert("Usuario o Clave incorrecto");
		});
		} else {
			alert("Ingrese su nombre de usuario y clave");
			txtUsuario.focus();
			return false;
		}
	return false;
}

function enviarContacto(pForm)
{
	with(pForm)
	{
		if(apellido.value.length > 0 && nombres.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				if(mensaje.value.length > 0)
				{
					x_EnviarContacto(apellido.value, 
									 nombres.value,
									 email.value, 
									 telefono.value, 
									 localidad.value, 
									 provincia.value, 
									 mensaje.value, 
									 destinatario.value, 
									 function(pCadena)
						{
							alert("Su mensaje ha sido enviado");
							pForm.reset();
						});
				}
				else
				{
					alert("Por favor, ingrese un Mensaje");
					mensaje.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese un Email valido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Apellido y Nombre/s");
			apellido.focus();
		}
	}
	return false;
}

function RegistroUsuario(pForm)
{
	with(pForm)
	{
		if(apellido.value.length > 0 && nombres.value.length > 0 && usuario.value.length > 0 && clave.value.length > 0 && localidad.value.length > 0 && provincia.value.length > 0)
		{
			if(validarEmail(email.value))
			{
					x_GuardarUsuarioRegistrado(
											   apellido.value, nombres.value, usuario.value, email.value, clave.value, localidad.value, provincia.value, function(pCadena)
						{
							pForm.reset();
							alert("Sus datos han sido enviados al administrador. Recibira un Email cuando estos sean verificados. Muchas gracias por registrarse.");
						});
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese todos los campos obligatorios.");
			apellido.focus();
		}
	}
	return false;
}

function retornarFecha(pDestino)
{
	var aDias = new Array("Domingo", "Lunes", "Martes",
		"Mi&eacute;rcoles",  "Jueves", "Viernes", "S&aacute;bado");
	var aMeses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
	
	var dFecha = new Date();
	with(dFecha)
	{
		var lIDDia = getDay();
		var sDia = new String(getDate());
		var sMes = getMonth();
		var lAno = getYear();
		var sHora = new String(getHours());
		var sMinutos = new String(getMinutes());
	}
	if(sDia.length == 1) sDia = "0" + sDia;
	if(sMes.length == 1) sMes = "0" + sMes;
	if(lAno < 1900) lAno += 1900;
	if(sHora.length == 1) sHora = "0" + sHora;
	if(sMinutos.length == 1) sMinutos = "0" + sMinutos;
	pDestino = document.getElementById(pDestino);
	if(pDestino)
	{
		pDestino.innerHTML = aDias[lIDDia] + ", " + sDia + " de " + aMeses[sMes] + " - <span class='texto-color'>" + sHora + ":" + sMinutos + "</span> ";
	}
}

function GuardarSuscriptor(pForm)
{
	with(pForm)
	{
		if(nombres.value.length > 0)
		{
			if(validarEmail(email.value))
			{
					x_GuardarSuscriptor(nombres.value, email.value, function(pCadena)
						{
							alert("Gracias por suscribirse a nuestro newsletter.\n");
							pForm.reset();

						});
			}

			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Nombre");
			nombres.focus();
		}
	}
	return false;
}

function cargarResultadoDeEncuesta(pIDEncuesta, pDestino)
{
	var oDestino = document.getElementById(pDestino);
	if(oDestino)
	{
		var oFlash = new SWFObject("encuesta.swf", "", "180", "180", "7", "", true);
		with(oFlash)
		{
			addVariable("_URL", "xml.encuesta.php?IDEncuesta=" + pIDEncuesta);
			addParam("wmode", "transparent");
			write(pDestino);
		}
	}
}

function validarEmail(pEmail)
{
	var oRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	return oRegExp.test(pEmail);
}

function guardarVotacion(pForm, pIDEncuesta)
{
	var bOpcion = false;
	with(pForm)
	{
		for(var lJ = 0; lJ < rdOpcion.length; lJ++)
		{
			if(rdOpcion[lJ].checked == true)
			{
				var lIDOpcion = rdOpcion[lJ].value;
				bOpcion = true;
				break;
			}
		}
		if(!bOpcion)
		{
			alert("Por favor, seleccione una opción");
			rdOpcion[0].focus();
		}
		else
		{
			if(validarEmail(txtEmail.value))
			{
				x_GuardarVotacion(pIDEncuesta, lIDOpcion, txtEmail.value, function(pCadena)
					{
						var tEncuesta = document.getElementById("tdEncuesta-" + pIDEncuesta);
						if(tEncuesta) tEncuesta.innerHTML = pCadena;
						cargarResultadoDeEncuesta(pIDEncuesta, "divResultados-" + pIDEncuesta);
					});
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				txtEmail.focus();
			}
		}
	}
	return false;
}

function visualizarSeccion(pSeccion, pVisible)
{
	var oSeccion = document.getElementById(pSeccion);
	if(oSeccion)
	{
		with(oSeccion)
		{
			if(pVisible && oSeccion.className == "oculto")
				className = "visible";
			else if(!pVisible && (className == "" || className == "visible"))
				className = "oculto";
		}
	}
}

/***SUBMENU ******************************************/
function mostrarSubmenu(capa){
  var obj = document.getElementById(capa)
  if(obj.style.visibility== "hidden")  obj.style.visibility= "visible";
}
function ocultarSubmenu(capa){
  var obj = document.getElementById(capa)
  if(obj.style.visibility== "visible")  obj.style.visibility= "hidden";
}

function cargarVideo(idVid)
{
	var oFlashV;
	if(document.getElementById("video_featured") && document.getElementById("video_featured_titulo") && document.getElementById("video_featured_description"))
	{
		oFlashV = new SWFObject("scripts/flayr/flayr.swf", "1", "374", "280", "8");
		with(oFlashV)
		{
					addVariable("movie","http://colegio-arquitectos.com.ar/videos/V_"+idVid+".flv");
					addVariable("preview","http://colegio-arquitectos.com.ar/videos/I_"+idVid+".jpg");
					addParam("wmode", "transparent");
					addParam("menu", "false");
					addParam("allowfullscreen", "true");
			write("video_featured");
		}
		
		x_CargarVideo(idVid, function(pCadena){
			var texto = pCadena;
			texto = texto.split(":|:");
			var titulo = document.getElementById("video_featured_titulo");
			titulo.innerHTML = "<a href='despliegue-video.php?idvideo="+idVid+"'>"+texto[0]+"</a>";
			var desc = document.getElementById("video_featured_description");
			desc.innerHTML = texto[1];		
		});				

	}
	return false;
}