function search_check () {
	f = document.forms['search'];
	if (f.type[f.type.selectedIndex].value == 'foro') {
		document.forms['foro'].query.value = f.keywords.value;
		document.forms['foro'].submit();
	}
	else if (f.type[f.type.selectedIndex].value == 'blog') {
		document.forms['blog'].s.value = f.keywords.value;
		document.forms['blog'].submit();
	}
	else if (f.type[f.type.selectedIndex].value == 'user') {
		if (f.keywords.value.length < 2) alert("You must enter a word of at least two characters");
		else if (f.keywords.value == 'Enter your search') alert("You must enter a word of at least two characters");
		else {
			f.action = "/buscador-usuarios";
			f.submit();
		}
	}
	else {
		if (f.keywords.value.length < 2) alert("You must enter a word of at least two characters");
		else if (f.keywords.value == 'Enter your search') alert("You must enter a word of at least two characters");
		else f.submit();
	}
}

function search_check2 () {
	f = document.forms['search'];
	if (f.keywords.value.length < 2) alert("You must enter a word of at least two characters");
	else if (f.keywords.value == 'Enter your search') alert("You must enter a word of at least two characters");
	else f.submit();
}

function goRegister() {
	window.location="/register";
} 

function openPopup(_lnk,_height,_width) {
	window.open(_lnk,'Popup','scrollbars=no,toolbar=no,menubar=no,status=no,location=no,top=0,left=0,resizable=no,width=' + ((_width!="" && _width)?_width:'510') + ',height=' + ((_height!="" && _height)?_height:'230'));
}

function addlibrary(_songid) {
	openPopup("/new-favourite-song?songid="+_songid);
}

function addperformer(_uid,_uname) {
	openPopup("/new-favourite-singer?id="+_uid+"&username="+_uname, 350, 510);
}

function songfeedback(_sid) {
	songfeedbackx(_sid,null);
}

function recfeedback(_rid,_uid) {
	recfeedbackx(_rid,_uid,null);
}

function userfeedback(_uid) {
	recfeedbackx(-1,_uid,null);
}

function deleteRecording(_rid, _sname) {
	if (confirm('Are you sure yo want to delete this recording of "'+_sname+'"?\n All the votes and comments will be deleted.')) {
		openPopup("/borrar-grabacion?rid="+_rid, 350, 510);
	}
}

function consejosPlayer() {
	window.open('/consejosplayer.html','Consejos','scrollbars=yes,toolbar=no,menubar=no,status=no,location=no,top=0,left=0,resizable=no,width=540,height=450');
}

function openKaraoke(id) {
	window.open('/karaoke.php?id='+id,'Karaoke','scrollbars=yes,toolbar=no,menubar=no,status=no,location=no,top=0,left=0,resizable=no,width=1024,height=540');
}

function recOK(_rid) {
	window.location="/upload_recording.php?rid="+_rid;
}

function showElement (name) {
	theElement = document.getElementById(name);
	if (theElement) {
		theElement.style.display = "inline";
	}
}

function hideElement (name) {
	theElement = document.getElementById(name);
	if (theElement) {
		theElement.style.display = "none";
	}
}

var flagLang=true;
var flagDir=true;
function showLangs (){
		var sm=document.getElementById('langs');
		if (flagLang) {
			sm.style.display="none";
		}
		if (sm.style.display=="none") {
			sm.style.display="block";
		} else {
			sm.style.display="none";
		}
		flagLang=false;
}
function showDir (){
		var dm=document.getElementById('dirSearch');
		if (flagDir) {
			dm.style.display="none";
		}
		if (dm.style.display=="none") {
			dm.style.display="block";
		} else {
			dm.style.display="none";
		}
		flagDir=false;
}

// FUNCIONES PARA LAS ETIQUETAS

var zLast=11;
var zRank=15;

