/*function init(){
	define('firstname','string','First Name');
	define('lastname','string','Last Name');
	define('street','string','Street');
  define('city','string','City');
	define('zipcode','string','Zip Code');
	define('country','string','Country');
	define('phone','string','Phone');
	define('emailsender','email','E-mail sender');
	define('confirmemail','email','Confirm E-mail sender');
}
*/
function apri(num){
    var str = 'pro_florencecal.php?M='+num;
    aa=window.open(str,'new','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=246,left=100,top=100');
    aa.focus();
}
function apri2(num){
    var str = 'pro_florencecal2.php?M='+num;
    aa=window.open(str,'new','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=170,left=100,top=100');
    aa.focus();
}


var flashlinks=new Array();

function changelinkcolor(){
    for (i=0; i< flashlinks.length; i++){
        var flashtype=document.getElementById? flashlinks[i].getAttribute("flashtype")*1 : flashlinks[i].flashtype*1
        var flashcolor=document.getElementById? flashlinks[i].getAttribute("flashcolor") : flashlinks[i].flashcolor
        if (flashtype==0){
            if (flashlinks[i].style.color!=flashcolor)
                flashlinks[i].style.color=flashcolor
            else
                flashlinks[i].style.color=''
        }
        else if (flashtype==1){
            if (flashlinks[i].style.backgroundColor!=flashcolor)
                flashlinks[i].style.backgroundColor=flashcolor
            else
                flashlinks[i].style.backgroundColor=''
        }
    }
}

/*
function init(){
    var i=0
    if (document.all){
        while (eval("document.all.flashlink"+i)!=null){
            flashlinks[i]= eval("document.all.flashlink"+i)
            i++
        }
    }
    else if (document.getElementById){
        while (document.getElementById("flashlink"+i)!=null){
            flashlinks[i]= document.getElementById("flashlink"+i)
            i++
        }
    }
    setInterval("changelinkcolor()", 1000)
}

if (window.addEventListener)
    window.addEventListener("load", init, false)
else if (window.attachEvent)
    window.attachEvent("onload", init)
else if (document.all)
    window.onload=init

*/
function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d=document; if(d.images){
        if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0){
                d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
            }
    }
}

 
function popfi1(mypage,myname,w,h,pos,infocus,scrolbar){
    var popfi1Window=null;
    if(pos=='random'){
        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=='center'){
        LeftPosition=(screen.width)?(screen.width-w)/2:100;
        TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!='center' && pos!='random') || pos==null){
        LeftPosition=100;TopPosition=100;
    }settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars='+scrolbar+',resizable=no,dependent=no';
    popfi1Window=window.open('',myname,settings);
    if(infocus=='front'){
        popfi1Window.focus();popfi1Window.location=mypage;
    }
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null){
            document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
        }
}

/*FORM BOOKINGPRIVATE (TOUR PRIVATI)*/

//controllo il form prima di inviare i dati

function checkForm()	
{
    var name = document.getElementById('firstname').value;
    var surname = document.getElementById('lastname').value;
    var email = document.getElementById('emailsender').value;
    var emailConfirm = document.getElementById('confirmemail').value;
    var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;//espress regolare per controllare il formato delle mail
	
	  
    if ((name == "") || (name == "undefined"))
    {
        alert("Please enter your name");
        document.TheForm.firstname.focus();
        return false;
    }
    else if ((surname == "") || (surname == "undefined"))
    {
        alert("Please enter your surname");
        document.TheForm.lastname.focus();
        return false;
    }
    else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined"))
    {
        alert("Please enter a valid e-mail address");
        document.TheForm.emailsender.focus();
        return false;
    }
    else if (email != emailConfirm)
    {
        alert("Your E-mail and your Confirm E-mail are not the same");
        document.TheForm.confirmemail.focus();
        return false;
    }
    else
    {
        return true;
    }
}

function submitForm(nomeForm, actionPage)
{
    if (checkForm())//se nome e d email sono inserite fai il submit
    {
        var tmpForm=document.getElementById(nomeForm);
        tmpForm.action=actionPage;
        tmpForm.method="post";
        tmpForm.submit();
    }
}
