function switchImgOn($imageID){
	var $source = '/en/images/Nav_Top_' + $imageID + '_ov.gif';
	document.getElementById($imageID).src = $source;
}

function switchImgOff($imageID){
	var $source = '/en/images/Nav_Top_' + $imageID + '.gif';
	document.getElementById($imageID).src = $source;
}
function switchImgOnFr($imageID){
	var $source = '/fr/images/Nav_Top_' + $imageID + '_ov.gif';
	document.getElementById($imageID).src = $source;
}

function switchImgOffFr($imageID){
	var $source = '/fr/images/Nav_Top_' + $imageID + '.gif';
	document.getElementById($imageID).src = $source;
}

function switchVisibility($element){
	if(document.getElementById($element).style.display == 'none'){
		document.getElementById($element).style.display = 'block';
	}else{
		document.getElementById($element).style.display = 'none';
	}
}
/* MODIFICATIONS APPORTÉE 
Par: Sébastien Plourde
Date: 20 juin 2007

ORIGINAL : 

function switchLayer(layerId){
		if(document.getElementById('layer_' + layerId).style.display == 'none'){
			document.getElementById('layer_' + layerId).style.display = 'block';
		}else{
			document.getElementById('layer_' + layerId).style.display = 'none';
		}
}

*/
function switchLayer(layerId)
	{
	if(document.getElementById('layer_' + layerId).style.display == 'none')
		{
		document.getElementById('layer_' + layerId).style.display = 'block';
		document.getElementById('li_hooked_' + layerId).src = 'images/li_hookedm.gif';			
		}
	else
		{
		document.getElementById('layer_' + layerId).style.display = 'none';
		document.getElementById('li_hooked_' + layerId).src = 'images/li_hooked.gif';
		}
	}

function switchMenuInvisible($element){
	document.getElementById($element).style.display = 'none';
}

function switchMenuVisible($element){
	document.getElementById($element).style.display = 'block';
}

function switchAllInvisible(){
	var i=0;
	var countryArr = new Array();
	countryArr[0]="usaDirectory";
	countryArr[1]="canDirectory";
	countryArr[2]="mexDirectory";
	countryArr[3]="eurDirectory";
	countryArr[4]="asiDirectory";
	countryArr[5]="afrDirectory";
	countryArr[6]="samDirectory";
	countryArr[7]="ausDirectory";
	countryArr[8]="indDirectory";
	
	for(i in countryArr) {
		$element=countryArr[i];
		document.getElementById($element).style.display = 'none';
	}
}

function preloadImages(section, nbImages){
     // counter
     var i = 0;

     // create object
     var imageObj = new Image();

     // set image array
     var images = new Array();
     
     if (section == 'topNav'){	
		images[0]="images/Nav_Top_Company.gif"
		images[1]="images/Nav_Top_Solutions.gif"
		images[2]="images/Nav_Top_Consult.gif"
		images[3]="images/Nav_Top_Customers.gif"
		images[4]="images/Nav_Top_Resources.gif"
		images[5]="images/Nav_Top_Partners.gif"
		
		images[6]="/en/images/Icone_Sol_Inbound.jpg"
		images[7]="/en/images/Icone_Sol_Outbound.jpg"
		images[8]="/en/images/Icone_Sol_Reporting.jpg"
		images[9]="/en/images/Icone_Sol_Softphone.jpg"
		images[10]="/en/images/Icone_Sol_Monitor.jpg"
		images[11]="/en/images/Icone_Sol_Remote.jpg"
		images[12]="/en/images/Icone_Sol_Workforce.jpg"
		images[13]="/en/images/Icone_Sol_Stats.jpg"
		
		images[14]="/images/expert_back1.gif"
		images[15]="/images/tri_red0.gif"
		
		images[16]="/images/v3_1/v3_1_close1_en.gif"
		images[17]="/images/v3_1/v3_1_close1_fr.gif"
		
	}
     // start preloading
     for(i=0; i<=nbImages; i++) {
          imageObj.src=images[i];
     }
} 

function popScreenshot($imgName) {
	scrWin = window.open( "/en/includes/screenshot.php", "Aheeva", "status = 0, height = 500, width = 780, resizable = 0" );
	scrWin.document.write('<html><head></head><body margin=0 border=0><table cellspacing=0 cellpadding=0 width=100% height=100%><tr><td valign=middle align=center width=100% height=100%>');
	scrWin.document.write('<img src="/en/images/screenshots/' + $imgName + '">');
	scrWin.document.write('</td></tr></table></body></html>');
}

function printPop(pageParams) {
	print();
}

function printPage(){	
	if (window.print){
			window.print();
	}else{
			alert("Sorry, the browser does not support this feature");
	}
}

