/**********************************************************************************
****** Funciones JavaScript utilizadas en las páginas de la sección ENLACES *******
***********************************************************************************/

function printResults(order, surveyId)
{
	var params = "toolbar=0,location=0,scrollbars=1,directories=0,status=0,menubar=0,resizable=1,left=0,top=0,width=530,height=400";
	var preffix = (isInternetExplorer()) ? "" : "encuestas/";
	var direction = preffix + "imprimirResultados07.asp?id=" + surveyId;
	direction = (order == "") ? direction : direction + "&orden=votos";

	window.open(direction,'ventana_encuesta',params);

}

function adjustResults()
{
	var divWidth = document.getElementById("encuesta-capa").clientWidth;
	var tableWidth = document.getElementById("encuesta-tabla").clientWidth;

	var divHeight = document.getElementById("encuesta-capa").clientHeight;
	var tableHeight = document.getElementById("encuesta-tabla").clientHeight;
	var verticalOffset = (isInternetExplorer()) ? 30 : 15;

	if (tableHeight < divHeight)
		document.getElementById("encuesta-capa").style.height = (tableHeight + verticalOffset) + "px";
	if (tableWidth < divWidth && isInternetExplorer())
		document.getElementById("encuesta-tabla").style.width = (divWidth) + "px";
}

function valida(numberOfOptions)
{
	opciones = 0;
	numero = document.forms[0].elements["opcion"].length;

	for (var i=0; i<numero; i++)
	{
		if (document.forms[0].elements["opcion"][i].checked)
			opciones++;
	}
	if (opciones == 0)
	{
		alert("Por favor, antes de votar elige una opción.");
		return false;
	}
	else if (opciones > numberOfOptions)
	{
		txtOpciones = (numberOfOptions == 1) ? " opción" : " opciones";
		alert("Lo sentimos pero sólo puedes elegir " + numberOfOptions + txtOpciones + ".");
		return false;
	}

	return true;
}