function tabClick ( index ) {
    switch(index) {
        case 2:
            $('div#content_solutions').hide();
            $('div#content_markets').show();
            break;
        case 1:
            $('div#content_markets').hide();
            $('div#content_solutions').show();
            break;
    }
}

// support for flash mediaplayer
function resizeFlash(width) {
	document.getElementById("mediaplayer_placeholder").style.width = parseInt(width) +"px";
}

function setFlashMediaPlayerHeight(height) {
	document.getElementById("mediaplayer_placeholder").style.height = parseInt(height) +"px";
}

$(function(){
    Shadowbox.init({handleOversize:'drag', flvPlayer: '/flash/player.swf'});

	// Replace img PNG's in IE6
	if ($.browser.msie && $.browser.version < 7) {
		$('img[src$=.png]').each(function(){
			$(this).css({
				filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"')"
			});
			this.src = 'images/blank.gif';
		});
	}
	
	$('img#tab_solutions').click(function(){
		$(this).attr('src','images/tab_solutions2.gif').removeClass('activetab');
		$('img#tab_markets').attr('src','images/tab_markets1.gif').addClass('activetab');
		tabClick(1);
	});
	$('img#tab_markets').click(function(){
		$(this).attr('src','images/tab_markets2.gif').removeClass('activetab');
		$('img#tab_solutions').attr('src','images/tab_solutions1.gif').addClass('activetab');
		tabClick(2);
	});
	var labels=[];
    $('#home_tabs_flash_container img').each (function (i, img) {
       labels[i]= img.getAttribute('alt');
    });
    swfobject.embedSWF(__tab_swf, "home_tabs_flash_container", 500, 28, "7.0.0", "", {
       label1: labels[0],
       label2: labels[1],
       active: 1
    }, {
       wmode:'transparent'
    }); 

	// Enable autoslider (then hide second tab, or that slider doesn't get activated)
	$('div.autoslider').autoslider();
	
	tabClick(1);

	// Read more links
	$('div#content_extra').hide();
	$('a[rel=openextra]').click(function(){
		$('div#content_extra').show();
		$(this).hide();
		return false;
	});
	// beetje dirty dat ik er hier vanuit ga dat er maar 1 read more per pagina is
	// maar goed, dat is hierboven ook ;) (G)
	$('a[rel=closeextra]').click(function(){
		$('div#content_extra').hide();
		$('a[rel=openextra]').show();
		return false;
	});

	// Searchbox
	$('input#search').each(function(){
		$(this).attr('defaultvalue',this.value);
	}).focus(function(){
		if(this.value == $(this).attr('defaultvalue'))
			this.value = '';
	}).blur(function(){
		if($.trim(this.value) == '')
			this.value = $(this).attr('defaultvalue');
	});

	// FAQ
	$('ul.faq dd, ul.faq dl').hide();
	$('ul.faq li div').click(function(){
		$('dl',$(this).parent()).toggle();
	}).hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});
	$('ul.faq dt').click(function(){
		$(this).next().toggle();
	}).hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});

	// Proposition
	var h1 = $('div#proposition h1').text();
	var h2 = $('div#proposition h2').text();
	var h3 = $('div#proposition h3').text();
	
	var flashvars = {};
	var flashheight = 0;
	
	if (h1) { flashvars.line1 = encodeURIComponent(h1); flashheight += 35 };
	if (h2) { flashvars.line2 = encodeURIComponent(h2); flashheight += 20 };
	if (h3) { flashvars.line3 = encodeURIComponent(h3); flashheight += 20 };
	
	if (flashheight) {
		$('div#propflash').css('height',flashheight);
		swfobject.embedSWF(__proposition_swf, "propflash", 550, flashheight, "9.0.0", "", flashvars, {
			wmode: 'transparent',
			menu: 'false'
		});
	}

	// Music Player
	$('img#banner_home').parent().click(function(){
		var popup = window.open (this.href, 'player', 'menubar=0,scrollbars=0,toolbar=0,location=0,directories=0,status=0,resizable=1,width=210,height=160');
		popup.focus();
		return false;
	});
	
	// Home corporate movie
	swfobject.embedSWF("flash/player.swf", "homecorporatemovie", 220, 144, "9.0.0", "", {
		file: "corporate.flv",
		image: "flash/corp_preview.jpg"
	}, {
		wmode: 'transparent',
		allowfullscreen: 'true',
		allowscriptaccess: 'always'
	});
	
	
	// Pageables
	$('ul.pageable').paging();
	$('div.pageable').paging({elementType:'div'});
	
	$('div.flv div').each(function(i) {
	   if(!($(this).attr('id'))) {
	       $(this).attr('id', 'flv_' +i);
	   }
	    swfobject.embedSWF("flash/player.swf", $(this).attr('id'), $('img', this).css('width'), $('img', this).css('height') + 24, "9.0.0", "", {
	        file: $('img', this).attr('flv'),
	        image: $('img', this).attr('src'),
	        autostart: $('img', this).attr('jw-autostart')
	    }, {
	        wmode: 'transparent',
	        allowfullscreen: 'true',
	        allowscriptaccess: 'always'
	    });
	});
});

function trackMedia(url) {
    pageTracker._trackPageview(url);
}
