// JavaScript Document
//*******************JAVASCRIPT INITIALIZING FUNCTIONS********************************************************
//functions initialize functions
window.onload = callfunctions;
window.onunload = removefunctions;
function callfunctions() {
	formValidationOverRules();
}

function removefunctions() {
	formValidationOverRules();
}


//*******************FORM VALIDATION FUNCTIONS****************************************************************************
//form onFocus and onBlur functions:
/*CODICE MOLTO TOZZO RIPRESO DA QUELLO SOTTO (funziona solo da solo): (vedi anche assoeurope_form.css) McLaud2k4*/
function formValidationOverRules() {
        if (!document.getElementsByTagName) return;
        var allInputs = document.getElementsByTagName("input");
        for (var i = 0; i < allInputs.length; i++) {
                if (allInputs[i].type != 'text') continue
                        //var allInput = allInputs[i];
                        allInputs[i].onfocus = function() {
                                this.className = 'boxFocus';
                                if (this.value=='Nome') this.value='';
                                if (this.value=='Cognome') this.value='';
                                if (this.value=='Indirizzo') this.value='';
                                if (this.value=='Cittą') this.value='';
                                if (this.value=='Telefono') this.value='';
                                if (this.value=='Fax') this.value='';
                                if (this.value=='E-mail') this.value='';
                                if (this.value=='Sito web') this.value='';
								//EN
								if (this.value=='First name') this.value='';
                                if (this.value=='Last name') this.value='';
                                if (this.value=='Address') this.value='';
                                if (this.value=='City') this.value='';
                                if (this.value=='Telephone') this.value='';
                                if (this.value=='Fax') this.value='';
                                if (this.value=='E-mail') this.value='';
                                if (this.value=='Website') this.value='';
                        }
                        allInputs[i].onblur = function() {
                                this.className = 'boxBlur';
                                if (this.value=='' && this.getAttribute("name")=="nome") this.value='Nome';
                                if (this.value=='' && this.getAttribute("name")=="cognome") this.value='Cognome';
                                if (this.value=='' && this.getAttribute("name")=="indirizzo") this.value='Indirizzo';
                                if (this.value=='' && this.getAttribute("name")=="citta") this.value='Cittą';
                                if (this.value=='' && this.getAttribute("name")=="tel") this.value='Telefono';
                                if (this.value=='' && this.getAttribute("name")=="fax") this.value='Fax';
                                if (this.value=='' && this.getAttribute("name")=="email") this.value='E-mail';
                                if (this.value=='' && this.getAttribute("name")=="web") this.value='Sito web';
								//EN
								if (this.value=='' && this.getAttribute("name")=="en_nome") this.value='First name';
                                if (this.value=='' && this.getAttribute("name")=="en_cognome") this.value='Last name';
                                if (this.value=='' && this.getAttribute("name")=="en_indirizzo") this.value='Address';
                                if (this.value=='' && this.getAttribute("name")=="en_citta") this.value='City';
                                if (this.value=='' && this.getAttribute("name")=="en_tel") this.value='Telephone';
                                if (this.value=='' && this.getAttribute("name")=="en_fax") this.value='Fax';
                                if (this.value=='' && this.getAttribute("name")=="en_email") this.value='E-mail';
                                if (this.value=='' && this.getAttribute("name")=="en_web") this.value='Website';
								
                        }
                }
                var allTextAreas = document.getElementsByTagName("textarea");
                for (var i = 0; i < allTextAreas.length; i++) {
                var allTextArea = allTextAreas[i];
                allTextAreas[i].onfocus = function() {
                        this.className = 'boxFocus';
                        if (this.value=='Messaggio' && this.getAttribute("name")=="info") this.value='';
                        if (this.value=='Message' && this.getAttribute("name")=="en_info") this.value='';
                }
                allTextAreas[i].onblur = function() {
                        this.className = 'boxBlur';
                        if (this.value=='' && this.getAttribute("name")=="info") this.value='Messaggio';
						if (this.value=='' && this.getAttribute("name")=="en_info") this.value='Message';
                }
        }
        //rel external --- overrides the target="_blank" tag:
        //Before:<a href="document.html" target="_blank">external link</a>
        //After:<a href="document.html" rel="external">external link</a>
         var anchors = document.getElementsByTagName("a");
         for (var i=0; i<anchors.length; i++) {
           var anchor = anchors[i];
           if (anchor.getAttribute("href") &&
                           anchor.getAttribute("rel") == "external")
                         anchor.target = "_blank";
         }

}



//
function openpopup(URL, popW, popH, scroll) {
        var winleft = (screen.width - popW) / 2;
        var winUp = (screen.height - popH) / 2;
        dimensioni = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable = "no"';
        var info = window.open("","info",dimensioni);
        info.document.location = URL;
        info.document.close();
        info.focus();
        //return false;
}

//
function emailes(Address,Domain) {
  var Mailme = "mail" + "to:"+Address+"@"+Domain;
  parent.location=Mailme;
}
