window.global = Backbone.View.extend({
	el: $("body"),
	events: {
	},	
	vendors: ["jqcycle","fancybox"],
	initialize: function(){ var _this = this; munstro.load_vendors(this.vendors, function(){ _this.__construct(); }); },
	
/*
 * Constructor
 */
	__construct: function(){
		var _this = this;
		$(".press_release").fancybox({
			'type': 'iframe',
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'width': 500,
			'height': 400,
			'padding':10
		});			
		$(".popup").fancybox({
			'type': 'iframe',
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'width': 500,
			'height': 300,
			'padding':10
		});	
		$(".fancybox").fancybox({
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'cyclic': true
		});	
	 
		// Get the index of the show element
		start = 0;
		element = $(".show");
		index = $('.links').index(element);
		if(index != -1) start = index;
		
		// Append click events
		try{
			$('.sub_navigation .container').cycle({ 
				fx: 'scrollHorz',
				start: 0,
				speed:  500, 
				timeout: 0,
				next:   ".right_arrow", 
				prev:	".left_arrow",
				startingSlide: start
			});
		}catch(err){ }
		
		// Check window at load
		this.check_window();
		
		$(window).resize(function(){
			_this.check_window();
		});
	},
	
/**
 * Expand or de-expand a layer
 */		
	expand: function(id){
		if($("#" + id).css("display") == "none")$("#" + id).slideDown();
		else $("#" + id).slideUp();
	},

/**
 * Check Window Size
 */	
	check_window: function(){
		if($(window).height() < 450){
			if ( $.browser.msie ) {
				$(".utility_belt").show();
			}else{
				$(".utility_belt").fadeIn(1000);
			}
			$(".utility_belt").css({
				position:"relative"
			})
		}else{ 
			if ( $.browser.msie ) {
				$(".utility_belt").show();
			}else{
				$(".utility_belt").fadeIn(1000);
			}
			$(".utility_belt").css({
				position:"fixed"
			});
		}
	},
	
/**
 * Init height check
 */		
	init_height: function(debug_mode){
		this.check_height();
		$(window).resize(function() {
			if(debug_mode){
				document.title = $(window).height();
			}
			window._global.check_height();
		});
	},
	
/**
 * Init height check
 */		
	init_height2: function(debug_mode){
		this.check_height2();
		$(window).resize(function() {
			if(debug_mode){
				document.title = $(window).height();
			}
			window._global.check_height2();
		});
	},		
	
/**
 * Check height
 */			
	check_height: function(){
		var height = $(".scribe_background").attr("min-height");
		if($(window).height() < height){
			$(".scribe_background").css({
				position: "absolute",
				top: 0,
				bottom: "auto"
			});
		}else{
			$(".scribe_background").css({
				position: "fixed",
				top: "auto",
				bottom: 0
			});
		}
	},
	
/**
 * Check height
 */			
	check_height2: function(){
		var height = $(".scribe_background").attr("min-height");
		if($(window).height() < height){
			$(".scribe_background").css({
				position: "fixed",
				top: "auto",
				bottom: "auto"
			});
		}else{
			$(".scribe_background").css({
				position: "absolute",
				bottom:0,
				top: "auto"
			});
		}
	}		
});
var _global = new window.global;

