var launch = function(){

	// remove news block if there's no news in it
	if ($(".news .item").size() < 1) {
		$(".news").hide();
	}

	var blocks = [];

    var mx = 50;
    var y = 20;
	var xmin = 2 * mx;
	var xmax = $(window).width();
	var hmax = $(window).height();
    var ht = 0;
    var count = 0;
	
	var zztop = 1000;

	$(".block").each(function (i,e) {
	    ht += $(this).height();
	    count++;
	});
    var my = Math.floor((hmax - ht) / count);
    
    // console.log(hmax, ht, my);
    
	// position blocks randomly
	$(".block").each(function (i,e) {
		// make them draggable
        $(this).draggable();
        
        $(this).click(function(){
            $(this).css('z-index', zztop++);
        });

        x = xmin + Math.floor(Math.random()*(xmax - $(this).width() - xmin + mx)); // TODO fix margin
		$(this).hide();
		$(this).css("left", x).css("top", y);
		$(this).show();
		
		y += $(this).height() + Math.floor((Math.random() * my * 4));

		blocks.push(this);
	});
	
	// force links to target blank page
	$("a").each(function() {
		if ($(this).attr('class') !== 'top') {
			this.target = '_blank';
		}
	});

	// load sIFR
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({
			sSelector:"body h1", 
			sFlashSrc:"interface/sifr/sifr-davidg-medium.swf", 
			sColor:"#444444", 
			sLinkColor:"#000000", 
			sBgColor:"#FFFFFF", 
			sHoverColor:"#CCCCCC", 
			nPaddingTop:20, 
			nPaddingBottom:20, 
			sFlashVars:"textalign=left&offsetTop=0"
		}));
	};

}
