var Global = {

	init: function(){
		this.initMenu();	
		this.initCufon();
		this.initFaq();
		this.initExternalLinks();
		this.initFancybox();
	},

	initCufon: function(){
		if($('#logo').length > 0 ){ 
			Cufon.replace('#logo', { fontFamily: 'arialroundedMT' });
		}
		if($('div.content h1').length > 0 ){ 
			Cufon.replace('div.content h1', { fontFamily: 'arialroundedMT' });
		}
		if($('div.homepage span.slogan').length > 0 ){ 
			Cufon.replace('div.homepage span.slogan', { fontFamily: 'arialroundedMT' });
		}
		if($('div.homepage .bBottom h2').length > 0 ){ 
			Cufon.replace('div.homepage .bBottom h2', { fontFamily: 'arialroundedMT' });
		}
		if($('div.homepage .homeSteun').length > 0 ){ 
			Cufon.replace('div.homepage .homeSteun', { fontFamily: 'arialroundedMT' });
		}
		if($('#sidebar h2').length > 0 ){ 
			Cufon.replace('#sidebar h2', { fontFamily: 'arialroundedMT' });
		}
	},
	
	initFaq: function() {
		// get all faqItems
		var aFaqItems = $('.faqItem');
		aFaqItems.click(function() {
			// are we currently opened?
			if ($(this).find('.faqAnswer').css('display') !== 'none') {
				// yes, close ourself
				$('.faqItem').find('.faqAnswer').hide('fast');
				$(this).blur();
				return true;
			}
			// close all opened faqItems
			$('.faqItem').find('.faqAnswer').hide('fast');
			$(this).find('.faqAnswer').show('fast');
			$(this).blur();
			return true;
		});
	},
	
	initExternalLinks: function() {
		$('a[rel=external]').attr('target', '_blank');
	},
	
	initFancybox: function() {
		//$('a.video').fancybox();
		var aVideos = $('a.video');
		aVideos.each(function() {
			// get the href
			var file = $(this).attr('href');
			
			// generate inline HTML
			
			//console.log(file);
			$(this).click(function() {
				return true;
				//return false; // preventdefault and stoppropagation
			});
			
		});
	},
	
	initMenu: function() {

		var elmMenuTrigger = $('#menu li.main');

		elmMenuTrigger.bind('mouseenter', function(){
				$(this).addClass('hover');
				$(this).find('.submenu').stop(true, true).slideDown('fast');
		});

		elmMenuTrigger.bind('mouseleave', function(){
				$(this).removeClass('hover');
				$(this).find('.submenu').stop(true, true).slideUp('fast');
		});

		
		$('#menu li.main li').mouseenter(function () { $(this).toggleClass('hover'); });
		$('#menu li.main li').mouseleave(function () { $(this).toggleClass('hover'); });
		 
	}
}

window.onload = function(){ 
	Global.init(); 
}

