var global = {
	vars : {
		selectedCat : ''
	},
	safe_mail : function(name, domain, display) {
		var displayed = (typeof(display) == 'undefined') ? name + '@' + domain : display;
		document.write('<a ' + 'href=mailto:' + name + '@' + domain + '>' + displayed + '</a>');
	},	
	init : function() {

		if (!$.browser.msie) $('body').css('overflow-y', 'scroll');
		
		$(".box").jomino({
			interval: 200, 
			duration: 400, 
			easing: "easeInOutQuad", 
			autostart: true
		});
		
		// Showreel
		$(".showreel").fancybox({
			titleShow		: false,
			overlayOpacity  : '0.9',
			transitionIn	: 'elastic',
			transitionOut	: 'elastic',
			autoScale     	: false,
			type 			: 'iframe',
			padding			: 1,
			centerOnScroll  : true
		});
	
		// Flash
		$("a[href$=.swf]").fancybox({
			titleShow		: false,
			overlayOpacity  : '0.9',
			transitionIn	: 'elastic',
			transitionOut	: 'elastic',
			autoScale     	: false,
			type 			: 'swf',
			padding			: 1,
			centerOnScroll  : true
		});

		// QuickTime
		$("a[href$=.mov]").fancybox({
			titleShow		: false,
			transitionIn	: 'elastic',
			transitionOut	: 'elastic',
			overlayOpacity  : '0.8',
			overlayColor    : '#000',
			type 			: 'iframe',
			padding			: 1,
			centerOnScroll  : true
		});

		// Category Selector
		$('.categories a').bind('click', function() {
			var cat_name = $(this).attr('title');
			var cat_href = $(this).attr('href');
			
			if( $(this).is('.active') && (location.hash == cat_href)) {
				$(this).blur();
				return false;
			}
			$.each( $('.categories a'), function(k, v) {
				if ($(v).is('.' + cat_name)) {											 
					$(v).addClass('active');
				} else {
					$(v).removeAttr('class');
				}
			});
			
			$(this).addClass('active');
			pageTracker._trackPageview('/'+cat_name+'/');
			//global.vars.selectedCat = cat_name;
			
			//$.jomino.rewind();
			
			//location.hash = cat_href;
				
			
			$.each( $('.box'), function(k, v){
				if ($(v).is('.c_' + cat_name)) {
					$(v).show();
				} else {
					$(v).hide();	
				}
			});
			
			$(this).blur();
			return false;
		});
		
		
		//Horizontal Sliding
		$('.box.slideright').hover(function(){
			$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
		});
	
		
		//Full Caption Sliding (Hidden to Visible)
		$('.box.captionfull').hover(function(){
			$('.cover', this).stop().animate({top:'88px'},{queue:false,duration:160});
		}, function() {
			$('.cover', this).stop().animate({top:'260px'},{queue:false,duration:160});
		});

	}
};
$(document).ready(function() { global.init(); });

/*
$(document).ready(function() {

	// Bind the event.
	//$(window).bind( 'hashchange', function(){
	//	$("a[href$="+ location.hash +"]").trigger('click');
	//})
	
	//if (!location.hash) {
		$(".box").jomino({
			interval: 200, 
			duration: 500, 
			easing: "easeInOutQuad", 
			autostart: true, 						 
			onComplete : function() {
				//if (location.hash) {
				//	$("a[href$="+ location.hash +"]").trigger('click');
				//}
			}				 
		});
	//} else {
	//	$('.box').show(0, function() {
	//		$("a[href$="+ location.hash +"]").trigger('click');
	//	});	
	//}


	$(".showreel").fancybox({
		titleShow		: false,
		overlayOpacity  : '0.9',
		transitionIn	: 'elastic',
		transitionOut	: 'elastic',
		autoScale     	: false,
		type 			: 'iframe',
		padding			: 1,
		centerOnScroll  : true
	});


	// FLASH
	$("a[href$=.swf]").fancybox({
		titleShow		: false,
		overlayOpacity  : '0.9',
		transitionIn	: 'elastic',
		transitionOut	: 'elastic',
		autoScale     	: false,
		type 			: 'swf',
		padding			: 1,
		centerOnScroll  : true
	});
	
	/*
		$("a[href$=emmoglu.swf]").fancybox({
				titleShow		: true,
				transitionIn	: 'elastic',
				transitionOut	: 'elastic',
				overlayOpacity  : '0.8',
				overlayColor    : '#000',
				autoScale     	: false,
				transitionIn	: 'none',
				transitionOut	: 'none',
				padding: 2,
				width : 640,
				height: 426,
				type : 'swf'
		});
	// QUICKTIME
	$("a[href$=.mov]").fancybox({
		titleShow		: false,
		transitionIn	: 'elastic',
		transitionOut	: 'elastic',
		overlayOpacity  : '0.8',
		overlayColor    : '#000',
		type 			: 'iframe',
		padding			: 1,
		centerOnScroll  : true
	});


	$('.categories a').bind('click', function() {
		var cat_name = $(this).attr('title');
		var cat_href = $(this).attr('href');
		
		if( $(this).is('.active') && (location.hash == cat_href)) {
			$(this).blur();
			return false;
		}
		$.each( $('.categories a'), function(k, v) {
			if ($(v).is('.' + cat_name)) {											 
				$(v).addClass('active');
			} else {
				$(v).removeAttr('class');
			}
		});
		
		$(this).addClass('active');
		//location.hash = cat_href;
			
		$.each( $('.box'), function(k, v){
			if ($(v).is('.c_' + cat_name)) {
				$(v).fadeIn(1000);
			} else {
				$(v).hide();	
			}
		});		
		$(this).blur();
		return false;
	});
	
	
	//Horizontal Sliding
	$('.box.slideright').hover(function(){
		$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
	});

	
	//Full Caption Sliding (Hidden to Visible)
	$('.box.captionfull').hover(function(){
		$('.cover', this).stop().animate({top:'88px'},{queue:false,duration:160});
	}, function() {
		$('.cover', this).stop().animate({top:'260px'},{queue:false,duration:160});
	});

	/*
	$.preload(['01.jpg', '02.jpg', '03.jpg', '04.jpg', '05.jpg', '06.jpg', '07.jpg', '08.jpg', '09.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'], {
		base: 'img/',
		onFinish: function(){
			$(".loading").hide();
			$.jomino.forward();
		}
	});
	*/
	
	//$.jomino.forward();

	/*
	$.jomino.forward();
	
	$.jomino.stop();

	$.jomino.rewind();
	
		

});
*/
