Object.extend(String.prototype, {
  "trim": function () {
    return this.replace(/(^\s*)|(\s*$)/g,'');
  }
});

Event.observe(window, 'load', function() {
  $('newsletter-email').defaultValue = "Entrez votre adresse email";
  $('newsletter-email').setValue($('newsletter-email').defaultValue);
  Event.observe('newsletter-email','focus',function() { if (this.value == this.defaultValue || this.value.trim() == '') this.value = ''; });
  Event.observe('newsletter-email','blur',function() { if (this.value.trim() == '') this.value = this.defaultValue; });
  $('conteneur').show();
  $('footer').show();
  if (Prototype.Browser.IE) {
    Event.observe('newsletter-email','click',function() { if (this.value == this.defaultValue || this.value.trim() == '') this.value = ''; });
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    if (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7) {
      $$('*').each(alphaBackgrounds);
      $$('img').each(fnLoadPngs);
    }
  }
});

function alphaBackgrounds(e) {
  var bg = e.currentStyle.backgroundImage;
  if (bg.match(/\.png/i) != null) { 
    var mypng = bg.substring(5,bg.length-2);
    e.setStyle({
      filter : "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='"+(e.currentStyle.backgroundRepeat == 'no-repeat' ? 'crop' : 'scale')+"')",
      backgroundImage : "none"}); 
  }
}

function fnLoadPngs(img){
  if (img.src.match(/\.png$/i) != null) {
    var src = img.src;
    var div = document.createElement("DIV");    
    div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')";
    div.style.width = img.width + "px";
    div.style.height = img.height + "px";
    img.replaceNode(div); 
  }
}

function submitEmail() {
  Kwo.exec("/stdnat/base.signup/", $('newsletter-form'));
}