function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  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 checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver >= 8.0 ) 
      msg = "You're using a recent copy of Internet Explorer."
    else
      msg = "You should upgrade your copy of Internet Explorer.";
  }
  alert( msg );
}
function nextBg()
{
	var IEversion=getInternetExplorerVersion();
	if (IEversion<7 && IEversion!=-1)
	{
		if (document.getElementById('temoin').value==1)
		{
			document.getElementById('temoin').value=2;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd2.jpg)';
			$('#flag1').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag1').html('1');
			$('#flag2').css({'background-image' : 'url(imgs/flags/1.gif)'}); $('#flag2').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==2)
		{
			document.getElementById('temoin').value=3;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd3.jpg)';
			$('#flag2').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag2').html('2');
			$('#flag3').css({'background-image' : 'url(imgs/flags/3.gif)'}); $('#flag3').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==3)
		{
			document.getElementById('temoin').value=4;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd4.jpg)';
			$('#flag3').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag3').html('3');
			$('#flag4').css({'background-image' : 'url(imgs/flags/4.gif)'}); $('#flag4').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==4)
		{
			document.getElementById('temoin').value=5;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd5.jpg)';
			$('#flag4').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag4').html('4');
			$('#flag5').css({'background-image' : 'url(imgs/flags/5.gif)'}); $('#flag5').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==5)
		{
			document.getElementById('temoin').value=6;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd6.jpg)';
			$('#flag5').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag5').html('5');
			$('#flag6').css({'background-image' : 'url(imgs/flags/6.gif)'}); $('#flag6').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==6)
		{
			document.getElementById('temoin').value=7;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd7.jpg)';
			$('#flag6').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag6').html('6');
			$('#flag7').css({'background-image' : 'url(imgs/flags/7.gif)'}); $('#flag7').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==7)
		{
			document.getElementById('temoin').value=8;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd8.jpg)';
			$('#flag7').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag7').html('7');
			$('#flag8').css({'background-image' : 'url(imgs/flags/9.gif)'}); $('#flag8').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==8)
		{
			document.getElementById('temoin').value=9;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd9.jpg)';
			$('#flag8').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag8').html('8');
			$('#flag9').css({'background-image' : 'url(imgs/flags/8.gif)'}); $('#flag9').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==9)
		{
			document.getElementById('temoin').value=1;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd1.jpg)';
			$('#flag9').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag9').html('9');
			$('#flag1').css({'background-image' : 'url(imgs/flags/2.gif)'}); $('#flag1').html('&nbsp;');
		}
	}
	else 
	{
		if (document.getElementById('temoin').value==1)
		{
			document.getElementById('temoin').value=2;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd2.jpg)';
			$('#flag1').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag1').html('1');
			$('#flag2').css({'background-image' : 'url(imgs/flags/1.png)'}); $('#flag2').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==2)
		{
			document.getElementById('temoin').value=3;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd3.jpg)';
			$('#flag2').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag2').html('2');
			$('#flag3').css({'background-image' : 'url(imgs/flags/3.png)'}); $('#flag3').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==3)
		{
			document.getElementById('temoin').value=4;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd4.jpg)';
			$('#flag3').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag3').html('3');
			$('#flag4').css({'background-image' : 'url(imgs/flags/4.png)'}); $('#flag4').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==4)
		{
			document.getElementById('temoin').value=5;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd5.jpg)';
			$('#flag4').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag4').html('4');
			$('#flag5').css({'background-image' : 'url(imgs/flags/5.png)'}); $('#flag5').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==5)
		{
			document.getElementById('temoin').value=6;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd6.jpg)';
			$('#flag5').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag5').html('5');
			$('#flag6').css({'background-image' : 'url(imgs/flags/6.png)'}); $('#flag6').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==6)
		{
			document.getElementById('temoin').value=7;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd7.jpg)';
			$('#flag6').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag6').html('6');
			$('#flag7').css({'background-image' : 'url(imgs/flags/7.png)'}); $('#flag7').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==7)
		{
			document.getElementById('temoin').value=8;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd8.jpg)';
			$('#flag7').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag7').html('7');
			$('#flag8').css({'background-image' : 'url(imgs/flags/9.png)'}); $('#flag8').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==8)
		{
			document.getElementById('temoin').value=9;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd9.jpg)';
			$('#flag8').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag8').html('8');
			$('#flag9').css({'background-image' : 'url(imgs/flags/8.png)'}); $('#flag9').html('&nbsp;');
		}
		else if (document.getElementById('temoin').value==9)
		{
			document.getElementById('temoin').value=1;
			document.getElementById('slideshow').style.backgroundImage='url(imgs/bgd1.jpg)';
			$('#flag9').css({'background-image' : 'url(imgs/roundanm.png)'}); $('#flag9').html('9');
			$('#flag1').css({'background-image' : 'url(imgs/flags/2.png)'}); $('#flag1').html('&nbsp;');
		}
	}
}
function openDiv()
{
	document.getElementById('slideshow').style.display='block';
}