function switchLMicoDWN($element){
	$elementLink = $element + '_link';
	document.getElementById($element).src = '/en/images/' + $element + '.jpg';
	document.getElementById($elementLink).style.color = '#001e9e';
	
}

function switchLMicoUP($element){
	document.getElementById($element).src = '/en/images/' + $element + '_up.jpg';
	document.getElementById($elementLink).style.color = '#666666';
}

function switchTextDecoration($elementId){
	
	var i=9;
	var countryArrLink = new Array();
	countryArrLink[0]="usaDirectoryLink";
	countryArrLink[1]="canDirectoryLink";
	countryArrLink[2]="mexDirectoryLink";
	countryArrLink[3]="eurDirectoryLink";
	countryArrLink[4]="asiDirectoryLink";
	countryArrLink[5]="afrDirectoryLink";
	countryArrLink[6]="samDirectoryLink";
	countryArrLink[7]="ausDirectoryLink";
	countryArrLink[8]="indDirectoryLink";
	
	for(i in countryArrLink) {
	
		$element=countryArrLink[i];
		
		if($element != $elementId){
			document.getElementById($element).style.textDecoration = 'none';
		}else{
			document.getElementById($element).style.textDecoration = 'underline';
		}
	}

}

function fullwin(targeturl){
window.open(targeturl,'newwin','top=0,left=0,width='+screen.availWidth+',height='+screen.availHeight+',directories=yes,location=yes,resizable=yes,scrollbaras=yes,status=yes,toolbar=yes');
}

function go_now () {
    window.location.href = "http://www.aheeva.com/shop";
}

// functions to set up adverts
var adNo=1;
var howManyAds=0;
var timeAd;

function setupPage() {
	var mainWidth5 = document.getElementById("mainbody").offsetWidth;
	if(document.getElementById("rightNav")){
		document.getElementById("rightNav").style.left = ((mainWidth5/2) + 194) + "px";
		document.getElementById("rightNav").style.visibility = "";
	}
	if(document.getElementById("indAdvert")){
		setupAdverts();
	}

	if (document.getElementById("indexBlock1")) {
		var block1Height = document.getElementById("indexBlock1").offsetHeight;
		var block1Top = document.getElementById("indexBlock1").offsetTop;
		document.getElementById("indexBlock2").style.top=(block1Height+block1Top) + "px";					// set top position for solutions and products div
		
		if(document.getElementById("produ2")){
			var distanceFromTop = block1Height;
			if(document.getElementById("produ1")){
				distanceFromTop = block1Height+(document.getElementById("produ1").offsetHeight);			
			}
		}
		
		var block2Height = (document.getElementById("indexBlock2").offsetHeight)+10;
		document.getElementById("indexBlock3").style.top=(block1Height+block1Top+block2Height) + "px";		// set top position for news and events div
		document.getElementById("indexBlock3link").style.top=(block1Height+block1Top+block2Height) + "px";	// set top position for news and events link div
		document.getElementById("indexBlock5").style.top=(block1Height+block1Top+block2Height) + "px";		// set top position for why aheeva div
		
		var block3Height = (document.getElementById("indexBlock3").offsetHeight)+10;
		document.getElementById("indexBlock4").style.top=(block1Height+block1Top+block2Height+block3Height) + "px";	// set top position for news and events div
		var aboutDivHeight = document.getElementById("aboutAheeva").offsetHeight;
		document.getElementById("Shadow7").style.height = aboutDivHeight + "px";
		document.getElementById("Shadow7").style.marginTop = (block1Height+block2Height+block3Height+141) + "px";	// set shadow position for 'about' div in solutions and products
		
		var block4Height = (document.getElementById("indexBlock4").offsetHeight);
		document.getElementById("pageContent").style.height = (block1Height+block2Height+block3Height+block4Height+54) + "px";
		document.getElementById("indexBlock2").style.visibility="";													// make page elements visible after the position is set
		document.getElementById("indexBlock3").style.visibility="";
		document.getElementById("indexBlock3link").style.visibility="";											// make page elements visible after the position is set
		document.getElementById("indexBlock4").style.visibility="";
		document.getElementById("indexBlock5").style.visibility="";
		document.getElementById("Shadow7").style.visibility="";
		

	}
}

function setupAdverts() {
	for (i=1;i>howManyAds;i++){
		
		if(document.getElementById("indAdvertCont")){
			document.getElementById("indAdvertCont").id="indAdvertCont_"+i;
			document.getElementById("indAdvertlink").id="indAdvertlink_"+i;
			howManyAds++;
		}else{
			i=0;
		}
		
	}
	if(howManyAds>0){
		adNo=Math.ceil(Math.random()*howManyAds);
		timeAd=setTimeout('showAdBack()',3000);
	}
}

