var pathname = $.trim(window.location.pathname);
var hostname = pathname.split('/')[0];
var parentname = pathname.substring(0, pathname.lastIndexOf('/'));
var translateEn = {
'/fr/articles': '/articles',                              
'/fr/services-integres': '/bundled-service',
'/fr/etudes-de-cas/index': '/case-studies/index',
'/fr/entreprise/nous-joindre': '/company/contact-us',
'/fr/entreprise/histoire': '/company/history',
'/fr/entreprise/rh-carrieres': '/company/hr-careers',
'/fr/entreprise/index': '/company/index',
'/fr/entreprise/bureaux': '/company/offices',
'/fr/entreprise/equipe': '/company/team',
'/fr/conversion': '/conversion-optimization',
'/fr/cool': '/cool',
'/fr/services-creation': '/creative-services',
'/fr/exactitude-des-donnees-llm': '/data-accuracy',
'/fr/marketing-numerique': '/digital-marketing',
'/fr/planification-strategique-numerique': '/digital-strategy-planning',
'/fr/dimitri': '/dimitri',
'/fr/publicite-annuaires': '/directory-advertising',
'/fr/recherche-annuaires': '/directory-research',
'/fr/planification-strategique-annuaires' : '/directory-strategic-planning',
'/fr/marketing-integre': '/integrated-marketing',
'/fr/pages-jaunes-en-ligne': '/internet-yellow-pages',
'/fr/leads': '/lead-generation',
'/fr/llm-conversion': '/llm-conversion',
'/fr/rapport-gestion-fiches-locales'     : '/llm-reporting',
'/fr/llm-seo': '/llm-seo',
'/fr/nos-opinions': '/marketing-whitepapers',
'/fr/resultats-mesures': '/measured-results',
'/fr/allocation-medias': '/media-allocation',
'/fr/publicite-mobile': '/mobile',
'/fr/publicite-mobile': '/mobile-advertising',
'/fr/applications-mobiles': '/mobile-applications',
'/fr/web-mobile': '/mobile-web',
'/fr/seo-off-page': '/off-page-seo',
'/fr/recherche-localise-en-ligne': '/online-local-listing',
'/fr/seo-on-page': '/on-page-seo',
'/fr/pagetorrent': '/pagetorrent',
'/fr/communique-de-presse': '/press-release',
'/fr/print-execution': '/print-execution',
'/fr/pages-jaunes-imprimees': '/print-yellow-pages',
'/fr/politique-de-confidentialite': '/privacy-policy',
'/fr/gestion-de-la-reputation': '/reputation-management',
'/fr/recherche': '/research',
'/fr/ressources': '/resources',
'/fr/sem': '/sem',
'/fr/seo': '/seo',
'/fr/services-conseils-seo': '/seo-consulting',
'/fr/plan-du-site':'/sitemap',
'/fr/medias-sociaux': '/social',
'/fr/services-conseil-medias-sociaux': '/social-media-consulting',
'/fr/monitoring-medias-sociaux': '/social-media-monitoring',
'/fr/planification-strategique-numerique': '/strategic-planning'
};
var translate = {
'/articles':'/fr/articles',                                                           
'/bundled-service':'/fr/services-integres',                                           
'/case-studies/index':'/fr/etudes-de-cas/index',
'/company/contact-us':'/fr/entreprise/nous-joindre',
'/company/history':'/fr/entreprise/histoire',
'/company/hr-careers':'/fr/entreprise/rh-carrieres',
'/company/index':'/fr/entreprise/index',
'/company/offices':'/fr/entreprise/bureaux',
'/company/team':'/fr/entreprise/equipe',
'/conversion-optimization':'/fr/conversion',
'/cool':'/fr/cool',
'/creative-services':'/fr/services-creation',
'/data-accuracy':'/fr/exactitude-des-donnees-llm',
'/digital-marketing':'/fr/marketing-numerique',
'/digital-strategy-planning':'/fr/planification-strategique-numerique',
'/dimitri':'/fr/dimitri',
'/directory-advertising':'/fr/publicite-annuaires',
'/directory-research':'/fr/recherche-annuaires',
'/directory-strategic-planning':'/fr/planification-strategique-annuaires',
'/integrated-marketing':'/fr/marketing-integre',
'/internet-yellow-pages':'/fr/pages-jaunes-en-ligne',
'/lead-generation':'/fr/leads',
'/llm-conversion':'/fr/llm-conversion',
'/llm-reporting':'/fr/rapport-gestion-fiches-locales',
'/llm-seo':'/fr/llm-seo',
'/marketing-whitepapers':'/fr/nos-opinions',
'/measured-results':'/fr/resultats-mesures',
'/media-allocation':'/fr/allocation-medias',
'/mobile':'/fr/publicite-mobile',
'/mobile-advertising':'/fr/publicite-mobile',
'/mobile-applications':'/fr/applications-mobiles',
'/mobile-web':'/fr/web-mobile',
'/off-page-seo':'/fr/seo-off-page',
'/online-local-listing':'/fr/recherche-localise-en-ligne',
'/on-page-seo':'/fr/seo-on-page',
'/pagetorrent':'/fr/pagetorrent',
'/press-release':'/fr/communique-de-presse',
'/print-execution':'/fr/print-execution',
'/print-yellow-pages':'/fr/pages-jaunes-imprimees',
'/privacy-policy':'/fr/politique-de-confidentialite',
'/reputation-management':'/fr/gestion-de-la-reputation',
'/research':'/fr/recherche',
'/resources':'/fr/ressources',
'/sem':'/fr/sem',
'/seo':'/fr/seo',
'/seo-consulting':'/fr/services-conseils-seo',
'/sitemap':'/fr/plan-du-site',
'/social':'/fr/medias-sociaux',
'/social-media-consulting':'/fr/services-conseil-medias-sociaux',
'/social-media-monitoring':'/fr/monitoring-medias-sociaux',
'/strategic-planning':'/fr/planification-strategique-numerique'
};
var frLink = "http://www.groupedac.com";
var enLink = "http://www.dacgroup.com";




