function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function toggleLayer() {
	for ( var i=0; i < arguments.length; i++ ) {
		$(arguments[i]).style.display = ($(arguments[i]).style.display != 'none' ? 'none' : '' );
	}
}

function hideLayer() {
	for ( var i=0; i < arguments.length; i++ ) {
		$(arguments[i]).style.display = 'none';
	}
}

function showLayer() {
	for ( var i=0; i < arguments.length; i++ ) {
		$(arguments[i]).style.display = '';
	}
}

function closeWindow() {
	window.open('','_parent','');
	window.close();
}

function countdown(seconds,maxi)
         {

			seconds = seconds-1;
         minutes = seconds / 60;

			//if we're back to 0, then worst case they clicked immediately and we're 5 minutes into our timeout
			         
         if (seconds<0) seconds=maxi-5*60;
         
         if (minutes==5) window.open('/timeout.php','timeout','left=200,top=200,width=500,height=300,toolbar=0,status=0,resizable=0,location=0'); 
                        
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown('+seconds+',' + maxi + ');', 1000);
}

function survey_format_change(obj) {

if (obj.value == "N")
{
hideLayer('token_surveys');
showLayer('anon_surveys');
} else {

showLayer('token_surveys');
hideLayer('anon_surveys');
}

}

