/* ----  Funciones elpolvorin.es  ---- */
/* ----       by Packo 2009      ---- */
/* ----      FOCUS EDICIONES      ---- */


/* ---- Forms --- */
function inputFo(idCampo,valor){
	if (document.getElementById(idCampo).value == valor ){
		document.getElementById(idCampo).value ='';
	}
	return true;
}
function inputBl(idCampo,valor){
	if (document.getElementById(idCampo).value == '' ){
		document.getElementById(idCampo).value = valor;
	}
	return true;
}

function votar(valor,idForm){
	var formVotar = document.getElementById(idForm);
	formVotar.votar.value = formVotar.votar.value + valor;
	return formVotar.submit();
}

function votarOver(videoId,valor){
	for (i=1 ;i <= 5 ; i++){ 
		document.getElementById( videoId+'-'+i.toString() ).src='/img/r/star_' + ((i <= valor)? '1':'0') +'.gif';
	}
}

function votarOut(videoId,media){
	var aMedia = media.split('\.');
	for (i=1 ;i <= 5 ; i++){ 
		document.getElementById( videoId+'-'+i.toString()).src='/img/r/star_' + ((i <= aMedia[0])? '1':( ( aMedia[0] == (i -1) && aMedia[1] >= 5)? '05':'0' ) ) +'.gif';
	}
}


/* --- recordatorio --- */
function recordar(){
	var correo=document.getElementById('correo').value;
	var enlace=document.getElementById('reclave');
	if (enlace.href.indexOf('?') != -1){
		enlace.href=enlace.href.substring(0,enlace.href.indexOf('?'));
	}
	if ( (correo != 'tu correo') && (Trim(correo) != '') ){
		enlace.href=enlace.href + '?pc=' + correo;
		rwin(enlace.href,enlace.target,300,150);
		return;
	}else{
		alert ('Debes indicar tu correo');
		//enlace.href=null;
		enlace.href=window.location;
		enlace.target='_self';
		return;
	}	
}


/* --- comentarios --- */
function comentarioCheck(comentario){
	var maxCaracteres=510;
	var escrito = document.getElementById(comentario).value;
	var caracteres = escrito.length + 1;
	if ( caracteres > maxCaracteres ){
		escrito = escrito.substring(0,maxCaracteres);
		document.getElementById('comentario').value = escrito;
		caracteres = escrito.length ;
	}
	document.getElementById('contador').value = maxCaracteres - caracteres;
	return true;
}

function comentarioSubmit(comentario){
	var escrito = document.getElementById(comentario).value;
	var caracteres = escrito.length;
	if ( caracteres <= 3 ){
		alert('¡ Escribe algo !');
		return false;
	}else{
		return true;
	}
}

/* ----- Blogs ------ */

function blogsaccion(numero){
	if (document.getElementById('vbl'+numero).style.display == 'none'){
		document.getElementById('vbl'+numero).style.display='inline';
		document.getElementById('ibl'+numero).innerHTML='-';
	}else{
		document.getElementById('vbl'+numero).style.display='none';
		document.getElementById('ibl'+numero).innerHTML='+';
	}
	return; 
}

/* --- Registro --- */

function blogOptions(url){
	if (document.getElementById('blog_'+url).style.display == 'none'){
		document.getElementById('blog_'+url).style.display='inline';
	}else{
		document.getElementById('blog_'+url).style.display='none';
	}
	return; 
}

/* --- pop up --- */
function rwin (URL,target,width,height) {
	vrwin = window.open (URL, target,'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=no,resizable=no,width='+width+',height='+height);
	vrwin.focus();
}