function switchVisibleMode() {
	var advancedSearch = document.getElementById('advancedSearch');
	if (advancedSearch.style.display == 'none') {
		advancedSearch.style.display = "block";
	} else {
		advancedSearch.style.display = "none";
	}
}

function setFields(fieldsId) {
	document.advancedSearch.fieldsId.value = document.fieldsSearch.fieldsId.options[document.fieldsSearch.fieldsId.selectedIndex].value;
}

function windowOpen(name, url, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
  var wint = (screen.height - height) / 2;
  var winl = (screen.width - width) / 2;
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+winl+',top='+wint+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function sendVote(pollForm) {
	windowOpen('result', '', 320, 430);
	pollForm.submit();
}
function showHideBlock(block) {
	obj = document.getElementById(block);
	obj.style.display = (obj.style.display == 'none') ? 'block' : 'none';
}
var hasCookies = false;
  
//tests whether the user accepts cookies, and sets a flag.
if(document.cookie == '') {
	document.cookie = 'hasCookies=yes';
	if (document.cookie.indexOf('hasCookies=yes') != -1) hasCookies = true;
}
else hasCookies = true;

// sets a cookie in the browser.
function setCookie (name, value, hours, path) {
	if (hasCookies) {
		if(hours) {
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) var numHours = hours;
			else if (typeof(hours) == 'number') var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
		}
		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'');
	}
}
 
// reads a cookie from the browser
function readCookie(name) {
	if (document.cookie == '') return '';
	else {
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		if (firstChar != -1) {
			firstChar += name.length + 1;
			lastChar = theBigCookie.indexOf(';', firstChar);
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape(theBigCookie.substring(firstChar, lastChar));
		}
		else return '';
	}
}