/*******************************************************************************
 *
 *	Fichier :	/javascript/default.js
 *	Projet :	Pieds à Gilles v3 (http://www.piedsagilles.ch)
 *	Auteur :	Julien Apollonio <julien.apollonio@unil.ch>
 *	Date :		28/01/2008
 *
 ******************************************************************************/


function open_window(href, title, width, height) {
	window.open(href, title, 'toolbar=no, personalbar=no, titlebar=yes, location=yes, directories=no, width='+width+', height='+height+', scrollbars=yes, resizable=yes');
}

function hide_message(id) {
	document.getElementById(id).style.display = 'none';
}

function list_checkbox(form, bool) {
	var checkbox = document.forms[form].getElementsByTagName('input');
	for (i = 0; i <= checkbox.length; i++) {
		if (checkbox[i].getAttribute('type') == 'checkbox') {	
			checkbox[i].checked = bool;
		}
	}
}

function switch_events(session, type) {
	
	var xhr;
	if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
	else if (window.ActiveXObject) xhr = new ActiveXObject('Microsoft.XMLHTTP');
	xhr.open('POST', 'http_request.php', true);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (document.getElementById) document.getElementById('event_list').innerHTML = xhr.responseText;
			
		}
	}
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	var data = 'action='+escape(type)+'&session='+escape(session);
	xhr.send(data);
	setTimeout("alphapng()", 200);
}

function get_events_by_date(session, day, month, year) {
	var xhr;
	if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
	else if (window.ActiveXObject) xhr = new ActiveXObject('Microsoft.XMLHTTP');
	xhr.open('POST', 'http_request.php', true);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (document.getElementById) document.getElementById('event_by_date').innerHTML = xhr.responseText;
		}
	}
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	var data = 'session='+escape(session)+'&action=events_date'+'&date='+escape(day)+'-'+escape(month)+'-'+escape(year);
	xhr.send(data);
}

