function checkContactForm() {
	
   	var nome = $('nome');
    var cognome = $('cognome');
	var email = $('email');
	var message = $('msg');
	var captcha = $('captcha');
	    
    if ((nome.value == "") || (nome.value == "undefined")) {
    	alert("Inserire il nome!");
        nome.focus();
       	return false;
    } else if ((cognome.value == "") || (cognome.value == "undefined")) {
        alert("Inserire il cognome!");
		cognome.focus();
        return false;
    } else if ((email.value == "") || (email.value == "undefined")) {
        alert("Inserire la email!");
        email.focus();
        return false;
    } else if ((message.value == "") || (message.value == "undefined")) {
        alert("Inserire il testo del messaggio!");
        message.focus();
        return false;
    } else if (!mailCheck(email.value)){
		alert("Indirizzo mail non corretto!");
        email.focus();
        return false;
	} else if(captcha.value == ""){
		alert("Indirizzo il codice di sicurezza!");
        captcha.focus();
        return false;
	} else {
        document.modulo.action = "sendinfo.php";
        document.modulo.submit();
    }
}

function mailCheck(x){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		return true;
	} else {
		return false;
	}
}

function openRouteHTextLink(w){
	//try { hs.getExpander().doClose(); } catch (e) {}
	var id = w.split('|')[0];
	var type = w.split('|')[1];
	var url = '';
	if(type == 9){
		url = 'progetti/traghetto/card.php?id=' + id;
		if(/MSIE/.test(navigator.userAgent) && !window.opera){
			style = 'width=800px,height=607px,scrollbars=no,resizable=yes';
		} else {
			style = 'width=800px,height=580px,scrollbars=no,resizable=yes';
		}
		
	} else if(type == 0){
		url = 'progetti/traghetto/inc/openRC.php?id=' + id + '&type=' + type;
		style = 'width=710px,height=600px,scrollbars=no,resizable=yes';
	} else if(type == 6){
		url = 'progetti/traghetto/inc/openRC.php?id=' + id + '&type=' + type;
		style = 'width=750px,height=550px,scrollbars=yes,resizable=yes';
	} else if(type == 5){
		url = 'progetti/traghetto/inc/openRC.php?id=' + id + '&type=' + type;
		style = 'width=600px,height=550px,scrollbars=yes,resizable=yes';
	} else if(type == 4){
		url = 'progetti/traghetto/inc/openRC.php?id=' + id + '&type=' + type;
		style = 'width=525px,height=550px,scrollbars=yes,resizable=no';		
	} else {
		url = 'progetti/traghetto/inc/openRC.php?id=' + id + '&type=' + type;
		style = 'width=600px,height=600px,scrollbars=no,resizable=yes';
	}
	var win = window.open(url, 'routecontent', style);
}
