

var fadeoutTime = 30;	
var historyOn = 0;
var n = 0;

$(function() {
  $("#company").mouseenter(function() {		  
		$("ul.isEnabled:not(#companyMenu)").fadeOut(fadeoutTime).removeClass("isEnabled")
			$("#companyMenu").fadeIn(20);
			$("#companyMenu").addClass("isEnabled");					
  });
});

$(function() {	
  $("#business").mouseenter(function() {
	  $("ul.isEnabled:not(#businessMenu)").fadeOut(fadeoutTime).removeClass("isEnabled");
	  var pos_x = $(this).parent().position();
	  var mar_x = $(this).parent().parent().css("padding-left").replace("px", "");
	  $("#businessMenu").css("left",(pos_x.left-mar_x));
	  $("#businessMenu").fadeIn(20);
	  $("#businessMenu").addClass("isEnabled");
	});
});

$(function() {	
  $("#contact").mouseenter(function() {
	  $("ul.isEnabled:not(#contactMenu)").fadeOut(fadeoutTime).removeClass("isEnabled");
	  var pos_x = $(this).parent().position();
	  var mar_x = $(this).parent().parent().css("padding-left").replace("px", "");	  
	  $("#contactMenu").css("left",(pos_x.left-mar_x));
	  $("#contactMenu").addClass("isEnabled");
	$("#contactMenu").fadeIn(20)});
});


$(function() {	
  $("#intro").mouseenter(function() {
	  $("ul.isEnabled:not(#companyMenu)").fadeOut(fadeoutTime).removeClass("isEnabled");
	  var pos_x = $(this).parent().position();
	  var mar_x = $(this).parent().parent().css("padding-left").replace("px", "");	  
	  $("#companyMenu").css("left",(pos_x.left-mar_x));
	  $("#companyMenu").addClass("isEnabled");
	$("#companyMenu").fadeIn(400)});
});


$(function() {	
  $("#history").mouseenter(function() {
	  $("ul.isEnabled:not(#historyMenu)").fadeOut(fadeoutTime).removeClass("isEnabled");
	  var pos_x = $(this).parent().position();
	  var mar_x = $(this).parent().parent().css("padding-left").replace("px", "");	  
	  $("#historyMenu").css("left",(pos_x.left-mar_x));
	  $("#historyMenu").addClass("isEnabled");
	$("#historyMenu").fadeIn(20)});
});


$(function() {
  $("#principles").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('display','none').attr('src','principles.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#organization").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).fadeIn(900).attr('src','organization.fi.php')});
  });
});

$(function() {
  $("#funcVision").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).fadeIn(900).attr('src','funcVision.fi.php')});
  });
});


$(function() {
  $("#techTrade").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','tekninen.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#servContract").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','servContract.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#invest").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','investActivities.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#properties").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','propertyActivities.fi.php').fadeIn(900)});
  });
});



$(function() {
  $("#boardDirect").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','hallitus.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#leadDirect").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','leadDirect.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#industry").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','industry.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#media").click(function() {
	  historyOn = 0;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','media.fi.php').fadeIn(900)});
  });
});



$(function() {
  $("#subHist").click(function() {
	  historyOn = 1;
	$(".slideshowPic").fadeOut(30,function() {$(this).attr('src','history_One.fi.php').fadeIn(900)});
  });
});

$(function() {
  $("#histFirstPage").click(function() {	  
	  if (historyOn!=1)
	  {
	  	$('#histLeft').html(history1_left_str);
		$('#histRight').html(history1_right_str);
		$('#histSecondPage').removeClass('stronger');
		$('#histFirstPage').addClass('stronger');
		historyOn = 1;	    
	  }
	  });
});

$(function() {
  $("#histSecondPage").click(function() {	  
	  if (historyOn!=2)
	  {
	  	$('#histLeft').html(history2_left_str);
		$('#histRight').html(history2_right_str);
		$('#histSecondPage').addClass('stronger');
		$('#histFirstPage').removeClass('stronger');
		historyOn = 2;		    	  	  
	  }
	  });
});

