
// remap jQuery to $
(function($){


})(this.jQuery);



// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};



// catch all document.write() calls
(function(doc){
  var write = doc.write;
  doc.write = function(q){ 
    log('document.write(): ',arguments); 
    if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments);  
  };
})(document);











$(function() {
	//	Scrolled by user interaction
	$('#foo2').carouFredSel({
		prev: '#prev2',
		next: '#next2',
		items: 2,
		pagination: "#pager2",
		auto: false
	});

	//	Variable number of visible items with variable sizes
	$('#foo3').carouFredSel({
		width: 360,
		height: 'auto',
		scroll: 1,
		next: '#next3',
		prev: '#prev3',
		auto: false
	});

});


//Tooltip oproepen (http://onehackoranother.com/projects/jquery/tipsy/)
jQuery(document).ready(function() {
	$('a').tipsy(
	$.fn.tipsy.defaults = {
		delayIn: 0,      // delay before showing tooltip (ms)
		delayOut: 0,     // delay before hiding tooltip (ms)
		fade: true,     // fade tooltips in/out?
		fallback: '',    // fallback text to use when no tooltip text
		gravity: 's',    // gravity // nw | n | ne | w | e | sw | s | se | $.fn.tipsy.autoNS
		html: true,     // is tooltip content HTML?
		live: false,     // use live event support?
		offset: 0,       // pixel offset of tooltip from element
		opacity: 0.8,    // opacity of tooltip
		tooltiptitel: 'rev',  // attribute/callback containing tooltip text
		trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	});
	 
	$('img').tipsy(
	$.fn.tipsy.defaults = {
		delayIn: 0,      // delay before showing tooltip (ms)
		delayOut: 0,     // delay before hiding tooltip (ms)
		fade: true,     // fade tooltips in/out?
		fallback: '',    // fallback text to use when no tooltip text
		gravity: 'n',    // gravity // nw | n | ne | w | e | sw | s | se | $.fn.tipsy.autoNS
		html: true,     // is tooltip content HTML?
		live: false,     // use live event support?
		offset: 0,       // pixel offset of tooltip from element
		opacity: 0.8,    // opacity of tooltip
		tooltiptitel: 'alt',  // attribute/callback containing tooltip text
		trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	}); 
	
	$('label').tipsy(
	$.fn.tipsy.defaults = {
		delayIn: 0,      // delay before showing tooltip (ms)
		delayOut: 0,     // delay before hiding tooltip (ms)
		fade: true,     // fade tooltips in/out?
		fallback: '',    // fallback text to use when no tooltip text
		gravity: 's',    // gravity // nw | n | ne | w | e | sw | s | se | $.fn.tipsy.autoNS
		html: true,     // is tooltip content HTML?
		live: false,     // use live event support?
		offset: 0,       // pixel offset of tooltip from element
		opacity: 0.8,    // opacity of tooltip
		tooltiptitel: 'title',  // attribute/callback containing tooltip text
		trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	}); 
});


// lightbox oproepen (http://s3.envato.com/files/1423518/index.html)
jQuery(document).ready(function(){
  jQuery('.lightbox').lightbox();
});


//Slider functie
$(window).load(function() {
$('#home').orbit({
     animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
     animationSpeed: 800,                // how fast animtions are
     timer: true, 			 // true or false to have the timer
     advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
     pauseOnHover: false, 		 // if you hover pauses the slider
     startClockOnMouseOut: false, 	 // if clock should start on MouseOut
     startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
     directionalNav: false, 		 // manual advancing directional navs
     captions: false, 			 // do you want captions?
     captionAnimation: 'fade', 		 // fade, slideOpen, none
     captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
     bullets: true,			 // true or false to activate the bullet navigation
     bulletThumbs: false,		 // thumbnails for the bullets
     bulletThumbLocation: '',		 // location from this file where thumbs will be
     afterSlideChange: function(){} 	 // empty function 
});

$('.portfolio_slider').orbit({
     animation: 'horizontal-push',                  // fade, horizontal-slide, vertical-slide, horizontal-push
     animationSpeed: 800,                // how fast animtions are
     timer: false, 			 // true or false to have the timer
     advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
     pauseOnHover: false, 		 // if you hover pauses the slider
     startClockOnMouseOut: false, 	 // if clock should start on MouseOut 
     startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
     directionalNav: true, 		 // manual advancing directional navs
     captions: false, 			 // do you want captions?
     captionAnimation: 'fade', 		 // fade, slideOpen, none
     captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
     bullets: false,			 // true or false to activate the bullet navigation
     bulletThumbs: false,		 // thumbnails for the bullets
     bulletThumbLocation: '',		 // location from this file where thumbs will be
     afterSlideChange: function(){} 	 // empty function 
});});




$(function () {
	$('#main img').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
});

function doThis() {
	var imgs = $('img').length;//count the number of images on the page
	if (i >= imgs) {// Loop the images
		clearInterval(int);//When it reaches the last image the loop ends
	}
	$('img:hidden').eq(0).fadeIn(200);//fades in the hidden images one by one
	i++;//add 1 to the count
}


/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/

$(document).ready(function()
{
	var pageSize = 1;
	
	var username = 'mtmedianl';
	
	var currentPage = 1;
	
	var appendTweet = function(tweet, id) {
		$("<p />")
			.html(tweet)
		.appendTo($("#tweets"));
	};
	
	var loadTweets = function() {
		var url = "http://twitter.com/status/user_timeline/"
				+ username + ".json?count="+pageSize+"&page="+currentPage+"&callback=?";
				
		$.getJSON(url,function(data) {
			$.each(data, function(i, post) {
				appendTweet(post.text, post.id);
			});
			
			// We're done loading the tweets, so hide the overlay and update the UI
			$("#overlay").fadeOut();
			$("#pageCount").html(currentPage);
			$("#tweetCount").html(currentPage * pageSize);
		});
		
	};
	
	loadTweets();
	
	// Append a scroll event handler to the container
	$("#tweets").scroll(function() {
		// We check if we're at the bottom of the scrollcontainer
		if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) {
			// If we're at the bottom, show the overlay and retrieve the next page
			currentPage++;
			
			if(currentPage > 10) {
				alert('We should not spam the Twitter API with calls. I hope you get the idea!');
				return false;
			}
			
			$("#overlay").fadeIn();
			loadTweets();
		}
	});
	
});

function openDialog(t, w){
	if($(t).parent().hasClass("ui-dialog") && $(t).parent().is(":visible")){
		return;
	}
	if(w == null){
		$(t)
		.matoriaDialog();
	}else{
		$(t)
		.matoriaDialog({
			width: w
		});
	}
}



function setupLabel() {
	if ($('.label_check input').length) {
		$('.label_check').each(function(){ 
			$(this).removeClass('c_on');
		});
		$('.label_check input:checked').each(function(){ 
			$(this).parent('label').addClass('c_on');
		});                
	};
};
$(document).ready(function(){
	$('body').addClass('has-js');
	$('.label_check, .label_radio').click(function(){
		setupLabel();
	});
	setupLabel(); 
});




VideoJS.setupAllWhenReady();





