// JavaScript Document

function showCambiarSegmento(show){
	if (show){
		document.getElementById('veloDisplay').style.display = "block";
		document.getElementById('veloHidden').style.display = "none";		
		document.getElementsByName('fbfanIFrame_0')[0].style.visibility = "hidden";
	} else {
		document.getElementById('veloDisplay').style.display = "none";
		document.getElementById('veloHidden').style.display = "block";
		document.getElementsByName('fbfanIFrame_0')[0].style.visibility = "visible";		
	}
}

function displayForm(show){
	if (show){
		document.getElementById("spanVideo").style.display = "none";
		document.getElementById("spanForm").style.display = "block";
		document.getElementById("spanResponse").style.display = "none";
	} else {
		document.getElementById("spanVideo").style.display = "block";
		document.getElementById("spanForm").style.display = "none";	
		document.getElementById("spanResponse").style.display = "none";
	}
}

function displayGaleria(show, id){
	document.getElementById("fot1").style.display = "none";
	document.getElementById("fot2").style.display = "none";
	document.getElementById("fot3").style.display = "none";
	document.getElementById("gal").style.display = "none";
	if (show){
		document.getElementById("fot"+id).style.display = "block";		
	} else {
		document.getElementById("gal").style.display = "block";
	}
}

function textCounter(field,cntfield) {	
	var maxlimit = 200;
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else
		cntfield.value = maxlimit - field.value.length;
		
	document.getElementById("opinacarNumber").innerHTML = cntfield.value;
}
//----- ABRIR POPUP -----
function popup(url,nb_vent,atributos,w,h)
{
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	atributos=atributos+',top='+Math.round(TopPosition)+',left='+Math.round(LeftPosition);
	window.open(url,nb_vent,atributos);
	
}

function onlyNumbers(obj){
	reg = /[^0-9]/g;
	obj.value =  obj.value.replace(reg,"");
 }
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;   
    }else{   
		return false; 
    }
}

function escucharAudio(p){
	window.open("common/roncast_detalle.php?p="+p,"PodCast","width=350,height=110,screenx=200,screeny=200,location=0,scrollbars=0");
}

function anyCheck(f,mens,mens2)
{
	if(f.length){
		for (i = 0; i < f.length; i++){			
			if(f[i].checked==true)
				return true;
		}		
	}
	else{
		if (f.checked) 
			return true;		
	}
	alert("Debes seleccionar "+mens+" que desea "+mens2);
	return false;
}

function confirmar_eliminar(texto){
	return(confirm(texto));
}