﻿Cufon.replace('#contentShell > #content h1, #contentShell h1, #nav ul li a, #contentShell > #content h2, .footerSlash, .fn, .street-address, .locality, .region, .postal-code, .tel>span, #footerNav li a, .socialToolbarLabel, #exclusiveOffers a', { hover: true, fontFamily: 'DIN-Medium' });
Cufon.replace('#condoListing > ul > li .condoTitle', {hover:true, fontFamily: 'DIN-Medium', textShadow:'0 1px #fff'});
Cufon.replace('#emailOffersBox > .title, #exclusiveOffers .title', {hover:true, fontFamily: 'DIN-Medium', textShadow:'0 1px #fff'});

$(document).ready(function(){

     $.fn.pause = function(duration) {
     $(this).animate({ dummy: 1 }, duration);
     return this;
     };
          
     //change out that ugly calendar icon.
     $("#checkoutCalendarIcon, #checkinCalendarIcon").attr("src", "files/templates/210/icoCal.gif");

     //group the telephones
     $("#address .adr").after("<div id='telContainer'></div>");
     $("#address .tel").appendTo("#telContainer");
     
     //hide the subnav
     var findSubNavLI = $("#subNav ul  > li ");
     if (findSubNavLI.length<1) {$("#subNav").remove() };
     
     Cufon.replace('#subNav li a');
     
     //handle external links
     //make a cool 'external' selector. exceptions: mailto: and javscript jazz
     $.expr[':'].external = function(obj){return !obj.href.match(/^mailto\:/)
     && !obj.href.match(/^javascript/) && !obj.href.match(/^http\:\/\/www.vizergy.com/) && 
     !obj.href.match(/^http\:\/\/www.secure-res.com/) && !obj.href.match(/^https\:\/\/www.secure-res.com/) && (obj.hostname != location.hostname);};
     
     //add the class "external", and add popup.
     $("body:not(#ctl00_body) #content a:external, a[href*=.pdf], a[href*=.doc], a[href*=.docx]").addClass("external").click(function(){window.open(this.href); return false;;})
     
     //add another class for specific file types
     $("#content a[href*=.pdf]").addClass("pdf");
     $("#content a[href*=.doc], a[href*=.docx]").addClass("doc");
     
     $("#content ul:not(.sitemapWidget):not(.noFloat):not(.dudeCondo)").each(function(){
          var liCount = $(this).children().size();
          if (liCount >= 6) {
               var firstList = this;
               $(firstList).wrap("<div class='colContainer'><div class='twoCols'></div></div>");
               
               var colContainer = $(firstList).parent().parent();
               $(colContainer).append("<div class='twoCols next'><ul></ul></div>");
               
               var secondList = $(".twoCols:last ul", colContainer);
               var secondListLIs = $(firstList).children().slice(Math.ceil(liCount/2));
               
               $(secondList).append(secondListLIs);
               $("div.colContainer").next().addClass("clear");
               if ($(".colContainer .twoCols ul.noStyle").length ) {
                    $(this).parent().parent().find(".twoCols.next ul").addClass("noStyle");
               }  
          };//close if nonsense

     }); //closing the each-thingy
     
     //for the condos page...
     $('body#pageid5832 #header').appendTo($('#contentShell'));
     
     
     
     
     
     //IE sucks. 
     if ( $.browser.msie ) { 
     
          Cufon.replace(".widgetCTA>a>.widgetCTAHeaders, .hiddenBlue");
          
          $("#nav>ul>li>ul>li").hover(
               function(){ $(this).find("ul").css("display", "block"); },
               function(){ $(this).find("ul").hide(); }
          );
     
          
     }
     else {
          $("#side2 .widgetCTA").each(function(){
               var ctaText = $(this).find("a .widgetCTAHeaders").text();
               $(this).append("<h1 class='hiddenBlue'></h1>");
               $(this).find(".hiddenBlue").hide();
               $(this).find(".hiddenBlue").append(ctaText);
          
          });
          $("#side2 .widgetCTA").hover(
               function(){ $(this).find("a").find("h1").slideUp('fast'); $(this).find(".hiddenBlue").slideDown('fast'); },
               function(){ $(this).find("a").find("h1").slideDown('fast'); $(this).find(".hiddenBlue").slideUp('fast'); }
               
          );
          
          $("#side .widgetCTA").each(function(){
               var ctaText2 = $(this).find("a .widgetCTAHeaders").text();
               $(this).append("<h1 class='hiddenBlue'></h1>");
               $(this).find(".hiddenBlue").hide();
               $(this).find(".hiddenBlue").append(ctaText2);
               
               Cufon.replace(".widgetCTA>a>.widgetCTAHeaders, .hiddenBlue");
          
          });
          $("#side .widgetCTA").hover(
               function(){ $(this).find("a").find("h1").slideUp('fast'); $(this).find(".hiddenBlue").slideDown('fast'); $(this).find("a .widgetCTADescription").css("color", "#fff"); },
               function(){ $(this).find("a").find(".widgetCTAHeaders").slideDown('fast'); $(this).find(".hiddenBlue").slideUp('fast'); $(this).find("a .widgetCTADescription").css("color", "#D2CAC4"); }
               
          );
          
          
          
           //refresh cufon on hover
          $("#nav>ul>li").hover(
               function(){ $(this).find("ul:first").hide().slideDown('fast'); $(this).find("ul:first li").hide().fadeIn(); },
               function(){ $(this).find("ul:first").show().fadeOut('fast'); }
          ); 
     
     }// end of if/else IE
     
     
     $("#nav ul li").hover(
          function(){ /*nada*/ },
          function(){ Cufon.replace("#nav ul li a");  }
     );
     
     $("#footerNavLinks li:not(.lastItem)").after("<li class='footerSlash'>/</li>");
          
     //$("body").show();
     
     
});
