$(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;
				   });

$(".show_more_options").bind("click",function(){
$(".tohide:visible").fadeOut("fast");
$(".tohide:hidden").fadeIn("fast");
var _4=$(this).html();
var _5=$(this).attr("rev");
$(this).html(_5).attr("title",_5).attr("rev",_4);
return false;
});			

$('.download_redirect').bind('click', function(){
			var iframe = $(document.createElement('iframe')).css({ width:0, height:0, border:'0px solid #FFFFFF'});
				iframe.attr('src', $(this).attr('href'));
				iframe.appendTo('body');
				return false;
		});	   		
});
