$(document).ready(function(){
	
	
	$('.link_hover').hide();					   
	if (document.getElementById('this_be_lang') != null || document.getElementById('this_be_lang') != undefined) {
		var lang = document.getElementById('this_be_lang').value;  
		var fuid = document.getElementById('this_be_id').value;
		callFlash(fuid, lang);
	}
	
	//if (!isthisie8()){		
		$(".exp_box").hide();
		$(".toggle_button").click( function () {
		  var target = this.id;
		  
		  
		  target = "#b" + target.substr(1);
		 // $(".exp_box").slideUp(200); // hide shit
		  $(target).slideToggle(300); // show shit
		});
	//}
	
	function getInternetExplorerVersion() {
		var rv = -1; // Return value assumes failure.
			if (navigator.appName == 'Microsoft Internet Explorer') {
				var ua = navigator.userAgent;
				var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
				if (re.exec(ua) != null)
					rv = parseFloat(RegExp.$1);
			}
		return rv;
	}
	function isthisie8() {
		var msg = "You're not using Windows Internet Explorer.";
		var ver = getInternetExplorerVersion();
			if (ver > -1) {
				if (ver >= 8.0){
					//msg = "You're using a recent copy of Windows Internet Explorer."
					return true
				}	
				else {
					//msg = "You should upgrade your copy of Windows Internet Explorer.";
					return false
				}
			}
			else {
				return false	
			}
		//alert(msg);
	}
	
	
	
	/**
	 *
	 * 2010 news module additions
	 * Next page button
	 *
	**/
	$('a.nextPage').click( function(){
		
		// --- Get last article number ---
		var hideFrom		= parseInt( $('div#articleOverview a.article:visible:first').attr('id').substr(8) );
		var hideTo			= hideFrom+4;
		var showFrom		= hideTo+1;
		var showTo			= showFrom+4;
		var readyHiding	= false;
		var moreArticles	= true;
		
		// --- Hide last 5 articles ---
		for( hideFrom; hideFrom<=hideTo; hideFrom=hideFrom+1)
		{
			// --- If article exists, fade out ---
			if( $('a#article_'+hideFrom).length )
				$('a#article_'+hideFrom).hide();
			
			if( hideFrom<=hideTo )
			{
				for( showFrom; showFrom<=showTo; showFrom=showFrom+1)
				{
					if( $('a#article_'+showFrom).length )
					{
						// --- If article exists, fade in! ---
						$('a#article_'+showFrom).fadeIn('fast');
					}
					else
					{
						// --- No more articles, break and hide arrow ---
						moreArticles = false;
						break;
					}	
				}
			}
			
		}
		
		// --- If no more articles, hide next button ---
		if( !moreArticles )
			$('a.nextPage').fadeOut('fast');
		
		// --- Fade in previous button ---
		if( $('a.prevPage').css('display') == 'none' )
			$('a.prevPage').fadeIn('fast');
		
		// --- Return false to cancel anchor event ---
		return false;
		
	});
	
	/**
	 *
	 * 2010 news module additions
	 * Prev page button
	 *
	**/
	$('a.prevPage').click( function(){
		
		// --- Get last article number ---
		var hideFrom			= parseInt( $('div#articleOverview a.article:visible:first').attr('id').substr(8) );
		var hideTo				= hideFrom+4;
		var showFrom			= hideFrom-5;
		var showTo				= showFrom+4;
		var readyHiding		= false;
		var noMoreArticles	= false;
		
		if( showFrom == 1 )
			noMoreArticles = true;
		
		// --- Hide last 5 articles ---
		for( hideFrom; hideFrom<=hideTo; hideFrom=hideFrom+1)
		{
			// --- If article exists, fade out ---
			if( $('a#article_'+hideFrom).length )
				$('a#article_'+hideFrom).hide();
			
			if( hideFrom<=hideTo )
			{
				for( showFrom; showFrom<=showTo; showFrom=showFrom+1)
				{
					// --- If article exists, fade in! ---
					if( $('a#article_'+showFrom).length )
						$('a#article_'+showFrom).fadeIn('fast');
				}
			}
		}
		
		// --- If no more articles, hide next button ---
		$('a.nextPage').fadeIn('fast');
		
		// --- Fade in previous button ---
		if( noMoreArticles && $('a.prevPage').css('display') == 'block' )
			$('a.prevPage').fadeOut('fast');
		
		// --- Return false to cancel anchor event ---
		return false;
		
	});
	
});


function callFlash(f,l) {
	var flashvars = {
		fund_id:f,
		language:l                  
	};
	var params = {
		menu: "false",
		scale: "noScale",
		allowFullscreen: "true",
		allowScriptAccess: "always",
		bgcolor: "#ffffff",
		wmode:"opaque"
	};
	var attributes = {
		id:"FonditataulukkoV2"
	};
	swfobject.embedSWF("/flash/FonditataulukkoV2.swf", "flash_alt_content", "100%", "400px", "10.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);
}

function show(e) {
	$('#' +e.id + '_hover' ).fadeIn(200);
}

function hide(e) {
	$('#' + e.id).fadeOut(200);
}

  
 	
		
