swfobject.embedSWF("cover.swf", "cover", "955", "460", "7.0.0", "../includes/expressInstall.swf", {}, {menu: "false",wmode: "transparent",quality: "high", swliveconnect: "true", allowScriptAccess: "always"
}, {name:"cover"});


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// navigation menu
function toggleLayer(whichLayer) {
	var numBox = 4;
	if (document.getElementById) {
	
	for (i=1; i<=numBox; i++) {
		if (whichLayer != "nav"+i) {
			document.getElementById("nav"+i).style.display = '';
		}
	}
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
	} else if (document.all) {
	
	for (i=1; i<=numBox; i++) {
		if (whichLayer != "nav"+i) {
			document.all["nav"+i].style.display = '';
		}
	}
	
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
	} else if (document.layers)	{
	
	for (i=1; i<=numBox; i++) {
		if (whichLayer != "nav"+i) {
			document.layers["nav"+i].style.display = '';
		}
	}
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
}


function contattaci_check(theForm) {
var objRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;

if (theForm.nome.value == '') {
		alert ('Prego, inserire il Vostro nome!');
		theForm.nome.focus();
		return false;
	} else if (theForm.email.value == '') {
		alert ('Prego, inserire la Vostra e-mail!');
		theForm.email.focus();
		return false;
	} else if (theForm.email.value != '' && !objRegExp.test(theForm.email.value)) {
		alert ('Formato eMail non valido! Prego riprovare...');
		theForm.email.focus();
		return false;
		} else if (theForm.oggetto.value == '') {
		alert ('Prego, inserire oggetto!');
		theForm.oggetto.focus();
		return false;
	} else if (theForm.msg.value == '') {
		alert ('Prego, inserire messaggio!');
		theForm.msg.focus();
		return false;
		} else if (theForm.msg.value.length < 3) {
		alert ('Prego, inserire messaggio!');
		theForm.msg.focus();
		return false;
	} else if (theForm.autorizza.checked == false) {
		alert ('Prego, autorizzare trattamento dei propri dati!');
		return false;
	} else { 	
	return true;
	}
}

function register_check(theForm) {

var objRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
var objRegExp2 = /^[a-zA-Z0-9]{6,20}$/;
var objRegExp3  = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/;
		

	if (theForm.pre_email.value == '') {
		alert("Prego, inserire e-mail!");
		theForm.pre_email.focus();
		return false;
	} else if (theForm.pre_email.value != '' && !objRegExp.test(theForm.pre_email.value)) {
		alert("Formato e-mail non valido! Prego riprovare...");
		theForm.pre_email.focus();
		return false;
	} else if (theForm.email.value == '') {
		alert("Prego, confermare e-mail!");
		theForm.email.focus();
		return false;
	} else if (theForm.email.value != '' && !objRegExp.test(theForm.email.value)) {
		alert("Formato da e-mail confermare  non valido! Prego riprovare...");
		theForm.email.focus();
		return false;
	} else if (theForm.email.value != theForm.pre_email.value) {
		alert("Prego, confermare e-mail correttamente!");
		theForm.email.focus();
		return false;
	} else if (theForm.passwd.value == '') {
		alert ('Prego, inserire password!');
		theForm.passwd.focus();
		return false;
	} else if (theForm.passwd.value != '' && !objRegExp2.test(theForm.passwd.value)) {
		alert("Formato password non valido! Prego riprovare...");
		theForm.passwd.focus();
		return false;
	} else if (theForm.nome.value == '') {
		alert ('Prego, inserire nome!');
		theForm.nome.focus();
		return false;
	} else if (theForm.cognome.value == '') {
		alert ('Prego, inserire cognome!');
		theForm.cognome.focus();
		return false;
	} else if (theForm.data_nasc.value == '') {
		alert ('Prego, inserire data di nascita!');
		theForm.data_nasc.focus();
		return false;
		} else if (theForm.data_nasc.value != '' && !objRegExp3.test(theForm.data_nasc.value)) {
		alert("Formato data di nascita non valido! Prego riprovare...");
		theForm.data_nasc.focus();
		return false;
	} else if (theForm.sesso[0].checked == false && theForm.sesso[1].checked == false) {
		alert ('Prego, selezionare sesso di appartenenza!');
		return false;
		} else if (theForm.city.value == '') {
		alert ('Prego, inserire citta\' di residenza!');
		theForm.city.focus();
		return false;
	} else if (theForm.autorizza.checked == false) {
		alert ('Prego, autorizzare trattamento dei propri dati!');
		return false;
	} else { 	
	return true;
	}
}


function xmlhttpPost(strURL,formname,responsediv,responsemsg) {
    var xmlHttpReq = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
			var varredirect=self.xmlHttpReq.responseText.indexOf('ajax.success'); 

			if (varredirect == -1 ) { 
	            updatepage(self.xmlHttpReq.responseText,responsediv);
			}
			
        } else {
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage(responsemsg,responsediv);

		}
    }
    self.xmlHttpReq.send(getquerystring(formname));
}

