//
//VARIABLE PARA CONTABILIZAR VIDEOS
//
j=0;
//
function cambiarImagen(pintIdImagen){
	document.getElementById('fotoDestacada').src = arrQtyImagenes[pintIdImagen];
	document.getElementById('imGaleria'+pintIdImagen).className = 'vGaleriaOn';
	document.getElementById('imGaleria'+document.frmGaleria.intIdImagenOn.value).className = 'vGaleriaOff';
	document.frmGaleria.intIdImagenOn.value = pintIdImagen;
	document.getElementById('strTituloFoto').innerHTML = arrTitulo[pintIdImagen];
}
//
function startGallery(){
	if(document.frmGaleria.blnStop.value == "false"){
		intIdFoto = parseInt(document.frmGaleria.intIdImagenOn.value) + parseInt(1);
		if(intIdFoto == 5){
			intIdFoto = 0;
		}
		cambiarImagen(intIdFoto);
	}
}
//
function stopstartGallery(){
	if(document.frmGaleria.blnStop.value == "true"){
		document.frmGaleria.blnStop.value = "false";
	}
	else{
		document.frmGaleria.blnStop.value = "true";
	}
}
//
function pauseNextPreviousGallery(pstrState){
	document.frmGaleria.blnStop.value = "true";
	if(pstrState == "next"){
		intIdFoto = parseInt(document.frmGaleria.intIdImagenOn.value) + parseInt(1);
		if(intIdFoto == 5){
			intIdFoto = 0;
		}
	}
	else{
		intIdFoto = parseInt(document.frmGaleria.intIdImagenOn.value) - parseInt(1);
		if(intIdFoto < 0){
			intIdFoto = 4;
		}
	}
	cambiarImagen(intIdFoto);
}
//
//
function cambiarVideo(pstrId, pstrVideo){
	//
	// Parametro pstrId: ID del video seleccionado
	// Parametro pstrVideo: URL con el video de Youtube
	//
	for(i=0;i<j;i++){
		if(document.getElementById('videoNro'+i).className == 'vVideoOn'){
			document.getElementById('videoNro'+i).className = 'vVideoOff';
			document.getElementById('videoTitulo'+i).className = 'vTituloVideoOff';
			document.getElementById('videoResumen'+i).className = 'vResumenVideoOff';
		}
	}
	//
	document.getElementById('videoNro'+pstrId).className = 'vVideoOn';
	document.getElementById('videoTitulo'+pstrId).className = 'vTituloVideoOn';
	document.getElementById('videoResumen'+pstrId).className = 'vResumenVideoOn';
	//
	var htmlVideo = "";
	htmlVideo+="<object width=\"310\" height=\"250\" id=\"objVideoYT\">";
	htmlVideo+="<param name=\"movie\" value=\"" + pstrVideo + "\"></param>";
	htmlVideo+="<param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param>";
	htmlVideo+="<embed src=\"" + pstrVideo + "\" type=\"application/x-shockwave-flash\" id=\"embVideoYT\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"310\" height=\"250\"></embed></object>";
	//
	document.getElementById('videoObject').innerHTML = htmlVideo;
}
//
function goTo(pstrURL){
	document.location.href = pstrURL;
}
//
function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return (true);
	} else {
		return (false);
	}
}
//
function validarRegistrarse(){
	ok=true;
	obj=document.registro;
	
	if(obj.email.value=='' && ok){alert('Por favor, introduzca su Email.');obj.email.focus();ok=false;}
	if(!validarEmail(obj.email.value) && ok){alert('Por favor, introduzca su Email válido.');obj.email.focus();ok=false;}
	if(obj.confirmaremail.value=='' && ok){alert('Por favor, introduzca la confirmación de su Email.');obj.confirmaremail.focus();ok=false;}
	if(!validarEmail(obj.confirmaremail.value) && ok){alert('Por favor, introduzca su Email válido.');obj.confirmaremail.focus();ok=false;}
	if(obj.email.value!=obj.confirmaremail.value && ok){alert('Su email y confirmación no coinciden.');obj.confirmaremail.focus();ok=false;}
	
	if(obj.contrasena.value=='' && ok){alert('Por favor, introduzca su Contraseña.');obj.contrasena.focus();ok=false;}
	if(obj.contrasena.value.length<=3 && ok){alert('Su contraseña debe tener 4 o más caracteres.');obj.contrasena.focus();ok=false;}
	if(obj.confirmarcontrasena.value=='' && ok){alert('Por favor, introduzca la confirmación de su Contraseña.');obj.confirmarcontrasena.focus();ok=false;}
	if(obj.contrasena.value!=obj.confirmarcontrasena.value && ok){alert('Su contraseña y confirmación no coinciden.');obj.confirmarcontrasena.focus();ok=false;}
	
	if(obj.nombre.value=='' && ok){alert('Por favor, introduzca su Nombre.');obj.nombre.focus();ok=false;}
	//if(obj.apellidos.value=='' && ok){alert('Por favor, introduzca sus Apellidos.');obj.apellidos.focus();ok=false;}
	//if(obj.sexo.value==0 && ok){alert('Por favor, seleccione su Sexo.');obj.sexo.focus();ok=false;}
	//if(obj.telefono.value=='' && ok){alert('Por favor, introduzca su Teléfono.');obj.telefono.focus();ok=false;}
	if(obj.pais.value==0 && ok){alert('Por favor, seleccione un País.');obj.pais.focus();ok=false;}
	if(!obj.acepto.checked && ok){alert('Debe aceptar las condiciones de registro.');obj.acepto.focus();ok=false;}
	//if(obj.provincia.value==0 && ok){alert('Por favor, seleccione una Provincia.');obj.provincia.focus();ok=false;}
	
	if(ok){
		obj.submit();
	}
}
function validarRegistrarse2(){
	ok=true;
	obj=document.registro;
	
	if(obj.email.value=='' && ok){alert('Por favor, introduzca su Email.');obj.email.focus();ok=false;}
	if(!validarEmail(obj.email.value) && ok){alert('Por favor, introduzca su Email válido.');obj.email.focus();ok=false;}
	if(obj.confirmaremail.value=='' && ok){alert('Por favor, introduzca la confirmación de su Email.');obj.confirmaremail.focus();ok=false;}
	if(!validarEmail(obj.confirmaremail.value) && ok){alert('Por favor, introduzca su Email válido.');obj.confirmaremail.focus();ok=false;}
	if(obj.email.value!=obj.confirmaremail.value && ok){alert('Su email y confirmación no coinciden.');obj.confirmaremail.focus();ok=false;}
	
	//if(obj.contrasena.value=='' && ok){alert('Por favor, introduzca su Contraseña.');obj.contrasena.focus();ok=false;}
	if(obj.contrasena.value!='' && obj.contrasena.value.length<=3 && ok){alert('Su contraseña debe tener 4 o más caracteres.');obj.contrasena.focus();ok=false;}
	//if(obj.confirmarcontrasena.value=='' && ok){alert('Por favor, introduzca la confirmación de su Contraseña.');obj.confirmarcontrasena.focus();ok=false;}
	if(obj.contrasena.value!=obj.confirmarcontrasena.value && ok){alert('Su contraseña y confirmación no coinciden.');obj.confirmarcontrasena.focus();ok=false;}
	
	if(obj.nombre.value=='' && ok){alert('Por favor, introduzca su Nombre.');obj.nombre.focus();ok=false;}
	//if(obj.apellidos.value=='' && ok){alert('Por favor, introduzca sus Apellidos.');obj.apellidos.focus();ok=false;}
	//if(obj.sexo.value==0 && ok){alert('Por favor, seleccione su Sexo.');obj.sexo.focus();ok=false;}
	//if(obj.telefono.value=='' && ok){alert('Por favor, introduzca su Teléfono.');obj.telefono.focus();ok=false;}
	if(obj.pais.value==0 && ok){alert('Por favor, seleccione un País.');obj.pais.focus();ok=false;}
	//if(obj.provincia.value==0 && ok){alert('Por favor, seleccione una Provincia.');obj.provincia.focus();ok=false;}
	
	if(ok){
		obj.submit();
	}
}
function rollOverDebate(id){
	ok=true;
	
	if(document.getElementById('debateFoto'+id).className.indexOf('Off') && document.getElementById('debateTitulo'+id).className.indexOf('Off')>=1 && ok){
		document.getElementById('debateFoto'+id).className=document.getElementById('debateFoto'+id).className.replace('Off','On');
		document.getElementById('debateTitulo'+id).className=document.getElementById('debateTitulo'+id).className.replace('Off','On');
		ok=false;
	}
	
	if(document.getElementById('debateFoto'+id).className.indexOf('On') && document.getElementById('debateTitulo'+id).className.indexOf('On')>=1 && ok){
		document.getElementById('debateFoto'+id).className=document.getElementById('debateFoto'+id).className.replace('On','Off');
		document.getElementById('debateTitulo'+id).className=document.getElementById('debateTitulo'+id).className.replace('On','Off');
		ok=false;
	}
}
function linkSolapa(idsolapa,idgruposolapas,idsolapacontenedor,idsolapacontenedoron){
	RollSolapa(idgruposolapas,true);
	RollSolapa(idsolapa,false);
	RollSolapaContenedor(idsolapacontenedor)
	document.getElementById(idsolapacontenedoron).style.display='block';
}

