document.write('<style type="text/css">.jsshow { display: block; } .jshide { display: none; } .headline { visibility: hidden; } .headline .cufon { visibility: visible; }</style>');

// default easing
jQuery.easing.def = 'easeOutQuad';

// disable selection of text (used on tabs)
$.extend($.fn.disableTextSelect = function() {
	return this.each(function(){
		if ($.browser.mozilla) {
			$(this).css('MozUserSelect', 'none');
		} else if ($.browser.msie) {
			$(this).bind('selectstart', function() { return false; });
		} else {
			$(this).mousedown(function() { return false; });
		}
	});
});

var IMPLEMENT = {
  utils: {
    ie: false,
    init: function(funcs) {
      for (var i = funcs.length; i--;) {
        if (typeof funcs[i] !== 'undefined') {
          funcs[i].init();
        }
      }
    }
  },
  init: function() {
    if ($.browser.msie) {
      this.utils.ie = parseInt($.browser.version, 10);
    }
    
    this.utils.init([
			this.frontFlash,
      this.targets,
			this.relatedMaterial,
			this.videos,
			this.misc
    ]);
    
  },
	frontFlash: {
		init: function() {
			$('div.mFrontFlash').each(function() {
				var $this = $(this),
						meta = $.metadata.get(this);
						
				$this.flash({
					src: '/flash/slideshow.swf',
					width: 730,
					height: 230,
					allowfullscreen: true,
					flashvars: { xmlPath: meta.xml }
				},{
					version: '8',
					update: false
				});
				
				if(!$this.hasClass('flash-replaced')) {
					$this.find('img').show();
				}
				
			});
		}
	},
	targets: {
    init: function() {
      $('.target').live('click', function(e) {
        if (e.button === 0) {
          var $link = $(this).find('a:last');
          if ($link.length > 0) {
            var href = $link.attr('href');
            if (href) {          
              if ($link.attr('target') === '_blank') {
                window.open(href);
              } else {
                document.location = href;
              }
              return false;
            }
          }
        }
      });      
    }
  },
	relatedMaterial: {
		init: function() {
			$('div.mRelatedMaterial h3').disableTextSelect().mousedown(function() {
				var $li = $(this).parents('li:first');
				
				if($li.hasClass('active')) {
					$li.removeClass('active').find('div.content').slideUp(200);
				} else {
					$li.addClass('active').find('div.content').slideDown(300);
					$li.siblings('li.active').removeClass('active').find('div.content').slideUp(200);
				}
			}).find('a').mousedown(function() { return false; });
		}
	},
	videos: {
		init: function() {
			$('div.mVideoplayer').each(function() {
				var $this = $(this),
						meta = $.metadata.get(this);
				
				$this.find('div.bd').flash({
					src: '/flash/videoplayer.swf',
					width: 466,
					height: meta.height,
					allowfullscreen: true,
					flashvars: { streamPath: meta.flv, streamImagePath: meta.img, stageHeight: meta.height }
				},{
					version: '8',
					update: false
				});
						
			});
		}
	},
	misc: {
		init: function() {
			$('span.value').each(function() {
        var $this = $(this),
            $label = $this.find('label'),
            $inp = $this.find('input');

        if($inp.val() !== '') { $label.hide(); }
        $label.mousedown(function() { $inp.parents('fieldset:first').find('input').blur().end().end().focus(); });
        $inp.bind('focus change keydown', function() { $label.hide(); });
        $inp.blur(function() { if($inp.val() === '') { $label.show(); }});
      });

			// print
      $('.print').click(function() {
        window.print();
      }).disableTextSelect();
		}
	}
};

$(function() {
  IMPLEMENT.init();
});