/* DEBUG */
function var_dump(obj)
{
  if(typeof obj == "object") {
    return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
  } else {
    return "Type: "+typeof(obj)+"\nValue: "+obj;
  }
}

/* FRANCE BILLET */
function france_billet()
{
  $.get("/index/france-billet", {}, function(reponse) {
    window.open(reponse);
  }, "text");
}

/* FLASH BANDEAU ACCUEIL */
$(document).ready(function () {
  $('#flashbandeau').flash({
    swf: '/images/site/anim_mc.swf',
    height: 159,
    width: 332,
    params: {
      wmode: 'transparent'
    }
  });
});

/* NEWSLETTER */
function newsletter_subscribe()
{
    var email_value = $('#email_box').val();

    $('#error_box_newsletter').html('');
    $('#succes_box_newsletter').html('');

    $.get("/index/newsletterbox", {email_box: email_value}, function(reponse) {

      var msg = reponse.split('|');
    if (msg[0] == 'erreur') {
      $('#error_box_newsletter').html(msg[1]);
    } else {
      $('#email_box').val('');
      $('#succes_box_newsletter').html(msg[1]);
    }
    }, "text");
}

/* RECHERCHE */
$(document).ready(function() {
  $('input.onFocusClear').focus(function(){
    $(this).val('');
  });
});

/* PNG TRANSPARENT IE6 */
function setie6png(img) { if(document.all && (IEver=parseFloat(navigator.appVersion.split("MSIE")[1])) && (IEver>=5.5) && (IEver<7) && document.body.filters && img) {
  imgName=img.src.toUpperCase();
  if(imgName.substring(imgName.length-3,imgName.length)=="PNG") img.outerHTML=
    "<span "+(img.id?"id='"+img.id+"' ":"")+(img.className?"class='"+img.className+"' ":"")+(img.title?"title=\""+img.title+"\" ":"")
    +"style=\"width:"+img.width+"px;height:"+img.height+"px;"+(img.align=="left"?"float:left;":(img.align=="right"?"float:right;":""))
    +(img.parentElement.href?"cursor:hand;":"")+"display:inline-block;"+img.style.cssText+";"
    +"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"',sizingMethod='scale');\"></span>";
}}
$(document).ready(function() {
  $('img.png').each(function() {
    setie6png(this);
  });
});

/* JQUERY UI */
$(document).ready(function() {
  $('button.ui-state-default').hover(
    function(){
      $(this).addClass("ui-state-hover");
    },
    function(){
      $(this).removeClass("ui-state-hover");
    }
  )

  var elements = $(this).find('button.ui-state-default');
  elements.each(function(){
     var html = $(this).html();
     var reg1 = new RegExp("&lt;", "g");
     var reg2 = new RegExp("(&gt;)", "g");

     html = html.replace(reg1, "<");
     html = html.replace(reg2, ">");

     $(this).html(html)
  });

});