$(document).ready(function(){

  if($.cookie("wasatch_corp_bgImg")) {
    var imgCookieLink = $.cookie("wasatch_corp_bgImg");  
    $("body").css("background-image", "url('" + imgCookieLink + "')");
  } else {
  
  $("body").css("background-image", "url(/themes/wasatch/shared/images/bg/body-bg-04.jpg)");
  
  }

 // Since xhtml strict doesn't allow _blank open external links in a new window this way

  $(function() {
  	$('a[rel*=external]').click( function() {
  		window.open(this.href);
  		return false;
  	});
  });

  // Chat now window
  
  $(function() {
    $('a.chat_window').click( function() {
      window.open(this.href, "chat", "width=475,height=400,modal=yes,alwaysRaised=yes");
      return false;
    });
  });


//***********************************

  $(function(){    
    $("#bg_selector a").click(function() {
      var imgLink = $("img", this).attr("src");
      $.cookie("wasatch_corp_bgImg", "" + imgLink + "", { path: '/', expires: 365 });
      var imgCookieLink = $.cookie("wasatch_corp_bgImg");       
      $("body").css("background-image", "url('" + imgCookieLink + "')"); 
      return false;
    });  
  });

//***********************************
// Initiate Crossfading Slideshow
 
  $.preload( '#slideshow img', {
    onFinish: function() {
      $('#slideshow img').removeClass('gone');
      $('#slideshow').slideshow({ timeout: 4000, fadetime: 600, type: 'sequence' });
    }
  });

  //***********************************

  $.preload( '#bg_selector li a img', {
    onFinish: function() {
      $('#bg_selector li a img').removeClass('gone');

      $('#bg_selector').jcarousel({
        scroll: 1,
        animation: 150,
        wrap: "both"
      });
    }
  });


//***********************************

  $("a[rel='cbox']").colorbox();
  
  // Walkscore colorbox
  $(".cboxwalkscore").colorbox({width:"540px", height:"356px", inline:true, href:"#thewalkscore"});
  
//***********************************

  $("div.floorplan_brochure a.printbutton").click(function(){
    $(this).parent().parent().parent().parent().jqprint();
    return false;
  });

//***********************************


//***********************************

}); // end