function Set_Cookie( name, value, expires, path, domain, secure ){
var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function btnOver(obj){
	obj.style.cursor='pointer';
}
function selectLang(id){
	Set_Cookie("Lang", id);
	location.href='index.php';
	
}

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	
	return randomstring;
}


function chkEmail(){
	var nome = document.getElementById('nome').value;
	var email = document.getElementById('email').value;
	var oggetto = document.getElementById('oggetto').value;
	var testo = document.getElementById('testo').value;
	if (!nome || !email || !oggetto || !testo){
		alert ("Devi compilare tutti i campi per inviare l'email!");
		return false;
	}else{
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		if (!espressione.test(email)){
			alert ("L'email inserita non è valida!");
			return false;
		}
	}
}

