// HINYC JS
// Author: Georgios Athanassiadis

$(function(){
	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		 $('div#secret-code').live('click', function(){
			gris();
		});
	} else {
       
		$(document).cheatCode({
			code : '71,82,73,83',
			activated : function(){
				gris();
			}
		});
	}
	
	//Hover-events
	
	//Infodivar
	$('.infodiv', 'footer').hover(function(){
		$(this).animate({
		    top: '-=10px'
		  }, 100, function() {
		    $(this).find('.info-content').fadeIn();
		  });
	
	}, function(){
		$(this).animate({
		    top: ''
		  }, 100, function() {
		    $('.info-content', this).fadeOut();
		  });
		
	});
	
	//Infocontent dots
	$('li.dot-1', 'div.info-content').hover(function(){
		$(this).parent().parent().find('h3').text('Portfolio');
	}, 	
		function(){
			$(this).parent().parent().find('h3').text('');
		}
	);
	
	$('li.dot-2', 'div.info-content').hover(function(){
		$(this).parent().parent().find('h3').text('Twitter');
	}, 	
		function(){
			$(this).parent().parent().find('h3').text('');
		}
	);
	
	$('li.dot-3', 'div.info-content').hover(function(){
		$(this).parent().parent().find('h3').text('Facebook');
	}, 	
		function(){
			$(this).parent().parent().find('h3').text('');
		}
	);
});


//Functions

function gris(){
	
	$('div#curtain').fadeIn(3000, function(){
	
	scroll(0,0);
	
	//Switch stylesheet, insert new video and change some HTML-elements
	
		var htmlElement = 	'<object width="940" height="529"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12133493&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=12133493&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="940" height="529"></embed></object>';
		
		$('section#video').before(htmlElement).remove();

		
		$('h1', 'header').text('GRISINYC');
		$('img', '#secret-code').attr('src', 'assets/images/hinyc.backbutton.gris.png');
		$('#hinyc-style', 'html').attr('href', 'css/hinyc_gris.css');
		
		
		//Clickevent on backbutton
		$('#secret-code').live('click', function(){
			
			$('div#curtain').css('background-color', '#fff').fadeIn(3000, function(){
				window.location.reload()
			});
			
		})
		
		$('div#curtain').fadeOut(3000);
	});
	
}


