var wmode = (jQuery.browser.msie && (jQuery.browser.version >= 6 && jQuery.browser.version < 7)) ? '' : 'transparent';
var fonts;

fonts = [];
fonts[0] = { src: 'http://www.miamiadschool.com/assets/swf/fonts/sifr3/futura-extra-bold.swf', ratios: [8, 1.41, 11, 1.31, 15, 1.29, 25, 1.25, 28, 1.23, 32, 1.22, 33, 1.23, 39, 1.22, 51, 1.21, 54, 1.2, 55, 1.21, 91, 1.2, 93, 1.19, 94, 1.2, 95, 1.19, 96, 1.2, 98, 1.19, 100, 1.2, 109, 1.19, 110, 1.2, 114, 1.19, 115, 1.2, 1.19] };
fonts[1] = { src: 'http://www.miamiadschool.com/assets/swf/fonts/sifr3/helvetica-neue-medium-condensed.swf', ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01] };
fonts[2] = { src: 'http://www.miamiadschool.com/assets/swf/fonts/sifr3/futura-boo.swf', ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 21, 1.2, 26, 1.21, 27, 1.2, 35, 1.19, 48, 1.18, 53, 1.17, 54, 1.18, 77, 1.17, 79, 1.16, 81, 1.17, 86, 1.16, 87, 1.17, 1.16] };
fonts[3] = { src: 'http://www.miamiadschool.com/assets/swf/fonts/sifr3/helvetica-neue-bold-condensed.swf', ratios: [6, 1.09, 7, 1.07, 8, 1.06, 16, 0.99, 25, 0.97, 35, 0.94, 38, 0.91, 50, 0.92, 76, 0.91, 77, 0.9, 78, 0.91, 79, 0.9, 81, 0.91, 89, 0.9, 90, 0.91, 0.9] };

sIFR.activate(fonts[0], fonts[1], fonts[2], fonts[3]);
sIFR.replace(fonts[0], { selector: '#bottom h1', css: '.sIFR-root { color: #ed008c; text-align: center;}', wmode: wmode, tuneHeight: -10 });
sIFR.replace(fonts[1], { selector: '#top .info h2', css: '.sIFR-root { color: #555555; }', wmode: wmode, tuneHeight: -8 });
sIFR.replace(fonts[0], { selector: '#contact strong.title', css: '.sIFR-root { color: #ed008c; text-align: center; }', wmode: wmode, tuneHeight: -8 });

$().ready(function() {
	var $input;

   $('#bottom .form form').validate({
   	submit: function(valid) {
         var value = $('#bottom .form input[name=referral]:checked').val();
         var $input = $('#bottom .form input[name=referral-other]');
			var error = (value == 'other' && $input.val() == '');

         $input.toggleClass('error', error);
         
         if (!valid || error) return;

         this.submit();
      }
   });
   
   $input = $('#bottom .form input[name=discount]');
   $input.bind('click change', function() {
      var checked = $(this).attr('checked');
   	var $element;
   
   	$element = $('#bottom .form .prices label em');
   	$element.toggleClass('active', checked);
      $element.each(function() {
      	var $input = $(this).parent().prev();
      	var price = parseInt($input.attr('rel'), 10);
         
         if (checked) price *= 0.90;

			$input.val(price);
			$(this).html(price);
         $(this).format({ format: '$#,###' });
      });
   });
   
   $input.trigger('change');
});
