window.onload = function() {
	new Rollover('nav');
}

function changeLang(url, l) {
	new Ajax.Request(url, {
		method:'get',
		parameters: {lang: l},
		onSuccess:function() {
			document.location.reload();
		}
	});
}

function showSelect() {
	var someNodeList = $$('select');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'visible';
	});
}
function hideSelect() {
	var someNodeList = $$('select');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'hidden';
	});
}
function showFlash() {
	var someNodeList = $$('embed');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'visible';
	});
	var someNodeList = $$('object');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'visible';
	});
}
function hideFlash() {
	var someNodeList = $$('embed');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'hidden';
	});
	var someNodeList = $$('object');
	var nodes = $A(someNodeList);
	nodes.each(function(node) {
		node.style.visibility = 'hidden';
	});
}
function afterMBHide() {
	showSelect();
	showFlash();
}
function displayContactMB() {
	var MBScript = 'index.php?item=contact&output=basic';
	var MBTitle = 'Contact';
	Modalbox.show(MBScript, {title:MBTitle, method:'get', width:500, afterLoad:afterContactMBLoaded, afterHide:afterMBHide });
	return false;
}
function afterContactMBLoaded() {
	var valid = new Validation('contactform', {immediate:false, useTitles:true, onFormValidate:contactValidationCallback});
	hideSelect();
	hideFlash();
}
function contactValidationCallback(result, form) {
	if (result) {
		Modalbox.show('index.php?item=contact&output=basic', {title:'Contact', params:Form.serialize('contactform'), method:'post', afterHide:afterMBHide });
		return false;
	} else {
		Effect.Appear('errorLi');
		var someNodeList = $$('div.validation-advice');
		var nodes = $A(someNodeList);
		var totalHeight = 0;
		nodes.each(function(node) {
			totalHeight += node.getHeight()+10;
		});
		Modalbox.resize(0, totalHeight);
	}
}