function showAdBack() {
	clearTimeout(timeAd);
	var mainWidth2 = document.getElementById("mainbody").offsetWidth;
	document.getElementById("indAdvert").style.left = ((mainWidth2/2) - 371) + "px";
	document.getElementById("indAdvert2").style.left = ((mainWidth2/2) - 360) + "px";
	document.getElementById("adNextBack").style.left = ((mainWidth2/2) - 368) + "px";
	document.getElementById("indAdvert").style.visibility = "";
	document.getElementById("indAdvert2").style.visibility = "";
	document.getElementById("adNextBack").style.visibility = "";
	showNextAd();
}

function hideCurrentAd() {
	clearTimeout(timeAd);
	document.getElementById("indAdvertCont_"+adNo).style.visibility = "hidden";
	document.getElementById("indAdvertlink_"+adNo).style.visibility = "hidden";
	showNextAd();
}

function showNextAd() {
	adNo+=1;
	if(adNo>howManyAds){
		adNo=1;
	}
	var mainWidth3 = document.getElementById("mainbody").offsetWidth;
	document.getElementById("indAdvertCont_"+adNo).style.left = ((mainWidth3/2) - 360) + "px";
	document.getElementById("indAdvertlink_"+adNo).style.left = ((mainWidth3/2) - 371) + "px";
	document.getElementById("indAdvertCont_"+adNo).style.visibility = "";
	document.getElementById("indAdvertlink_"+adNo).style.visibility = "";
	document.getElementById("currentAd").innerHTML = adNo+"&nbsp;&nbsp;of&nbsp;&nbsp;"+howManyAds;
	document.getElementById("adPercent").style.width = Math.ceil((adNo/howManyAds)*100) + "%";
	timeAd=setTimeout('hideCurrentAd()',15000);
}

function showPrevAd() {
	clearTimeout(timeAd);
	document.getElementById("indAdvertCont_"+adNo).style.visibility = "hidden";
	document.getElementById("indAdvertlink_"+adNo).style.visibility = "hidden";
	adNo-=1;
	if(adNo<1){
		adNo=howManyAds;
	}
	var mainWidth4 = document.getElementById("mainbody").offsetWidth;
	document.getElementById("indAdvertCont_"+adNo).style.left = ((mainWidth4/2) - 360) + "px";
	document.getElementById("indAdvertlink_"+adNo).style.left = ((mainWidth4/2) - 371) + "px";
	document.getElementById("indAdvertCont_"+adNo).style.visibility = "";
	document.getElementById("indAdvertlink_"+adNo).style.visibility = "";
	document.getElementById("currentAd").innerHTML = adNo+"&nbsp;&nbsp;of&nbsp;&nbsp;"+howManyAds;
	document.getElementById("adPercent").style.width = Math.ceil((adNo/howManyAds)*100) + "%";
	timeAd=setTimeout('hideCurrentAd()',15000);
}

function pauseAd() {
	clearTimeout(timeAd);
	document.getElementById("currentAd").innerHTML = "paused";
}


function elementsPosition() {
	var mainWidth = document.getElementById("mainbody").offsetWidth;
	if(document.getElementById("rightNav")){
		document.getElementById("rightNav").style.left = ((mainWidth/2) + 194) + "px";
	}
	if (document.getElementById("indAdvert")) {
		document.getElementById("indAdvert").style.left = ((mainWidth/2) - 371) + "px";
		document.getElementById("indAdvert2").style.left = ((mainWidth/2) - 360) + "px";
		document.getElementById("adNextBack").style.left = ((mainWidth/2) - 368) + "px";
		document.getElementById("indAdvertCont_"+adNo).style.left = ((mainWidth/2) - 360) + "px";
		document.getElementById("indAdvertlink_"+adNo).style.left = ((mainWidth/2) - 371) + "px";
	}
	
	if (document.getElementById("newVersion")) {
		if(document.getElementById("newVersion").style.visibility=="") {
			overFitToPage();
		}
	}
	
	
}

function linkOverColSwap(theTarget) {
	var startbg = theTarget.style.backgroundColor;
	var starttext = theTarget.style.color;
	theTarget.style.backgroundColor = starttext;
	theTarget.style.color = startbg;
}

