﻿$(document).ready(function() {

if ($.browser.msie && $.browser.version <= 6 ) {
$("#titlebar div:first").css({"height" : "159px", "clip" : "rect(0px 970px 159px 0px)"});
};


$("#footerNav ul li").after("<li>&nbsp;|</li>");
$("#footerNav ul li:last").hide();
$("#address ul li#propertyName").after("<li>&nbsp;|&nbsp;</li>");
$("#address ul li#street").after("<li>&nbsp;|&nbsp;</li>");
$("#address ul li#zip").after("<li>&nbsp;|&nbsp;</li>");

// hide the RFP Parent. NOTE::::: RFP must be placed FIRST in navigation (after home).
$("#footerNav ul>li:nth-child(3)").hide();
$("#footerNav ul>li:nth-child(4)").hide();
$("#nav>ul>li:nth-child(2)").hide();

//add class to the last CTA
$("#ctaShell div:nth-child(3)").addClass("lastItem");

//add the address to the header. yuck.
$("#address li#street").clone().appendTo("#headerAddress ul");
$("#address li#city").clone().appendTo("#headerAddress ul");
$("#address li#state").clone().appendTo("#headerAddress ul");
$("#address li#zip").clone().appendTo("#headerAddress ul");
$("#address li#phone").clone().appendTo("#headerAddress ul");

//animate the CTAs
$("#ctaShell div").hover(
          function () {
               $(this).find(".widgetCTAimg").animate({ top: "16px" }, 200);
          },
          function () {
               $(this).find(".widgetCTAimg").animate({ top: "24px" }, 200);
          }
);

//give left margin to only the left CTAs in the content area
$("#content .widgetCTA:even").css({'margin-right' : '10px'});

//move the subnav into the right column. is it two column? or three column?
var findThirdCol = $(".threeColumn3");
if (findThirdCol.length<1) { $("#subNav").prependTo(".twoColumn2"); }
else { $("#subNav").prependTo(".threeColumn3"); }

//hide the sidenav
var findSubNavLI = $("#subNav ul  > li ");
if (findSubNavLI.length<1) {$("#subNav").css({'display' : 'none'}) };

//find height of secondary navigation UL and apply it to the BG
$("#nav ul li").mouseover(function(){
     var findSubULheight = $(this).find("ul").height();
     var subNavBGheight = findSubULheight + 30;
     $(this).find("ul").find(".subnavBG").css({"height" : subNavBGheight });
});





//floor plans awesomeness 
$(".floorPlanCollapse:even").css({'margin-right' : '10px'});
//floor plans awesomeness 
$.fn.pause = function(duration) {
    $(this).animate({ dummy: 1 }, duration);
    return this;
};

$(".floorPlanCollapse .openSesame").click(function(){

     $(this).parent().parent().animate({ width: "585px"}, 1500);
     $(this).parent().parent().find("h3").fadeOut("slow");
     $(this).parent().parent().find("p:not(.closeP)").fadeOut("slow");
     $(this).parent().parent().find("p.closeP").fadeIn("slow");
     $(this).parent().parent().find(".bgFloorPlans").animate({ height: "505px", width: "605px"}, 1500 );
     $(this).parent().parent().find(".floorPlanImg").animate({ 
          height: "400px", 
          width: "500px", 
          marginLeft: "30px", 
          marginTop: "20px"}, 1500 );
     
     /*var imgPath = $(this).parent().parent().find("img.floorPlanImg").attr("src");
     $("#content").append("<div id='hideMe'></div>");
     $("#hideMe").append("<scr" + "ipt>var planImage = '" + imgPath + "';var so = new SWFObject('files/templates/151/movable.swf', 'mymovie', '670', '580', '9');   so.addParam('allowFullScreen', 'true');           so.addVariable('furnPanelColor','0x6A6A6A');so.addVariable('toolsPanelColor','0x29627F');so.addVariable('furnTextColor','0xFFFFFF');so.addVariable('toolsTextColor','0xFFFFFF');so.addVariable('fpName','First Floor');so.addVariable('fpInfo','');so.addVariable('fpImage',planImage); so.write('moveswf');</scr" + "ipt><div id='moveswf'></div>");
     $(this).parent().parent().find(".closeP").before("<div class='furnishFp'><a href='#hideMe' rel='shadowbox;width=680;height=590'>Click Here to Furnish This Floorplan</a></div>");
     $(this).parent().parent().find(".furnishFp").pause(1600).fadeIn("slow");
     Shadowbox.setup();*/
     
});

$(".floorPlanCollapse a.closeSesame").click(function(){
     /*$("#hideMe #moveswf").remove();
     $("#hideMe").remove(); */
     $(this).parent().parent().animate({ width: "260px"}, 1500);
     $(this).parent().parent().find("p.closeP").fadeOut("slow");
     $(this).parent().parent().find(".furnishFp").fadeOut("slow").pause(1600).remove();
     $(this).parent().parent().find(".bgFloorPlans").animate({ height: "145px", width: "300px"}, 1500 );
     $(this).parent().parent().find(".floorPlanImg").animate({ 
          height: "90px", 
          width: "120px", 
          marginLeft: "0px", 
          marginTop: "0px"}, 1500 );
     $(this).parent().parent().find("h3").pause(1600).fadeIn("slow");
     $(this).parent().parent().find("p:not(.closeP)").pause(1600).fadeIn("slow");
     
});


//when hovering over a subnav menu item manually fire the main navs hyperlink hover so
     //that the nav images still show on sub nav hover
     $("#mainNavLinks > li > ul").hover(
          function()
          {
               $(this).parent().children().eq(0).trigger("mouseenter");
          },
          function()
          {
               $(this).parent().children().eq(0).trigger("mouseleave");
          }
     );


});