$(document).ready(function(){
   
    //init vars so IE dosent fall down
    var banner = '';
    var image = '';
    
    this.header = '';
    this.contact = '';
    
    //rotation speed
    var speed = 5;
    var delay = 1;
    
    this.header = $("#header-text");
    this.contact = $("#enquiry-info");

    $.ajax({
      url: '/get_homepage_banners',
      async: false,
      dataType: 'json',
      success: function (json) {
          
          if(json.length > 1)
          {

            var banner = $("#banner_image").css("width",723);
            banner.css("height", 323);

            banner.crossSlide({
              sleep: speed,
              fade: delay
            },
            json 
            , function(idx, img, idxOut, imgOut) {
              if (idxOut == undefined)
              {
                // starting single image phase, put up caption
                document.header.html("<h1>" + json[idx].head['title'] + "</h1><p><span>" + json[idx].head['copy'] + "</span></p>")
                //replace fonts
                Cufon.replace('#enquiry-info')('#header-text');
                //fade
                //document.header.fadeIn() 
              }
              else
              {
                // starting cross-fade phase, take out caption
                //document.header.fadeOut()
              }
            });
          }
      }
    });

});