function startJs(currentPage,enSavoirPlus,goAnim,ms)
{
	
	var IEversion=getInternetExplorerVersion();
	if (IEversion<7 && IEversion!=-1)
	{
		var so = new SWFObject('imgs/logopm.swf', "logo", "280", "154", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.write("logo");
	}
	else 
	{
		$("#logo").html('<a href="/" title="Percy Miller.com"><img src="imgs/logopm2.png" alt="" /></a>');	
	}
	
	if (currentPage=='accueil')
	{
		
		document.getElementById('temoin').value=1;
		if ($("#menuc").length > 0)
		{	
			$('<img/>').attr('src','imgs/bgd1.jpg').load(function()
			{
				var so = new SWFObject('imgs/flash_finalc.swf', "menuc", "972", "400", "7");
				so.addParam("quality", "medium");
				so.addParam("wmode", "transparent");
				so.write("menuc");
			});
		}
		else 
		{
				
		}
		/*
		*/
		
	}
	else 
	{
		if ($("#menuc").length > 0)
		{
			var so = new SWFObject('imgs/flash_finalc.swf?goAnim='+goAnim, "menuc", "972", "400", "9");
			so.addParam("quality", "medium");
			so.addParam("wmode", "transparent");
			so.write("menuc");
		}	
	}
	if ($("#mapca2").length > 0)
	{
		var so = new SWFObject('imgs/flag-canada.swf', "mapca2", "160", "125", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.write("mapca2");
	}
	if ($(".actui").length > 0)
	{
		$(".actui").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('actu');
			var idActu = Tabcur[1];
			var so = new SWFObject('/imgs/actu.swf?image=actualites/'+idActu+'_198.jpg', currentId, "198", "103", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($(".actuac").length > 0)
	{
		$(".actuac").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('actuac');
			var idActu = Tabcur[1];
			var so = new SWFObject('/imgs/actuac.swf?image=actualites/'+idActu+'_155.jpg', currentId, "155", "81", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($(".edit").length > 0)
	{
		$(".edit").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('edit');
			var idActu = Tabcur[1];
			var so = new SWFObject('/imgs/partac2.swf?image=partenaires/'+idActu+'_103.jpg', currentId, "103", "54", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId); 
		}); 
	}
	if ($(".temi").length > 0)
	{
		$(".temi[class!='temi noflash']").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('tem');
			var idTem = Tabcur[1];
			var so = new SWFObject('/imgs/tem.swf?image=temoignages/'+idTem+'_144.jpg', currentId, "155", "175", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($(".servvi").length > 0)
	{
		$(".servvi").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('servv');
			var idActu = Tabcur[1];
			var so = new SWFObject('/imgs/actu.swf?image=services/'+idActu+'_198.jpg?t=2', currentId, "198", "103", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($(".serv2vi").length > 0)
	{
		$(".serv2vi").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('serv2v');
			var idActu = Tabcur[1];
			var so = new SWFObject('/imgs/actu.swf?image=services2/'+idActu+'_198.jpg?t=2', currentId, "198", "103", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($(".service2-mini").length > 0)
	{
		$(".service2-mini").each(function(){
			var currentId = $(this).attr('id');
			var Tabcur = currentId.split('serv2');
			var idTem = Tabcur[1];
			var so = new SWFObject('/imgs/Services-mini.swf?image=services2/'+idTem+'_71.jpg', currentId, "61", "81", "7");
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
			so.write(currentId);
		});
	}
	if ($("#botdoc").length > 0)
	{
		$('#botdoc').cycle({ 
			before: function() { $(this).children('.ddoctit').children('.ddoctit2').jTypeWriter({duration:1}); },
			cleartype:  false, 
			timeout: 5500		
		});
	}
	if ($(".ddoci").length > 0)
	{
		$(".ddoci").each(function(){
			
			if ($("#botdoc").length == 0)
			{
				if ($(this).parent().children('.ddocd').length > 0) 
				{
					// On remplace le texte du lien du bouton "plus d'infos"
					$(this).parent().children('.ddocd').children('.btt1').children('a').text(enSavoirPlus);
					$(this).click(function() {
						//alert($(this).children('a').attr('href'));
						window.location=$(this).parent().children('.ddocd').children('.btt1').children('a').attr('href');
					});
				}
				else 
				{
					$(this).parent().children('.btt1').children('a').text(enSavoirPlus);
					$(this).click(function() {
						//alert($(this).children('a').attr('href'));
						window.location=$(this).parent().children('.btt1').children('a').attr('href');
					});
				}
				var currentId = $(this).attr('id');

				var Tabcur = currentId.split('doc');
				var idTem = Tabcur[1];
				var so = new SWFObject('/imgs/doc.swf?image=documents/'+idTem+'_130.jpg?'+ms, currentId, "160", "204", "7");
				so.addParam("quality", "high");
				so.addParam("wmode", "transparent");
				so.write(currentId);
			}
			else 
			{
				var currentId = $(this).attr('id');
	
				var Tabcur = currentId.split('doc');
				var idTem = Tabcur[1];
				var so = new SWFObject('/imgs/doc2.swf?t2=y&image=documents/'+idTem+'_130.jpg', currentId, "160", "204", "7");
				so.addParam("quality", "high");
				so.addParam("wmode", "transparent");
				so.write(currentId);	
			}
			
			
			
			
		});
	}
	$("#menu li:not(.sel)").mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:100});
	});
	$("#menu li:not(.sel)").mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0px -56px)"}, {duration:150});
	});
	$("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	if ($("#butcolg").length > 0)
	{
		$("#butcolg p img").each(function() {
			var id=$(this).attr('id');
			$(this).parent('a').parent('p').css({'background-image' : 'url(imgs/'+id+'o.jpg)'});
		});
		$("#butcolg p img").hover(function() {
			var id=$(this).attr('id');
			$(this).attr("src","imgs/"+id+"o.jpg");
			$('#butcolg div').html($(this).attr('alt'));
			}, 
		function() {
			var id=$(this).attr('id');
			$(this).attr("src","imgs/"+id+".jpg");
			$('#butcolg div').html('&nbsp;');
		});

		$("#aami").click(function() {
							$('#formulairefav').lightbox_me({
								centered: true, 
								onLoad: function() { 
									$('#formulairefav').find('input:first').focus();
									}
								});
							return false;
						});
		if(window.opera) {
			if ($("a#afav").attr("rel") != ""){ // don't overwrite the rel attrib if already set
				$("a#afav").attr("rel","sidebar");
			}
		} 

		$("a#afav").click(function(event){
	
			event.preventDefault(); // prevent the anchor tag from sending the user off to the link
			var url = document.location.href;
			var title = document.title;
			var nav = navigator.userAgent; 
			var ischrome = nav.indexOf("Chrome") ? true : false;
			
			if (window.sidebar) { // Mozilla Firefox Bookmark
				window.sidebar.addPanel(title, url, "");
			} else if( window.external ) { // IE Favorite
				if (ischrome==true)
				{
					alert('Unfortunately, this browser does not support the requested action, please bookmark this page manually.');
				}
				else 
				{
					window.external.AddFavorite(url, title);
				}
			} else if(window.opera) { // Opera 7+
				alert('test');
				return false; // do nothing - the rel="sidebar" should do the trick
			} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
				alert('Unfortunately, this browser does not support the requested action, please bookmark this page manually.');
			}
		});
	}
	$('#load').html('<img src="imgs/bgd2.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd3.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd4.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd5.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd6.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd7.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd8.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd9.jpg" alt="" style="width:2px; height:2px;"/><img src="imgs/bgd10.jpg" alt="" style="width:2px; height:2px;"/>');

}
