$(document).ready(function() {
	 $.urlParam = function(name, url){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
    if (!results) { return 0; }
    return results[1] || 0;
  }; 
	
	$(".colorbox, .screenshot").colorbox();
	$(".screen").colorbox({iframe:true, innerHeight:function(){return $.urlParam('height', $(this).attr('href'))}, innerWidth:function(){return $.urlParam('width', $(this).attr('href'))}});	
	var licLinks = $(".wikilinks");
		$.each(licLinks, function(){
			this.href = this.href + '?ajax=true';
			$(this).colorbox({
				iframe:true, innerWidth:'80%', innerHeight:'70%'});
		});
	
		
		$('#download_win_btn, #download_mac_btn').hover(function(){
			var width = ($('.tooltip:first').width() > 0) ? $('.tooltip:first').width() : 253;
            var position = $(this).position();		
			var x = position.left + $(this).width() / 2 - width / 2 +'px';
			var y = position.top + $(this).height() +'px';			
			$(this).next('.tooltip').css({'left': x, top: y} ).show()},function(){$(this).next('.tooltip').hide()});
	$('.howto_items_link a').bind('click', function(){
				 var tab = $.urlParam('tab', $(this).attr('href'));
				  $('.howto_item:visible').fadeOut('fast', function(){$('#'+tab).fadeIn();});
				  
				  $('.howto_items_link a').removeClass('active');
				  $(this).addClass('active');				  
				   return false;
				   })		
});
