/*
 * @filename replace_localtools.js
 * @programmer Sothea Nim, info@sotheanim.com; snim@alcor.concordia.ca
 * @date August 27, 2009
 * @description replacing the sharethis and printing tool
 */
 
function replace_localtools(hostname, uri, pagetitle, theSiteRoot, printLegacy)
{
	hostname = (typeof hostname!=='undefined') ? hostname : window.location.host;
	uri = (typeof uri!=='undefined') ? uri : window.location.pathname;
	pagetitle = (typeof pagetitle!=='undefined') ? pagetitle : document.getElementsByTagName('title')[0].innerHTML;
	
	var sroot = (typeof theSiteRoot!=='undefined') ? theSiteRoot : '/';
	sroot = sroot[0]==='/'?sroot:'/'+sroot;
	
	printLegacy = (typeof printLegacy!=='undefined') ? printLegacy : false;
	
	var reqHost = window.location.href.split('?');
	
	if( reqHost[1] ) print_link = reqHost[0]+'?'+reqHost[1]+'&print=1';
	else print_link = reqHost[0]+'?print=1';
	
	var tools = '<div id="localtool" style="margin-top:-30px;border:0px !important;"><ul>';
	tools = tools + '<li class="print"><a href="'+print_link+'" class="print" onclick="return true">Print</a></li>';
	tools = tools + '<li class="share"><a class="share" href="?share=1" onclick="return localTools('+"'share', '"+escape(window.document.title)+"'"+')">Share</a></li>';
	tools = tools + '<li class="print"><a href="http://'+hostname+sroot+'email.php?url='+uri+'&amp;pagetitle='+pagetitle+'" class="email" onclick="return true" title="Email: '+unescape(pagetitle)+'">Email</a></li>';
	tools = tools + '</ul><div id="toolbox">&nbsp;</div></div>';

//var tools = '<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=fafdea98-7556-4637-8177-9efd9fe1c1e6&amp;type=website&amp;post_services=email%2Cfacebook%2Ctwitter%2Cdelicious%2Cgbuzz%2Cmyspace%2Cdigg%2Csms%2Cwindows_live%2Cstumbleupon%2Creddit%2Cgoogle_bmarks%2Clinkedin%2Cbebo%2Cybuzz%2Cblogger%2Cyahoo_bmarks%2Cmixx%2Ctechnorati%2Cfriendfeed%2Cpropeller%2Cwordpress%2Cnewsvine&amp;headerbg=%236f6f6f&amp;headerTitle=Concordia%20University"></script>';
	
	if(document.getElementById("localtools_wrapper"))
	{
		document.getElementById('localtools_wrapper').innerHTML=tools;
	}
	else if(document.getElementById("localtools_wrapper-fr"))
	{
		document.getElementById('localtools_wrapper-fr').innerHTML=tools;
	}
}


function replace_localtools_fr(hostname, uri, pagetitle, theSiteRoot, printLegacy)
{
	hostname = (typeof hostname!=='undefined') ? hostname : window.location.host;
	uri = (typeof uri!=='undefined') ? uri : window.location.pathname;
	pagetitle = (typeof pagetitle!=='undefined') ? pagetitle : document.getElementsByTagName('title')[0].innerHTML;
	
	var sroot = (typeof theSiteRoot!=='undefined') ? theSiteRoot : '/';
	sroot = sroot[0]==='/'?sroot:'/'+sroot;
	
	printLegacy = (typeof printLegacy!=='undefined') ? printLegacy : false;
	
	var reqHost = window.location.href.split('?');
	
	if( reqHost[1] ) print_link = reqHost[0]+'?'+reqHost[1]+'&print=1';
	else print_link = reqHost[0]+'?print=1';
	
	var tools = '<div id="localtool" style="margin-top:-30px;border:0px !important;"><ul>';
	tools = tools + '<li class="print"><a href="'+print_link+'" class="print" onclick="return true">Imprimer</a></li>';
	tools = tools + '<li class="share"><a class="share" href="?share=1" onclick="return localTools('+"'share', '"+escape(window.document.title)+"'"+')">Partager</a></li>';
	tools = tools + '<li class="print"><a href="http://'+hostname+sroot+'email.php?url='+uri+'&amp;pagetitle='+pagetitle+'" class="email" onclick="return true" title="Courriel: '+unescape(pagetitle)+'">Courriel</a></li>';
	tools = tools + '</ul><div id="toolbox">&nbsp;</div></div>';

//var tools = '<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=fafdea98-7556-4637-8177-9efd9fe1c1e6&amp;type=website&amp;post_services=email%2Cfacebook%2Ctwitter%2Cdelicious%2Cgbuzz%2Cmyspace%2Cdigg%2Csms%2Cwindows_live%2Cstumbleupon%2Creddit%2Cgoogle_bmarks%2Clinkedin%2Cbebo%2Cybuzz%2Cblogger%2Cyahoo_bmarks%2Cmixx%2Ctechnorati%2Cfriendfeed%2Cpropeller%2Cwordpress%2Cnewsvine&amp;headerbg=%236f6f6f&amp;headerTitle=Concordia%20University"></script>';
	
	if(document.getElementById("localtools_wrapper"))
	{
		document.getElementById('localtools_wrapper').innerHTML=tools;
	}
	else if(document.getElementById("localtools_wrapper-fr"))
	{
		document.getElementById('localtools_wrapper-fr').innerHTML=tools;
	}
}