$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
  while(x<c.length){var m=r.exec(c.substr(x));
    if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
    }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
    o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
  while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
  t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
})
function initMenu() {
	var norm;
	$('.sub-menu').each(function (i) 
	{
		counter = 1;
		$(this).children("li").each(function() {
		if(counter <= 0.1)
			counter = 0.1;
			
		$(this).css({ opacity: counter });
		counter -= 0.1;		 
	});
 });
 var found = false;
$('#menu li').each(function (i) {
	var li = $(this);
		$(this).children("a").each(function() {		
			if(pathname == $.trim($(this).attr("href")) || ($.trim($(this).attr("href")).indexOf(parentname) >= 0 && (parentname == '/team' || parentname == '/equipe')) )
			{	
				li.children("ul").each(function() {
					$(this).show();
					found = true;
				});				
				$(this).html('<span id="selected-menu-item">'+$(this).text()+'</span>');				
			}
		});
	});	
	
	$('#menu ul').each(function (i) {
		ul = $(this);
		var lim = 17;		
		$(this).children("li").each(function() {
			var li = $(this);
			$(this).children("a").each(function() {					
				if(pathname == $.trim($(this).attr("href")))
				{
					ul.show();
					found = true;
					if($(this).text().length > lim)
					{$(this).text($(this).text().substring(0,lim)+'...')}
					li.attr('id','selected-menu-item');
					$(this).html('<span id="selected-menu-item">'+$(this).text()+'</span>');				
				}
			});
		});
	});
	if(found != true){
		$('#menu ul').show();
	}
	$('#selected-menu-item').css({ opacity: 1.0 });	
	$('#menu li ul li').hover( 
		function () 
		{
			norm = $(this).css("opacity");
			$(this).css({ opacity: 1.0 });
		}, 
		function () 
		{		
			$(this).css({ opacity: norm });
		}
	);
  
  $('#menu li a').hover(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return true;
        }		 
      }
    );
  }
  function initTwitter() {
	link = $('#twitter_div').html().substring(6,$('#twitter_div').html().lastIndexOf('</span>'));
	twitContent = $('#twitter_div').html().replace(/href/g, ' target="_blank" href');	
	$('#twitter_div').html(twitContent);	
	$('#retweet-link').attr("href",$('#retweet-link').attr("href")+'+'+$.URLEncode(link));	
}
$(document).ready(function(){
	initMenu();

	frLink += translate[pathname]?translate[pathname]:'';
	enLink += translateEn[pathname]?translateEn[pathname]:'';
	$('#lang-switch-fr').attr('href',frLink);
	$('#lang-switch-en').attr('href',enLink);
	
	
	$('#blog-feed').rssfeed('http://blog.dacgroup.com/?feed=rss2', {header:false,date:false,titletag:'h3'});	
	$('#blog-feed-dir').rssfeed('http://blog.dacgroup.com/?feed=rss2', {header:false,date:false,titletag:'h3'});	
	$('#twitter_div').html('<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/dac_group.json?callback=twitterCallback2&amp;count=1"></script>');		

	$("span[st_title='']").each(function (i){	
		$(this).attr("st_title",document.title);
	});	
	$('#imageholder').css('visibility','visible');	
	setTimeout("initTwitter()",1000);
	
	
	
	
	$(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
	
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum + 0.8;
	if(newFontSize < 20){
		$('html').css('font-size', newFontSize);
	}
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum - 0.8;
	if(newFontSize > 8){
		$('html').css('font-size', newFontSize);
	}
    return false;
  });
});
