/* Author: 4dsites.com
*  (c) copyright 2011 Soft Idiom Limited
*/

maxhector = {}; //namespace

maxhector.site = {
	
	menusVisible: !$.fn.superbgimage,
	animatingMenus: false,
	isTouch: 'touch',

	init: function(){
		maxhector.site.initSuperBigImage();
		maxhector.site.initMenus();
		maxhector.site.initTips();
		maxhector.site.enableViewportZoom();
	},
		
	enableViewportZoom: function() {
		$('#view').attr('content','maximum-scale = 1.6');
	},
	
	initTips: function(){
		$('#social li a').tipTip({delay:550, maxWidth: '80px', edgeOffset: 45, defaultPosition:'top', fadeOut:0});
	},
	
	isInternalPage: function(){
		return !$.fn.superbgimage; //only on home page
	},
	
	initSuperBigImage: function(){
		// Options for SuperBGImage
		if(maxhector.site.isInternalPage()) return;
		$.fn.superbgimage.options = {
			randomtransition: 0, // 0-none, 1-use random transition (0-7)
			transition: 1, // // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
			slideshow: 1, // 0-none, 1-autostart slideshow
			slide_interval: 3000, // interval for the slideshow
			randomimage: 0, // 0-none, 1-random image
			speed: 'slow' // animation speed
		};	
		// initialize SuperBGImage
		$('#thumbs').superbgimage().hide();
	},
	
	initMenus: function(){
		if(!maxhector.site.isInternalPage()) {
			$('#leftColumn').hover(function() { //mouse in
				maxhector.site.showMenus();
				maxhector.site.isTouch = false;
			}, function() { //mouse out
				maxhector.site.hideMenus();
			});
		}
		$('#logo').click(function(){
			maxhector.site.toogleMenus();
		});
		$('#social').hover(function(){
			$(this).animate({marginBottom:'8px'},300);
		}, function(){ //mouse out
			$(this).animate({marginBottom:'0px'},300);
		});
	},
	
	toogleMenus: function() {
		if(maxhector.site.menusVisible) {
				maxhector.site.hideMenus();
			} else {
				maxhector.site.showMenus();
		}
	},
	
	showMenus: function() {
		if(maxhector.site.animatingMenus) {
			return;
		}
		maxhector.site.animatingMenus = true;
		$('#leftColumn').animate({ height: '100%' }, 200);
		$('#filtering-nav').animate({ top: '30px',opacity:1 },200, function(){
			maxhector.site.animatingMenus = false;
			maxhector.site.menusVisible = true;
		});
		$('#social').fadeIn(100);
		$('#copyright').fadeIn(100);
		$('#portfolio').css('margin','0 0 0 330px');
		$('#portfolio').css('padding','30px 0');
		$('.wrap').masonry()
	},
	
	hideMenus: function() {
		if(maxhector.site.animatingMenus) {
			return;
		}
		maxhector.site.animatingMenus = true;
		$('#filtering-nav').animate({ top: '-200px',opacity:0 },200);
		$('#leftColumn').animate({ height: '55px' }, 100, function(){
			maxhector.site.animatingMenus = false;
			maxhector.site.menusVisible = false;
		});
		$('#social').fadeOut(100);
		$('#copyright').fadeOut(100);
		$('#portfolio').css('margin','0 0 0 50px');
		$('#portfolio').css('padding','100px 0 0 0');
		$('.wrap').masonry()
	}
	
}


$(function() {
	maxhector.site.init();
});