function RollSolapa(id,estado){
	var par=document.getElementById(id);
	var clds=par.childNodes;
	for (var z0=0;z0<clds.length;z0++){
		if (clds[z0].nodeName=='DIV'){
			if(clds[z0].id!=''){
				RollSolapa(clds[z0].id,estado);
			}else{
				if(estado){
					clds[z0].className=clds[z0].className.replace('_On','_Off');
				}else{
					clds[z0].className=clds[z0].className.replace('_Off','_On');
				}
			}
		}
	}
}

function RollSolapaContenedor(id){
	var par=document.getElementById(id);
	var clds=par.childNodes;
	for (var z0=0;z0<clds.length;z0++){
		if (clds[z0].nodeName=='DIV'){
			clds[z0].style.display='none';
		}
	}
}

function activarSolapasMiembros(pstrIdActiva, pstrIdActivar, pstrIdContenidoActivo, pstrIdContenidoActivar, pstrIdUltimaSolapa, pstrIdUltimoDiv){
	//alert(pstrIdActiva + "\n" + pstrIdActivar + "\n" + pstrIdContenidoActivo + "\n" + pstrIdContenidoActivar + "\n" + pstrIdUltimaSolapa + "\n" + pstrIdUltimoDiv);
	document.getElementById(pstrIdActiva).className = "iSolapaMSOff";
	document.getElementById(pstrIdActivar).className = "iSolapaMSOn";
	document.getElementById(pstrIdContenidoActivo).style.display = "none";
	document.getElementById(pstrIdContenidoActivar).style.display = "block";
	if(pstrIdUltimaSolapa != null){
		document.getElementById(pstrIdUltimaSolapa).className = "iSolapaMSOff";
		document.getElementById(pstrIdUltimoDiv).style.display = "none";
	}
	if (pstrIdContenidoActivar == 'idMasSeguidosContenido'){
		document.getElementById('pstMiembrosLink').href = "/intranet/verseguidos";
	}
	if (pstrIdContenidoActivar == 'idUltimosContenido'){
		document.getElementById('pstMiembrosLink').href = "/intranet/miembros";
	}
	if (pstrIdContenidoActivar == 'idContenidoDebates'){
		document.getElementById('pstTodosLink').href = "/intranet/debates";
	}
	if (pstrIdContenidoActivar == 'idContenidoPizarra'){
		document.getElementById('pstTodosLink').href = "/intranet/pizarra";
	}
	if (pstrIdContenidoActivar == 'idContenidoBlogs'){
		document.getElementById('pstTodosLink').href = "/intranet/blogs";
	}
}


function ancla(pstrId){
	var yPos = document.getElementById(pstrId).offsetTop;
	if(document.all){
		yPos = parseInt(yPos) + parseInt(300);
	}
	window.scrollTo(0,yPos);
}

