// Questa funzione inserisce alcuni attributi proprietari di Safari solo in Safari, oltre ad aggiungere (per tutti i browser moderni) un valore di default nel campo di ricerca e ad eliminarlo quando il campo ha il focus

//( http://www.ceprix.net/archives/how-to-validate-your-xhtml-while-using-safari-attributes/

var DEF_VAL   = "Email"; // Default Value
var isSafari = (navigator.userAgent.indexOf("AppleWebKit") !=-1); // Detecting not only Safari but WebKit-based browsers

function initSearchform() {
    if (!document.getElementById) return false;
    if (!document.getElementById('l102137-102137')) return false;
    var theSearchField = document.getElementById('l102137-102137');
    if (isSafari) {
        // Changing type to 'search' from 'text'
        // and inserting 'autosave,' 'results,' 'placeholder' values for Safari and WebKit-based browsers
        theSearchField.setAttribute('type', 'search');
        theSearchField.setAttribute('autosave', 'giopaolomaggini.data');
        theSearchField.setAttribute('results', '10');
        theSearchField.setAttribute('placeholder', DEF_VAL);
    } else {
        // Displaying-&-hiding-stuff for non-WebKit-based browsers
        theSearchField.onfocus    = focusSearch;
        theSearchField.onblur     = blurSearch;
        if (theSearchField.value=='') theSearchField.value = DEF_VAL;
}
}

function focusSearch() {
    if (this.value==DEF_VAL) {
        this.value = '';
    }
}

function blurSearch() {
    if (this.value=='') {
        this.value = DEF_VAL;
    }
}
