function shownetworker(id, id2)
{
	if(id2 !== undefined) {
		id+=""+id2;
	}
	var neu=window.open("http://www.trnd.es/showagent.trnd?id="+id+"","shownetworker","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=500,height=350,left=150,top=50");
	neu.focus();
}

function infowindow(File)
{
	var neu=window.open(File,"infowindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=500,height=450,left=150,top=50");
	neu.focus();
}

function imprint()
{
	var neu=window.open("http://www.trnd.es/imprint.trnd","Contacta_con_nosotros","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=500,height=450,left=150,top=50");
	neu.focus();
}

function privacy()
{
	var neu=window.open("http://www.trnd.es/privacy.trnd","Política_de_protección_de_datos","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=640,height=480,left=150,top=50");
	neu.focus();
}

function termsofuse()
{
	var neu=window.open("http://www.trnd.es/termsofuse.trnd","Aviso_legal","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=640,height=480,left=150,top=50");
	neu.focus();
}

function password()
{
	var neu=window.open("https://www.trnd.es/password.trnd","password","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=400,height=320,left=150,top=50");
	neu.focus();
}

function trndtunes(){
var neu=window.open("/tunes/participate.trnd","trndtunes","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=610,height=514,left=150,top=50");
trndtunes.focus();
};

function toggle( targetId )
{
	if (document.getElementById) {
		var target  = document.getElementById( targetId );

		if (target.style.display === "") {
			target.style.display = "none";
		} else {
			target.style.display = "";
		}
	}
}

function show( targetId )
{
	if (document.getElementById) {
		var target  = document.getElementById( targetId );
		target.style.display = "";
	}
}

function hide( targetId )
{
	if (document.getElementById) {
		var target  = document.getElementById( targetId );
		target.style.display = "none";
	}
}

function checkMaxChecked(fieldname,maxchecked,oldvalues)
{
	var newvalues = [];

	for (i=0;i<oldvalues.length;i++) {
		if (oldvalues[i]!=fieldname) {
			newvalues.push(oldvalues[i]);
		}
	}

	if (oldvalues.length != newvalues.length) {
		oldvalues=newvalues;
	} else {
		oldvalues.push(fieldname);
	}

	if (oldvalues.length>maxchecked) {
		var del=oldvalues.shift();
		document.forms[0].elements[del].checked=false;
	}
}

function checkTextarea(s)
{
	var f=document.forms[0].elements[s];
	if (f.value.length<1) {
		return 1;
	} else {
		return 0;
	}
	
}

function checkRadio(s)
{
	var f=document.forms[0].elements[s];
	var checked=0;
	for (i=0;i<f.length;i++) {
		if (f[i].checked) {
			checked++;
		}
	}
	if (checked === 0) {
		return 1;
	} else {
		return 0;
	}
}

function checkSelect(s)
{
	var f=document.forms[0].elements[s];
	var g=f.options[f.options.selectedIndex].value;
	if (g === "") {
		return 1;
	} else {
		return 0;
	}
	
}

function checkField(s)
{
	var f=document.forms[0].elements[s];
	if (!f.type) {
		f=document.forms[0].elements[s][0];
	}
	if (f.type == "radio") {
		return checkRadio(s);
	}
	if (f.type == "select-one") {
		return checkSelect(s);
	}
	if (f.type == "textarea") {
		return checkTextarea(s);
	}
	return 1;
}