function getquerystring(formname) {
    var form = document.forms[formname];
	var qstr = "";

    function GetElemValue(name, value) {
        qstr += (qstr.length > 0 ? "&" : "")
            + escape(name).replace(/\+/g, "%2B") + "="
            + escape(value ? value : "").replace(/\+/g, "%2B");
			//+ escape(value ? value : "").replace(/\n/g, "%0D");
    }
	
	var elemArray = form.elements;
    for (var i = 0; i < elemArray.length; i++) {
        var element = elemArray[i];
        var elemType = element.type.toUpperCase();
        var elemName = element.name;
        if (elemName) {
            if (elemType == "TEXT"
                    || elemType == "TEXTAREA"
                    || elemType == "PASSWORD"
					|| elemType == "BUTTON"
					|| elemType == "RESET"
					|| elemType == "SUBMIT"
					|| elemType == "FILE"
					|| elemType == "IMAGE"
                    || elemType == "HIDDEN")
                GetElemValue(elemName, element.value);
            else if (elemType == "CHECKBOX" && element.checked)
                GetElemValue(elemName, 
                    element.value ? element.value : "On");
            else if (elemType == "RADIO" && element.checked)
                GetElemValue(elemName, element.value);
            else if (elemType.indexOf("SELECT") != -1)
                for (var j = 0; j < element.options.length; j++) {
                    var option = element.options[j];
                    if (option.selected)
                        GetElemValue(elemName,
                            option.value ? option.value : option.text);
                }
        }
    }
    return qstr;
}
function updatepage(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}



function check_email(theForm) {
	var objRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	if (theForm.email_rp.value == '') {
		alert ('Prego, inserire la Vostra e-mail!');
		theForm.email_rp.focus();
		return false;
	} else if (theForm.email_rp.value != '' && !objRegExp.test(theForm.email_rp.value)) {
		alert ('Formato eMail non valido! Prego riprovare...');
		theForm.email_rp.focus();
		return false;
	} else { 	
	xmlhttpPost('recupero_passwd_resp.php', 'form_rp', 'form_rp_result', '<div style=\'margin-bottom:5px\'><strong>Prego, attendere...</strong></div>');
	theForm.email_rp.value = '';
	return false;
	}
}