$(function(){
	$('#englishLan').click(function(){
		var currentPath = window.location.pathname;
		var currentPage = currentPath.substring(currentPath.lastIndexOf('/')+1);
		var pageName = currentPage.split(".");
		var temp = null;		
		if (pageName[0] == "hallitus")
		{			
			var pName = $('.peopleList a.stronger').html().replace(" ","");
			temp = "hallitus.en.php?chosenOne=" + pName;
		}
		else if (pageName[0] == "leadDirect")
		{			
			// For ikko a Koivista we had to put more replace
			var pName = $('.peopleList a.stronger').html().replace(" ", "").replace(".","").replace(" ","");
			temp = "leadDirect.en.php?chosenOne=" + pName;
			
		}
		else
		{
			temp =  pageName[0] + ".en.php";
		}
		window.location.href = temp;
		window.location.load(temp);

		});
	});
	
$(function(){
	$('#OnvestLogo').click(function(){
		var temp = "index.php?pageOnIframe=intro.fi.php&lang=fi&startUp=false";
		window.location.href = temp;
		window.location.load(temp);
	});
});

$(function(){
	$('#groupReviewLink').click(function(){
		var temp = "index.php?pageOnIframe=organization.fi.php&lang=fi";
		// we need a top relod cause we are inside the iframe, so  a simple reload will reload just the internal iframe, putting the index.php inside of it.
		//Instead with this sytem we call a top reload so all the index will reload with iframe included. This is necessary otherwise the languages changes will not work correctly.
		window.top.location.href = temp;
		window.top.location.load(temp);
	});
});

	
	$(function(){
		$('.peopleList a').click(function(){
			if (!$(this).hasClass('stronger'))
			{	
				$('.peopleList a.stronger').removeClass();
				$(this).addClass("stronger");
				var pName = $(this).html();		
				var imgfolder = "Img\/People\/";			
				switch (pName)
				{
					case "Maarit Toivanen-Koivisto": 
					var pathname = window.location.pathname;
					var tempsSrc = null;
					var whichOne = pathname.search("hallitus");				
					if (whichOne > 0)
					{
						tempSrc = imgfolder + "MaaritToivanenKoivistoHal" + ".png";				
					}
					else 
					{
						tempSrc = imgfolder + "MaaritToivanenKoivisto" + ".png";				
					}
					//$("#imageFrame").attr("src",tempSrc);
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Maarit Toivanen-Koivisto");
					break;
					
					case "Markku Pohjola": 
					//var tempSrc = imgfolder + pName + ".png";
					var tempSrc = imgfolder + "MarkkuPohjola" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Markku Pohjola");
					break;
					
					case "Seppo Riski": 
					//var tempSrc = imgfolder + pName + ".png";
					var tempSrc = imgfolder + "SeppoRiski" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Seppo Riski");
					break;
					
					case "Jukka Helkama": 
					//var tempSrc = imgfolder + pName + ".png";
					var tempSrc = imgfolder + "JukkaHelkama" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Jukka Helkama");
					break;
					
					case "Johanna Jouhki":										
					var tempSrc = imgfolder + "JohannaJouhki" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Johanna Jouhki");
					break;
					
					case "Timo Alamiekkaoja":										
					var tempSrc = imgfolder + "TimoAlamiekkaoja" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Timo Alamiekkaoja");
					break;
					
					case "Ilkka A. Koivisto":										
					var tempSrc = imgfolder + "IlkkaKoivisto" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Ilkka Koivisto");
					break;
			
		
					case "Jyrki Rantala":										
					var tempSrc = imgfolder + "JyrkiRantala" + ".png";				
					$("#imageFrame").fadeOut(400, function(){$(this).attr('src',tempSrc).bind('readystatechange load',function(){if (this.complete) $(this).fadeIn(400);});})
					$("h2").html("Jyrki Rantala");
					break;			
				}
			}
		});
	});



