$(function(){		
	$('a.fancy').fancybox();
	
	$('.tabs .controls a').click(function(){
		$(this).closest('.tabs').find('.controls li').removeClass('active');
		$(this).parent().addClass('active');
		$(this).closest('.tabs').find('.tab').removeClass('active');
		$(this).closest('.tabs').find('.tab' + $(this).attr('data-tab')).addClass('active');
		return false;
	});
	
	/* TWITTER
	=======================================*/
	//load twitter messages
	function loadTweets(url) {
		//$('#twitter .loader').show();
		$.getJSON(url, function(response){
	  		var items = '<ul>',
	  			i = 0;
	  		$.each(response, function(index, value){
	  			items += '<li>@'+value.user.screen_name + ' &#8211; ' +value.text+'</li>';
	  			if(i >= 4){
	  				return false;
	  			}
	  			i++;
	  		});
	  		items += '</ul>';
	  		
	  		$('#twitter').html(items).formatTwitter();
	  		
	  		//$('#twitter.loader').hide();
	  	});
	};
	//loadTweets('http://api.twitter.com/1/lists/statuses.json?slug=Voetballers&owner_screen_name=voetbalbelgie&count=5&page=1&callback=?');
});

/* FORMAT TWITTER JQUERY EXTENSION
=======================================*/
(function($){
	var url1 = /(^|&lt;|\s)(www\..+?\..+?)(\s|&gt;|$)/g,
	url2 = /(^|&lt;|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$)/g,

	formatTwitter = function () {
		var childNodes = this.childNodes,
		i = childNodes.length;
        while(i--){
			var n = childNodes[i];
			if (n.nodeType == 3) {
				var html = $.trim(n.nodeValue);
				if (html){
					html = html.replace(/&/g, '&amp;')
                         .replace(/</g, '&lt;')
                         .replace(/>/g, '&gt;')
                         .replace(url1, '$1<a href="http://$2">$2</a>$3')
                         .replace(url2, '$1<a href="$2">$2</a>$5')
                         .replace(/(^|\s)@(\w+)/g, ' <a href="http://twitter.com/$2" target="_blank">@$2</a>')
      					 .replace(/(^|\s)#(\w+)/g, ' <a href="http://search.twitter.com/search?q=%23$2" target="_blank">#$2</a>');
             		$(n).after(html).remove();
            	}
          	}else if (n.nodeType == 1  &&  !/^(a|button|textarea)$/i.test(n.tagName)) {
            	formatTwitter.call(n);
          	}
     	}
  	};

	$.fn.formatTwitter = function () {
		return this.each(formatTwitter);
  	};
})(jQuery);


function photoPopup(theURL,winName,w,h) { 
h=100;
w=100;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,noresize,status=0'
win = window.open('/photo.php?id=' + theURL,winName,settings);
		}
		function ArticleForum(form) {
			if (form.title.value == '') {
				alert('Je bent een onderwerp vergeten');
				form.title.focus();
				return false;
			} else if (form.fulltext.value == '') {
				alert('Vergeet je reactie niet te schrijven...');
				form.fulltext.focus();
				return false;
			} else  {
				return true;
			}
		
		}
		function printPopup(id) { 
		w=600;
		h=500;
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,noresize,status=no'
		win = window.open('article_print.php?id=' + id,'print',settings);
		}
		
		
						function ftvlaunch(video,quality,pid) {
							  var LeftPosition = (screen.width) ? (screen.width-670)/2 : 0;
							  var TopPosition = (screen.height) ? (screen.height-500)/2 : 0;
							  var popwin = window.open('http://bongo.zoomin.tv/videoplayer/index.cfm?id='+video+'&quality='+ quality +'&pid='+ pid,'MTV6_window','toolbar=no,width=670,height=500,top='+TopPosition+',left='+LeftPosition+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
						      popwin.focus();
						}

					