function changeLayer (cual) {
		if (cual=="kar") {
			document.getElementById("kar").style.display="block";
			document.getElementById("grab").style.display="none";
		}
		else {
			document.getElementById("kar").style.display="none";
			document.getElementById("grab").style.display="block";
		}
		
}
function changeLayerR (cual) {
		if (cual=="rankNac") {
			document.getElementById("rankNac").style.display="block";
			document.getElementById("rankDeb").style.display="none";
			document.getElementById("rankVal").style.display="none";
			document.getElementById("rankGlob").style.display="none";
		}
		else if (cual=="rankDeb") {
			document.getElementById("rankNac").style.display="none";
			document.getElementById("rankDeb").style.display="block";
			document.getElementById("rankVal").style.display="none";
			document.getElementById("rankGlob").style.display="none";
		}
		else if (cual=="rankVal") {
			document.getElementById("rankNac").style.display="none";
			document.getElementById("rankDeb").style.display="none";
			document.getElementById("rankVal").style.display="block";
			document.getElementById("rankGlob").style.display="none";
		}
		else {
			document.getElementById("rankNac").style.display="none";
			document.getElementById("rankDeb").style.display="none";
			document.getElementById("rankVal").style.display="none";
			document.getElementById("rankGlob").style.display="block";
		}
		/**/
		changeBack (cual);
		/**/
}
function changeBack (cual) {
		document.getElementById("mRank41").style.backgroundImage="url(/img2/rank4_1_Off.gif)";
		document.getElementById("mRank42").style.backgroundImage="url(/img2/rank4_2_Off.gif)";
		document.getElementById("mRank43").style.backgroundImage="url(/img2/rank4_3_Off.gif)";
		document.getElementById("mRank44").style.backgroundImage="url(/img2/rank4_4_Off.gif)";
		document.getElementById("mRank41").style.color="#999999";
		document.getElementById("mRank42").style.color="#999999";
		document.getElementById("mRank43").style.color="#999999";
		document.getElementById("mRank44").style.color="#999999";
		document.getElementById("mRank41").style.cursor="pointer";
		document.getElementById("mRank42").style.cursor="pointer";
		document.getElementById("mRank43").style.cursor="pointer";
		document.getElementById("mRank44").style.cursor="pointer";
		if (cual=="rankNac") {
			document.getElementById("mRank41").style.backgroundImage="url(/img2/rank4_1_On.gif)";
			document.getElementById("mRank41").style.color="#A60101";
			document.getElementById("mRank41").style.cursor="default";
		}
		if (cual=="rankDeb") {
			document.getElementById("mRank42").style.backgroundImage="url(/img2/rank4_2_On.gif)";
			document.getElementById("mRank42").style.color="#A60101";
			document.getElementById("mRank42").style.cursor="default";
		}
		if (cual=="rankVal") {
			document.getElementById("mRank43").style.backgroundImage="url(/img2/rank4_3_On.gif)";
			document.getElementById("mRank43").style.color="#A60101";
			document.getElementById("mRank43").style.cursor="default";
		}
		if (cual=="rankGlob") {
			document.getElementById("mRank44").style.backgroundImage="url(/img2/rank4_4_On.gif)";
			document.getElementById("mRank44").style.color="#A60101";
			document.getElementById("mRank44").style.cursor="default";
		}
}
function changeLayerR2 (cual) {
		document.getElementById("rankNac").style.zIndex=zLast;
		document.getElementById("rankDeb").style.zIndex=zLast;
		document.getElementById("rankVal").style.zIndex=zLast;
		document.getElementById("rankGlob").style.zIndex=zLast;
		document.getElementById("rankAlt").style.zIndex=zLast;
		var lm=document.getElementById(cual);
		lm.style.zIndex=zLast+2;
		/**/
		changeBack2 (cual);
		/**/
}
function changeBack2 (cual) {
		document.getElementById("mRank51").style.backgroundImage="url(/img2/rank5_1_Off.gif)";
		document.getElementById("mRank52").style.backgroundImage="url(/img2/rank5_2_Off.gif)";
		document.getElementById("mRank53").style.backgroundImage="url(/img2/rank5_3_Off.gif)";
		document.getElementById("mRank54").style.backgroundImage="url(/img2/rank5_4_Off.gif)";
		document.getElementById("mRank55").style.backgroundImage="url(/img2/rank5_5_Off.gif)";
		document.getElementById("mRank51").style.color="#999999";
		document.getElementById("mRank52").style.color="#999999";
		document.getElementById("mRank53").style.color="#999999";
		document.getElementById("mRank54").style.color="#999999";
		document.getElementById("mRank55").style.color="#999999";
		document.getElementById("mRank51").style.cursor="pointer";
		document.getElementById("mRank52").style.cursor="pointer";
		document.getElementById("mRank53").style.cursor="pointer";
		document.getElementById("mRank54").style.cursor="pointer";
		document.getElementById("mRank55").style.cursor="pointer";
		if (cual=="rankAlt") {
			document.getElementById("mRank51").style.backgroundImage="url(/img2/rank5_1_On.gif)";
			document.getElementById("mRank51").style.color="#A60101";
			document.getElementById("mRank51").style.cursor="default";
		}
		if (cual=="rankDeb") {
			document.getElementById("mRank52").style.backgroundImage="url(/img2/rank5_2_On.gif)";
			document.getElementById("mRank52").style.color="#A60101";
			document.getElementById("mRank52").style.cursor="default";
		}
		if (cual=="rankVal") {
			document.getElementById("mRank53").style.backgroundImage="url(/img2/rank5_3_On.gif)";
			document.getElementById("mRank53").style.color="#A60101";
			document.getElementById("mRank53").style.cursor="default";
		}
		if (cual=="rankGlob") {
			document.getElementById("mRank54").style.backgroundImage="url(/img2/rank5_4_On.gif)";
			document.getElementById("mRank54").style.color="#A60101";
			document.getElementById("mRank54").style.cursor="default";
		}
		if (cual=="rankNac") {
			document.getElementById("mRank55").style.backgroundImage="url(/img2/rank5_5_On.gif)";
			document.getElementById("mRank55").style.color="#A60101";
			document.getElementById("mRank55").style.cursor="default";
		}
}