if (!applesearch) var applesearch = {}; applesearch.init = function ()
{ var srchform = document.getElementById('cntnt01moduleform_1'); if(srchform) { var srchinput = document.getElementById('cntnt01searchinput'); labelText = applesearch.getLabelText(); if ( navigator.userAgent.toLowerCase().indexOf('safari') < 0 && document.getElementById ) { this.clearBtn = false; var dummy = document.getElementById("champ-recherche"); if (dummy) dummy.href = "css/champ-recherche.css"; var r_crnr = document.createElement('span'); r_crnr.className = 'sbox_r'; r_crnr.setAttribute('id','srch_clear'); var fieldsets = srchform.getElementsByTagName('fieldset'); if (fieldsets) { fieldsets[0].appendChild(r_crnr);}
var d_clr = document.createElement('div'); d_clr.setAttribute('class','clear'); srchform.appendChild(d_clr); var labels = srchform.getElementsByTagName('label'); if (labels) { if (labels[0].currentStyle) { labelColor = labels[0].currentStyle.color; inputColor = srchinput.currentStyle.color;} else if (document.defaultView.getComputedStyle) { labelColor = document.defaultView.getComputedStyle(labels[0], null).getPropertyValue('color'); inputColor = document.defaultView.getComputedStyle(srchinput, null).getPropertyValue('color');}
}
if(srchinput) { srchinput.value = labelText; srchinput.style.color = labelColor; srchinput.onkeyup = function () { applesearch.onChange('cntnt01searchinput','srch_clear');}
srchinput.onfocus = function () { if (this.value == labelText) { this.value = ''; this.style.color = inputColor;}
}
srchinput.onblur = function () { if (this.value == '') { this.value = labelText; this.style.color = labelColor;}
}
}
srchform.onsubmit = function()
{ if(srchinput && srchinput != labelText) { return true;} else { return false;}
}
} else { if(srchinput) { srchinput.type = 'search'; srchinput.setAttribute('placeholder',labelText); srchinput.setAttribute('autosave','bsn_srch'); srchinput.setAttribute('results','5');}
}
}
}
applesearch.getLabelText = function()
{ var srchform = document.getElementById('cntnt01moduleform_1'); if(srchform) { var labels = srchform.getElementsByTagName('label'); if (labels) { var labelFor = labels[0].getAttribute('for'); var labelText = labels[0].firstChild.nodeValue;} else { var labelText = 'Search';}
} else { var labelText = 'Search';}
return labelText;}
applesearch.onChange = function (fldID, btnID)
{ var fld = document.getElementById( fldID ); var btn = document.getElementById( btnID ); if (fld.value.length > 0 && fld.value != labelText && !this.clearBtn) { btn.className = 'sbox_r_f2'; btn.fldID = fldID; btn.onclick = this.clearBtnClick; this.clearBtn = true;} else if (fld.value.length == 0 && this.clearBtn) { btn.className = 'sbox_r'; btn.onclick = null; this.clearBtn = false; fld.value = labelText; fld.style.color = labelColor;}
}
applesearch.clearFld = function (fldID,btnID)
{ var fld = document.getElementById( fldID ); fld.value = ''; this.onChange(fldID,btnID);}
applesearch.clearBtnClick = function ()
{ applesearch.clearFld(this.fldID, this.id);}
window.onload = function () { applesearch.init(); setupZoom();}
