//jQuery init
$(function() {

    // don't use _blank in xhtml
    $("a[rel=\"external\"]").click(function() {
        this.target = "_blank";
      });
    
    // set up facebox plugin
    $("a[rel*=facebox]").facebox();

    // menu drop down on hover
    $("#nav > li ul").hide();
    $("#nav > li").hover (
      function() {
        //$(this).children('ul').slideDown("fast");
        $(this).children('ul').show();
      },
      function() {
        //$(this).children('ul').slideUp("fast");
        $(this).children('ul').hide();
      }
    );

    // slide or fade in header images, quick browsers only
    if ($.support.opacity) {
      $("#headerpic #crop").effect("slide", {direction:"left"}, 1500);
      //$("#headerpic #crop").hide();
      //$("#headerpic #crop").fadeIn(6000);
    }
    
    // homepage accordion and flash includes
    if ($("body#home").length) {
      $("#accordion").accordion({autoHeight:false});
      var flashvars = {};
      var params = {wmode:"transparent"};
      var attributes = {};
      //these are pretty heavy, the accordion may struggle with the flash enabled here.
      //swfobject.embedSWF("flash/Home-sidebar-featured.swf", "featured_image", "160", "75", "9.0.0","expressInstall.swf", flashvars, params, attributes);
      //swfobject.embedSWF("/templates/1521/includes/flash/Home-sidebar-video.swf", "video_image", "160", "75", "9.0.0","expressInstall.swf", flashvars, params, attributes);
    }
    
    // floorplans flash includes
    if ($("body#the-homes").is(".floorplans")) {
      var flashvars = {};
      var params = {wmode:"transparent"};
      var attributes = {};
      swfobject.embedSWF("flash/floorplan.swf", "floorplans", "675", "700", "9.0.0","expressInstall.swf", flashvars, params, attributes);
    }
    
    // validate long reg form, don't clutter markup with {stupid|useless} asterisks
    if ($("body#registration").is(".page-25")) {
      $("input.required,select.required").prev('label').append("<span> *</span>");
      $("label span").css({'color':'#CCB77C'});
      $("#long_registration").validate();
    }

  });

//sIFR config
  var gill = { src: 'flash/gill_sans_mt.swf' };
  sIFR.activate(gill);

sIFR.replace(gill, {
  selector: '#main-content h2,#sidebar h2,#media-room #sidebar h3',
  css: '.sIFR-root { font-size:16px;color:#FFFFFF;text-transform:uppercase;letter-spacing:2.2;line-height:1;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#home #main-content h4',
  css: '.sIFR-root { font-size:12px;color:#FFFFFF;text-transform:uppercase;text-align:left;letter-spacing:1.0;line-height:1;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#home #main-content h5.quote',
  css: '.sIFR-root { font-size:14px;color:#FFFFFF;text-transform:uppercase;letter-spacing:2.2;line-height:1;text-align:center;cursor:pointer;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#home #main-content h5.body',
  css: '.sIFR-root { font-size:15px;color:#FFFFFF;text-transform:uppercase;letter-spacing:4.5;line-height:24px;text-align:center;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#home #main-content p.body',
  css: '.sIFR-root { font-size:15px;color:#FFFFFF;letter-spacing:2.5;line-height:24px;text-align:center;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#home #main-content h5.headline',
  css: '.sIFR-root { font-size:20px;color:#CCB77C;text-transform:uppercase;letter-spacing:2.1;line-height:1;text-align:center;}',
  wmode: 'transparent'
});

sIFR.replace(gill, {
  selector: '#articles_header h3',
  css: '.sIFR-root { text-align:center;color:#FFFFFF;text-transform:uppercase;line-height:1;}',
  wmode: 'transparent'
});
sIFR.replace(gill, {
  selector: '#main-content h3,#media-room #main-content h4,#tooltip h3',
  css: '.sIFR-root { font-size:14px;color:#CCB77C;text-transform:uppercase;line-height:1;}',
  wmode: 'transparent'
});

//legacy js to support flash floorplans
aWidth=screen.availWidth
aHeight=screen.availHeight

cenWidth  = ((screen.availWidth/2) - (aWidth/2));
cenHeight = ((screen.availHeight/2) - (aHeight/2));

var winWidth = screen.availWidth;
var winHeight = screen.availHeight;


function checkSize() {

  //alertSize();

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

function openMain(sDirect,sText) {
  //alert('sDirect: ' + sDirect);
  //aWindow=window.open(sDirect,"mainWin","width=" + winWidth + ",height=" + winHeight + ",menubar=0,status=0,toolbar=0,scrollbars=0,resizeable=0,screenX=" + cenWidth + ",screenY=" + cenHeight + ",left=" + cenWidth + ",top=" + cenHeight);
  aWindow=window.open("single.php?sDirect="+sDirect+"&sText="+sText,"mainWin","width=" + winWidth + ",height=" + winHeight + ",menubar=0,status=0,toolbar=0,scrollbars=0,resizeable=0,screenX=" + cenWidth + ",screenY=" + cenHeight + ",left=" + cenWidth + ",top=" + cenHeight);
}

function openUnitsSWF(sSWF) {
  //alert('sSWF: ' + sSWF);
  aWindow=window.open(sSWF,"mainWin","width=" + myWidth + ",height=" + myHeight + ",menubar=0,status=0,toolbar=0,scrollbars=0,resizeable=0,screenX=" + cenWidth + ",screenY=" + cenHeight + ",left=" + cenWidth + ",top=" + cenHeight);
}// JavaScript Document