var Site = {
	run: function() {
		jQuery('body').addClass('js-enabled');
		this.remove_focus(); // remove link focus
	},
	
	remove_focus: function() {
		jQuery('.remove-focus a, a.remove-focus').focus(function() {
			this.blur();
		});
	}

};

/**
 * include this script will call Site.run automatically.
 */
jQuery(function() {
	Site.run();
});

var Home = {
	run: function() {
		this.YoutubePanel.run();
	}
};

Home.YoutubePanel = {
	run: function() {
		this.div = jQuery('.youtube-panel');
		this.dialog = jQuery('.video-dialog');
		
		this.handle_play();
		this.handle_close();
	},
	
	handle_play: function() {
		jQuery('.play-video', this.div).click(function() {
			var data = jQuery(this).parent().find('.viedo-data').val();
			TFT.Ext.VBW.PlayYouTubeVideo(data,500,375);
			jQuery('.video-dialog').show();
			
			
			//center
			var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      
      var h = window.pageYOffset ||
      document.body.scrollTop ||
      document.documentElement.scrollTop;
      myHeight = myHeight + h;
      
      
      msgbox = document.getElementById("video-dialog");
      offsetWidthNew = msgbox.offsetWidth+260; //right box
      
      var x = (myWidth / 2) - (offsetWidthNew / 2);
      var y = (myHeight / 2) + (msgbox.offsetHeight / 2); 
      y = y + 50;
      //centering
      jQuery('.video-dialog').css({
      "position": "absolute",
      "top": y,
      "left": x
      });
      
      jQuery('#overlay-background').show();
			
			
			return false;
		});
	},
	
	handle_close: function() {
		jQuery('.close-dialog', this.dialog).click(function() {
			jQuery('#youtubeplayer').html('');
			jQuery('.video-dialog').hide();
			jQuery('#overlay-background').hide();
			return false;
		});
	}
	
};


var Article = {
	run: function() {
		this.hide_download_nessary();
	},
	
	hide_download_nessary: function() {
		var panel = jQuery('.digital-press');
		var download_panel = jQuery('.acrobat-reader-download');
		if (jQuery('.fmt-text,.fmt-pdf', panel).length == 0) {
			download_panel.hide();
		}
	}
};


