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] };

var userAgent = navigator.userAgent.toLowerCase();

if (!/chrome/.test(userAgent))
{
   sIFR.activate(fonts[0], fonts[1], fonts[2], fonts[3]);
   
   var wmode = (jQuery.browser.msie && (jQuery.browser.version >= 6 && jQuery.browser.version < 7)) ? '' : 'transparent';
   
   sIFR.replace(fonts[2], { selector: '#home-detail h1, #home .items li h1, #home .items li h2', css: '.sIFR-root { leading: -8; color: #ed008c; }, a { color: #ed008c; text-decoration: none; }, a:hover { color: #ed008c; text-decoration: underline; }', wmode: wmode });
   sIFR.replace(fonts[3], { selector: '#home-detail h2, #home .items li .subtitle', css: '.sIFR-root { color: #333333; }', wmode: wmode, tuneHeight: -5 });
}

$().ready(function() {
   $('#home .list .search form').validate();
   $('#home-detail .items li .media').each(function() {
   	var value = JSON.parse($(this).find('textarea').val());

   	switch (value.type)
      {
      	case 'youtube':
         
         	var url = value.url.split('?');
            var flash;

            if (url.length == 1) return;

            url = "http://www.youtube.com/v/" + url[1].slice(2) + "&hl=en_US&fs=1&";

            flash = new SWFObject(url, null, '100%', 340, '8', '#000000');
            flash.addParam('allowScriptAccess', 'always');
            flash.addParam('allowFullScreen', 'true');
            flash.addParam('wmode', 'transparent');
            flash.write(this);
 
         	break;
      }
   });
   $('#home .items a.retweet, #home-detail a.retweet').click(function() {
      jQuery.popup($(this).attr('rel'), 500, 350, false);
   });
   $('#home .items a.facebook, #home-detail a.facebook').click(function() {
      jQuery.popup($(this).attr('rel'), 630, 510, false);
   });

   $('.alert').each(function() { 
  		var message = $(this).html();

      if (message.length > 0) alert(message);
   });

   $('.captcha').each(function() {
   	Recaptcha.create('6LdbMAsAAAAAAAOdaEGD2OOth8UuaaLz9yc0wrpP', this, {
         theme: 'custom',
			lang: 'en',
         callback: function() { }
      });
   });
});