$(document).ready(function(){
   initializepromo();
   initializenav();
   interiorpageinteraction();
   Cufon.now();
   textresize();
   accessibilitycheck();
});


function initializepromo() {

   if ($('.planphx').children('div').hasClass('home')) {
      whathaveigottoworkwithhere = $('#belfry a.promo').width();
      $('#belfry a.promo em.question').css({'width': whathaveigottoworkwithhere - 250});
   
      $(window).resize(function() {
         whathaveigottoworkwithhere = $('#belfry a.promo').width();
         $('#belfry a.promo em.question').css({'width': whathaveigottoworkwithhere - 250});
      }); //resize
   } else if ($('.planphx').children('div').hasClass('interior')) {
      whathaveigottoworkwithhere = $('#belfry').width();
      $('#belfry div.pagetitlecontainer').css({'width': whathaveigottoworkwithhere - 180});
   
      $(window).resize(function() {
         whathaveigottoworkwithhere = $('#belfry').width();
         $('#belfry div.pagetitlecontainer').css({'width': whathaveigottoworkwithhere - 180});
      }); //resize
   } //if

} //initializepromo

function initializenav() {

   navwidth = $('div.nav').width();
   if (navwidth >= 750) {
      $('div.nav p a').css({'fontSize': '110%'});
   } //if
   if (navwidth >= 850) {
      $('div.nav p a').css({'fontSize': '120%'});
   } //if
   if (navwidth >= 950) {
      $('div.nav p a').css({'fontSize': '130%'});
   } //if
   if (navwidth >= 1050) {
      $('div.nav p a').css({'fontSize': '140%'});
   } //if

} //initializenav


function interiorpageinteraction() {
    $('.planphx .interior .contentproper h3 a').hover(
      function () {
         $(this).parent('h3').animate({'backgroundPosition': '(0px 0px)'}, 200);
      }, 
      function () {
         $(this).parent('h3').animate({'backgroundPosition': '(0px 10px)'}, 200);
      }
    );
} //interiorpageinteraction

function textresize() {
   $('li.txt-size').children('a').click(function() {
      Cufon.replace('em.question, .home .contentproper .section a', {hover: true, fontFamily: 'futurabold'});
      Cufon.replace('div.nav p a, .home .contentproper h3', {hover: true, fontFamily: 'futurabook'});
      Cufon.replace('#belfry h3, .interior .contentproper h3', {hover: true, fontFamily: 'futuralight'});

      accessibilitycheck();
   }); //click
} //textresize




function accessibilitycheck() {

    if ($.browser.msie && $.browser.version < 7) {
       $('#belfry a.promo').css({'fontSize': '11px'});
    } else {
      $('#belfry a.promo').removeClass('squishedpromo');
         $('#belfry a.promo').css({'height': 'auto'});
         $('#belfry a.promo').children('em.question').css({'backgroundImage': 'url(/webcms/groups/internet/@inter/@citygov/@future/@planphx/documents/web_content/promoleft.png)'});
         $('#belfry a.promo').children('em.tellus').css({'backgroundImage': 'url(/webcms/groups/internet/@inter/@citygov/@future/@planphx/documents/web_content/promoright.png)'});
         $('#belfry a.promo').children('em.tellus').css({'marginTop': '0px'});
      howtallisthehomepagequestion = $('em.question').height();
      if(howtallisthehomepagequestion > 82) {
         $('#belfry a.promo').addClass('squishedpromo').css({'height': howtallisthehomepagequestion+50});
         $('#belfry a.promo').children('em').css({'backgroundImage': 'none'});
         $('#belfry a.promo').children('em.tellus').css({'marginTop': howtallisthehomepagequestion+30});
      } //if the homepage question is too tall

   } // if not ie6



   $('.planphx .home').children('.contentproper').children('.section').children('a').css({'fontSize': '90%'});
   Cufon.replace('em.question, .home .contentproper .section a', {hover: true, fontFamily: 'futurabold'});
   howtallarethelearnmorebuttons = $('.planphx .home').children('.contentproper').children('.section').children('a').height();
   if (howtallarethelearnmorebuttons > 38) {
      $('.planphx .home').children('.contentproper').children('.section').children('a').css({'fontSize': '80%'});
      Cufon.replace('em.question, .home .contentproper .section a', {hover: true, fontFamily: 'futurabold'});
   } //if the learn more buttons are too tall



   $('div.nav').removeClass('stacked');
   $('div.nav').children('p').each( function(i) {
      howwideami = $(this).width();
      howwidearemykids = $(this).children('a').children('span:first-child').width() + $(this).children('a').children('span:first-child').siblings('span').width();
      if (howwidearemykids > howwideami-5) {
         $(this).parent('div.nav').addClass('stacked');
      }
   }); //each



   $('.contentproper.squished').removeClass('squished');
   $('.planphx .home').children('div.contentproper').children('div.section').children('h3').each( function(i) {
      howwideismychildspan = $(this).children('span').width();
      if (howwideismychildspan > $(this).width()-70) {
         $(this).parent('.section').parent('.contentproper').addClass('squished');
      }
   }); //each





   if ($('#belfry').children('a.logo').height() > $('#belfry').children('.pagetitlecontainer').height()) {
      $('.planphx .interior').children('#belfry').css({'height': $('#belfry').children('a.logo').height()});
   } else {
      $('.planphx .interior').children('#belfry').css({'height': $('#belfry').children('.pagetitlecontainer').height()});
   } //if logo is taller vs. if page title/description is taller



   
   $('.planphx .interior').children('#belfry').children('.pagetitlecontainer').children('h3').removeClass('squishedtitle');
   if ($('.planphx .interior').children('#belfry').children('.pagetitlecontainer').children('h3').children('span').width() > $('.planphx .interior').children('#belfry').children('.pagetitlecontainer').children('h3').width() ) {
      $('.planphx .interior').children('#belfry').children('.pagetitlecontainer').children('h3').addClass('squishedtitle');
   } //if

} //accessibilitycheck





