UI = {
	fancybox: {
		init: function(){
			jQuery(".screens a").fancybox({
				'titlePosition'	: 	'over',
				'overlayColor':  	'#FFF',
				'overlayOpacity':  	0.65
			});
		}
	},
	subcontent: {
		getCurrentSection: function(){
			var location = String(window.location);
			var section = "";
			if(location.lastIndexOf("#") != -1){
				section = location.substring(location.lastIndexOf("#")+1);
			}
			return section;
		},
		switchToSection: function(section){
			jQuery("#topic_design, #topic_code").removeClass('selected');
			switch(section){
				case '#code':
				case 'code':
					jQuery('#subsections #design_items').hide();
					jQuery('#subsections #code_items').fadeIn();
					jQuery('#topic_code').addClass('selected');
					break;
				default:
					jQuery('#subsections #code_items').hide();
					jQuery('#subsections #design_items').fadeIn();
					jQuery('#topic_design').addClass('selected');
					break;
			}
		},
		init: function(){
			var section = UI.subcontent.getCurrentSection();
			UI.subcontent.switchToSection(section);
			
			jQuery("#topics div").hover(function(){
				jQuery(this).addClass('hover');
			},function(){
				jQuery(this).removeClass('hover');
			});
			
			jQuery("#topics a").click(function(e){
				var section = jQuery(this).attr('href');
				UI.subcontent.switchToSection(section);
			});
		}
	}
}

jQuery(document).ready(function(){
	UI.fancybox.init();
	UI.subcontent.init();
});