function lavoraconnoi_check(theForm) {
var objRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
var objRegExp2 = /^[^/]+(.[dD][oO][cC]|.[rR][tT][fF]|.[tT][xX][tT]|.[pP][dD][fF])$/;
var objRegExp3  = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/;

if (theForm.nome.value == '') {
		alert ('Prego, inserire il Vostro nome!');
		theForm.nome.focus();
		return false;
	} else if (theForm.cognome.value == '') {
		alert ('Prego, inserire il Vostro cognome!');
		theForm.cognome.focus();
		return false;
	} else if (theForm.sesso[0].checked == false && theForm.sesso[1].checked == false) {
		alert ('Prego, inserire sesso!');
		return false;
	} else if (theForm.data_nasc.value == '') {
		alert ('Prego, inserire data di nascita!');
		theForm.data_nasc.focus();
		return false;
	} else if (theForm.data_nasc.value != '' && !objRegExp3.test(theForm.data_nasc.value)) {
		alert ('Formato data di nascita non valido! Prego riprovare...');
		theForm.data_nasc.focus();
		return false;
	} else if (theForm.prov.value == '') {
		alert ('Prego, inserire provincia!');
		theForm.prov.focus();
		return false;
	} else if (theForm.settore.value == '') {
		alert ('Prego, selezionare settore!');
		theForm.settore.focus();
		return false;
	} else if (theForm.email.value == '') {
		alert ('Prego, inserire la Vostra e-mail!');
		theForm.email.focus();
		return false;
	} else if (theForm.email.value != '' && !objRegExp.test(theForm.email.value)) {
		alert ('Formato eMail non valido! Prego riprovare...');
		theForm.email.focus();
		return false;
		} else if (theForm.note.value == '' && theForm.file.value == '') {
			alert ('Prego, inserire curriculum!');
		theForm.note.focus();
		return false;
		} else if (theForm.note.value != '' && theForm.note.value.length < 3) {
		theForm.note.focus();
		return false;
	} else if (theForm.file.value != '' && !objRegExp2.test(theForm.file.value)) {
		alert ('Formato file non valido! Prego riprovare...');
		theForm.file.focus();
		return false;
	} else if (theForm.autorizza.checked == false) {
		alert ('Prego, autorizzare trattamento dei propri dati!');
		return false;
	} else { 	
	return true;
	}
}

function guestbook_check(theForm) {
var objRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;

if (theForm.nome.value == '') {
		alert ('Prego, inserire il Vostro nome!');
		theForm.nome.focus();
		return false;
	} else if (theForm.email.value == '') {
		alert ('Prego, inserire la Vostra e-mail!');
		theForm.email.focus();
		return false;
	} else if (theForm.email.value != '' && !objRegExp.test(theForm.email.value)) {
		alert ('Formato eMail non valido! Prego riprovare...');
		theForm.email.focus();
		return false;
	} else if (theForm.cmt.value == '') {
		alert ('Prego, inserire messaggio!');
		theForm.cmt.focus();
		return false;
		} else if (theForm.cmt.value.length < 3) {
		alert ('Prego, inserire messaggio!');
		theForm.cmt.focus();
		return false;
	} else if (theForm.autorizza.checked == false) {
		alert ('Prego, autorizzare trattamento dei propri dati!');
		return false;
	} else { 	
	return true;
	}
}


/* --------- tasto destro ---------- */
var now = new Date();
var titolo = "Country Club Portorotondo";
var anno_start = 2010;
if (now.getFullYear() > anno_start) {
	var warningMessage="Copyright "+anno_start+"-"+now.getFullYear()+" "+titolo+". Tutti i diritti riservati.";
} else {
	var warningMessage="Copyright "+anno_start+" "+titolo+". Tutti i diritti riservati.";
}

function onMouseDownIE4(){
	if(event.button==2){
		alert(warningMessage);
		return false;
	}
};

function onMouseDownNS4(e){
	if(document.layers||document.getElementById&&!document.all) {
		if(e.which==2||e.which==3){
			alert(warningMessage);
			return false;
		}
	}
};

if(document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=onMouseDownNS4;
} else if(document.all&&!document.getElementById){
	document.onmousedown=onMouseDownIE4;
};
document.oncontextmenu=new Function("alert(warningMessage);return false");
document.onselect = function() { 
 return false; 
}
document.onkeydown = function() {
	if ((event.keyCode == 78) && (event.ctrlKey)){
		event.cancelBubble = true;
		event.returnValue = false;
		event.keyCode = false; 
		return false;
	}
}
/* --------- tasto destro - fine ---------- */