function rightNavOver(toswap) {
	var whichDiv = toswap.id;
	document.getElementById(whichDiv).previousSibling.className="rightNavigation_1";
	document.getElementById(whichDiv).previousSibling.firstChild.style.marginLeft="4px";
	document.getElementById(whichDiv).previousSibling.lastChild.style.paddingLeft="15px";
	document.getElementById(whichDiv).previousSibling.lastChild.style.marginTop="24px";
	document.getElementById(whichDiv).style.marginTop="-101px";
	document.getElementById(whichDiv).style.height="95px";
	document.getElementById(whichDiv).firstChild.style.height="95px";
}

function rightNavOut(toswap2) {
	var whichDiv = toswap2.id;
	document.getElementById(whichDiv).previousSibling.className="rightNavigation_0";
	document.getElementById(whichDiv).previousSibling.firstChild.style.marginLeft="10px";
	document.getElementById(whichDiv).previousSibling.lastChild.style.paddingLeft="10px";
	document.getElementById(whichDiv).previousSibling.lastChild.style.marginTop="19px";
	document.getElementById(whichDiv).style.marginTop="-96px";
	document.getElementById(whichDiv).style.height="90px";
	document.getElementById(whichDiv).firstChild.style.height="90px";
}

function becomeExpOver(toswap) {
	var whichDiv = toswap.id;
	document.getElementById(whichDiv).previousSibling.firstChild.className="becomeExpert_1";
}

function becomeExpOut(toswap) {
	var whichDiv = toswap.id;
	document.getElementById(whichDiv).previousSibling.firstChild.className="becomeExpert_0";
}

function solutionOver() {
	document.getElementById("produ1img").style.borderColor="#C93333";
	document.getElementById("produ1title").style.borderColor="#C93333";
	document.getElementById("produbot").style.borderColor="#C93333";
	document.getElementById("produ1title").style.color="#C93333";
	document.getElementById("produarrow").src="/images/tri_red0.gif";
	document.getElementById("produright1").style.borderColor="#C93333";
	document.getElementById("produright1").style.color="#C93333";
	document.getElementById("produ1").style.borderColor="#C93333";
}

function solutionOut() {
	document.getElementById("produ1img").style.borderColor="#6678C5";
	document.getElementById("produ1title").style.borderColor="#6678C5";
	document.getElementById("produbot").style.borderColor="#6678C5";
	document.getElementById("produ1title").style.color="#6678C5";
	document.getElementById("produarrow").src="/images/tri_blu0.gif";
	document.getElementById("produright1").style.borderColor="#6678C5";
	document.getElementById("produright1").style.color="#6678C5";
	document.getElementById("produ1").style.borderColor="#6678C5";
}

function newsOver() {
	document.getElementById("moreNews").style.borderColor="#bc0000";
	document.getElementById("moreNews").style.backgroundColor="#C93333";
}

function newsOut() {
	document.getElementById("moreNews").style.borderColor="#001E9E";
	document.getElementById("moreNews").style.backgroundColor="#6678C5";
}

function staticOver(div1,div2) {
	document.getElementById(div1).style.borderColor="#bc0000";
	document.getElementById(div1).style.color="#bc0000";
	document.getElementById(div2).src="/images/tri_red0.gif";
}

function staticOut(div1,div2) {
	document.getElementById(div1).style.borderColor="#001E9E";
	document.getElementById(div1).style.color="#001E9E";
	document.getElementById(div2).src="/images/tri_blu0.gif";
}

function iconNavOver(whichOne) {
	var thisIcon = "iconNav"+whichOne;
	var thisText = "iconNavText"+whichOne;
	document.getElementById(thisIcon).className="iconNavigation02";
	document.getElementById(thisText).style.display="";
}

function iconNavOut(whichOne) {
	var thisIcon = "iconNav"+whichOne;
	var thisText = "iconNavText"+whichOne;
	document.getElementById(thisIcon).className="iconNavigation01";
	document.getElementById(thisText).style.display="none";
}

/*--------------set cookie--------------*/



function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
  if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function checkForVisited() {
	visited=getCookie('visited');
	if (visited==null) {
		setCookie('visited','yes');
		overFitToPage();
		
		document.getElementById("newVersion").style.visibility="";
		document.getElementById("newVersionContent").style.display="";
	}
}

function overFitToPage() {
	var mainContentHeight = (document.getElementById("mainbody").offsetHeight)+12;
	document.getElementById("newVersion").style.marginTop=(0-(mainContentHeight)) + "px";
	document.getElementById("newVersion").style.width=(document.getElementById("mainbody").offsetWidth) + "px";
	document.getElementById("newVersion").style.height=mainContentHeight + "px";
	document.getElementById("newVersionContent").style.marginTop=(0-(mainContentHeight-50)) + "px";
	document.getElementById("newVersionContent").style.left = (((document.getElementById("mainbody").offsetWidth)/2) - 360) + "px"
}