$(document).ready(function() {
  
    /* ******************************** */
    /*  HIW Vimeo video                 */
    /* ******************************** */
    /*
    $("#hiw_video_image").hover(function() {
      $(this).attr('src', function() {
        return this.src.replace('off','on');
      });
    }, function() {
      $(this).attr('src', function() {
        return this.src.replace('on','off');
      });
    });
    
    $("#hiw_video_image").click(function(e) {
      e.stopPropagation();
      $('#normal_content').fadeOut(1000, function(){
        $('#video_content').fadeIn(500);
      });
    });

    */
    
    /* ******************************** */
    /*  jCarousel                       */
    /* ******************************** */
    
    jQuery('#carousel_chips').jcarousel({
      scroll: 1,
      visible: 3,
      wrap: 'circular'
    });
    
    
    /* ******************************** */
    /*  Anya Pod video                  */
    /* ******************************** */
    
    //video 5
    var video5 = new SWFObject("http://www.youtube.com/v/HcU27mWgOBM&rel=0&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_profilepage&fs=1&autoplay=1", "movie", 425, 325, "10", "#FFFFFF");
    video5.addParam("allowFullscreen", "true");
    video5.addParam("allowScriptAccess", "always");
    video5.useExpressInstall("http://" + location.host + "/javascripts/expressinstall.swf");
    video5.write("video5");

  });
  
  function close_hiw_video() {
    $('#video_content').fadeOut(1000, function(){
        $('#normal_content').fadeIn(500);
      });
  }

/* ******************************** */
/*  DazzleDeals Modal pop-up        */
/* ******************************** */

function DDModalInit(deal_id, deal_end_date, deal_sold_out){
  if (!deal_sold_out) {
    $('div#dd_bar_clock_modal').countdown({
      until: $.countdown.UTCDate( null, deal_end_date ),
      compact: true,
      format: 'hMS',
      layout: '{hnn}{sep}{mnn}{sep}<span id="dd_seconds_modal">{snn}</span>',
      expiryText: '<span id="dd_expired">00:00:00</span>'
    });
  }
  openDDModal();
  set_ddModal_cookie(deal_id);
}

function openDDModal(){
  closeDialog();
  $('#dd_modal_container_main').dialog('option', 'height', 417).dialog('option', 'width', 620).dialog({ dialogClass: 'borderless dazzledeal_modal' }).dialog('open');
}

/* cookie javascripts for windowshade */

function set_ddModal_cookie(deal_id)
{
	document.cookie="dazzle_deal_modal="+deal_id;
}


function get_ddModal_cookie(c_name,deal_id)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function check_ddModal_cookie(deal_id, deal_end_date, deal_sold_out)
{
cookie = 'dazzle_deal_modal'
has_ddModal_cookie=get_ddModal_cookie(cookie,deal_id); //check contents of cookie here

adjusted_end_date = $.countdown.UTCDate( null, deal_end_date )
now = new Date();

if (has_ddModal_cookie!=deal_id && now < adjusted_end_date && navigator.appVersion.indexOf("MSIE 6.")==-1) // does not have session cookie, Show the modal dialog.
  {
    DDModalInit(deal_id, deal_end_date, deal_sold_out);
  }
else
  {
    has_ddModal_cookie=deal_id; // do nothing. 
  }
}