var amigoTI="";
var amigoClkId=-1;
var amigoPI=new Array();
var amigoPx=new Array();
var amigoPy=new Array();
var amigoNH=new Array();
var amigoButtonClickState=false;
var amigoCurrentButtonId;
var cswmPW=0;
var cswmPH=0;
var cswmSPnt="";
var cswmDir="";
var cswmMB=0;
var cswmSI="";
var cswmSE=new Object();
var cswmSEL=0;
var cswmSET=0;
var cswmSEH=0;
var cswmSEW=0;
var cswmBW=0;
var cswmBH=0;
var cswmAR=0;
var cswmAB=0;
var cswmSLA=0;
var cswmSTA=0;
var cswmExIS=new Image();cswmExIS.src="";
var cswmExdIS=new Image();cswmExdIS.src="";
var cswmCTH=true;
var cswmXOff=0;var cswmYOff=0;
var cswmFP=0;
var cswmSH=false;
var cswmSTI=0;

function cswmT(ms){
if(ms!="off"){if(cswmCTH!=0){amigoTI=setTimeout("cswmHP(0);",ms);}}else{clearTimeout(amigoTI);}}

function cswmST(l,g,i){
if(i){cswmSTI = setTimeout("cswmHP("+l+");cswmSP("+g+",'"+i+"');",350);}else if(l){cswmSTI = setTimeout("cswmHP("+l+");",350);}else{clearTimeout(cswmSTI);}}

function cswmShow(id,srcid,relpos,offsetX,offsetY,fixedpos){
clearTimeout(amigoTI);
if(amigoClkId!=id){
cswmHP(0);
cswmSI=srcid;cswmSPnt=relpos;amigoClkId=id;cswmDir="right";
if(getDocumentItem("amigoPopup"+id))
{if(offsetX)cswmXOff=offsetX;if(offsetY)cswmYOff=offsetY;if(fixedpos)cswmFP=fixedpos;amigoButtonClickState=true;cswmSP(id);}}}

function cswmHide(){
amigoTI=setTimeout("cswmHP(0);", 350);}

function setButtonStyle(id, bgcol_attribute, ico_style, icoOn_style, item_color, expand_src) {
var item=getDocumentItem('amigoItem'+id);
if(!item){return;}
var expand=getDocumentItem('amigoExpand'+id);
var expandIc=getDocumentItem('cswmExpandIc'+id);
var icoOn=getDocumentItem('cswmIcoOn'+id);
var bgco;
try{
	bgco=item.getAttribute(bgcol_attribute);
} catch(e){bgco = false;}
if(icoOn){
	getDocumentItem('cswmIco'+id).style.display=ico_style;
	icoOn.style.display=icoOn_style;
}
item.style.color=item_color;expand.style.color=item_color;
if(bgco){
	item.style.backgroundColor=bgco;expand.style.backgroundColor=bgco;
} else{
	item.style.backgroundColor='#e3e1e2';expand.style.backgroundColor='#e3e1e2';
}
if(expandIc){
	expandIc.src=expand_src.src;
}
}

function cswmHiI(id,l){
setButtonStyle(id, 'cswmSelColor', 'none', 'inline', '#000000', cswmExdIS);
amigoNHM(id,l);
amigoNH[l-1]=id;
}

function amigoNHM(id,l){
if(amigoNH[l-1]!=id){var count=l-1;for(count=l-1;count<amigoNH.length;count++){cswmDiI(amigoNH[count]);}amigoNH.length=l;}}

function cswmDiI(id){
setButtonStyle(id, 'cswmUnSelColor', 'inline', 'none', '#3E5FA4', cswmExIS);
}

function cswmHideSelectBox(boolHide,arrSelectList)
{if(navigator.platform!="MacPPC"){if(navigator.userAgent.indexOf("MSIE 5.5")>0){return;}if(arrSelectList){document.cswmSelects=new Array();var SelectID=new String();var iCount=0;for(iCount=0;iCount<arrSelectList.length;iCount++){SelectID=arrSelectList[iCount];document.cswmSelects[iCount]=getDocumentItem(SelectID);}}if(!document.cswmSelects){document.cswmSelects=new Array();}if(boolHide==true && !cswmSH){document.cswmSelects=new Array();var iCount=0;var iCount2=0;var Selects = document.getElementsByTagName("select");for(iCount=0;iCount<Selects.length;iCount++){if(Selects[iCount].style.visibility != "hidden"){document.cswmSelects[iCount2]=Selects[iCount];iCount2++;}}}var iCount=0;if(boolHide==true){for(iCount=0;iCount<document.cswmSelects.length;iCount++){document.cswmSelects[iCount].style.visibility="hidden";}cswmSH=true;}if(boolHide==false){for(iCount=0;iCount<document.cswmSelects.length;iCount++){document.cswmSelects[iCount].style.visibility="visible";}cswmSH=false;}}}

function cswmSP(id,itemid){ if(navigator.platform=="MacPPC"){
getDocumentItem("amigoPopup"+id).style.display="block";
getDocumentItem("amigoPopup"+id).style.left=0;
getDocumentItem("amigoPopup"+id).style.top=0;
varMacLeftOffset=getDocumentItem("amigoPopup"+id).offsetLeft;
var MacTopOffset=getDocumentItem("amigoPopup"+id).offsetTop;
}
if(!itemid){if(cswmFP){
cswmSEL=cswmXOff;cswmSET=cswmYOff;cswmSEH=1;cswmSEW=1;cswmFP=0;
}else{if(!getDocumentItem(cswmSI)){return;}cswmSE=new Object(getDocumentItem(cswmSI));var cswmPrO=cswmSE;var cswmPrT="";cswmSEL=cswmSE.offsetLeft+cswmXOff;cswmSET=cswmSE.offsetTop+cswmYOff;cswmSEH=cswmSE.offsetHeight;cswmSEW=cswmSE.offsetWidth;while(cswmPrT!="BODY"){cswmPrO=cswmPrO.offsetParent;cswmSEL+=cswmPrO.offsetLeft;cswmSET+=cswmPrO.offsetTop;cswmPrT=cswmPrO.tagName;}
}
getDocumentItem("amigoPopup"+id).style.display="block";
cswmPW=getDocumentItem("amigoPopup"+id).clientWidth;
cswmPH=getDocumentItem("amigoPopup"+id).clientHeight;
cswmBW=document.body.clientWidth;
cswmBH=document.body.clientHeight;
cswmSLA=document.body.scrollLeft;
cswmSTA=document.body.scrollTop;
switch(cswmSPnt){
case "above":amigoPx[amigoPx.length]=cswmSEL;amigoPy[amigoPy.length]=cswmSET-cswmPH;cswmCA();cswmCR();break;
case "below":amigoPx[amigoPx.length]=cswmSEL;amigoPy[amigoPy.length]=cswmSET+cswmSEH;cswmCB();cswmCR();break;
case "right":amigoPx[amigoPx.length]=cswmSEL+cswmSEW;amigoPy[amigoPy.length]=cswmSET;cswmCR();cswmCB();break;
case "left":amigoPx[amigoPx.length]=cswmSEL-cswmPW;amigoPy[amigoPy.length]=cswmSET;cswmCL();cswmCB();cswmDir="left";
break;
}
cswmXOff=0;cswmYOff=0;getDocumentItem("amigoPopup"+id).style.left=amigoPx[amigoPx.length-1];
getDocumentItem("amigoPopup"+id).style.top=amigoPy[amigoPy.length-1];
amigoPI[amigoPI.length]=id;}
else{
var d;d=document;amigoPx[amigoPx.length]=getDocumentItem("amigoPopup"+amigoPI[amigoPI.length-1]).clientWidth+amigoPx[amigoPx.length-1]-4;var szPrE="";
if(getDocumentItem("amigoItem"+itemid).parentElement.offsetTop==0){
	if(navigator.platform=="MacPPC"){var szPrE="parentElement.parentElement.";}
	else if(getDocumentItem("amigoItem"+itemid).parentElement.parentElement.parentElement.parentElement.className!="amigoPopupBox"){
		var szPrE="parentElement.parentElement.parentElement.";}
}
amigoPy[amigoPy.length]=eval("d.all[\"amigoItem"+itemid+"\"].parentElement."+szPrE+"offsetTop")+amigoPy[amigoPy.length-1];
getDocumentItem("amigoPopup"+id).style.display="block";
cswmPW=getDocumentItem("amigoPopup"+id).clientWidth;
cswmPH=getDocumentItem("amigoPopup"+id).clientHeight;
var cswmPrW=getDocumentItem("amigoPopup"+amigoPI[amigoPI.length-1]).clientWidth;
cswmAR=cswmBW-amigoPx[amigoPx.length-1]+cswmSLA;cswmAB=cswmBH-amigoPy[amigoPy.length-1]+cswmSTA;
if(amigoPx[amigoPx.length-2]==cswmSLA){cswmDir="right";}if((cswmAR<cswmPW)||(cswmDir=="left")){cswmMB=(amigoPx[amigoPx.length-1]-cswmPW-cswmPrW)+8;if((cswmMB>=0)&&(cswmMB>cswmSLA)){cswmDir="left";}else{cswmMB=cswmSLA;}amigoPx[amigoPx.length-1]=cswmMB;}if(cswmAB<cswmPH){cswmMB=amigoPy[amigoPy.length-1]-(cswmPH-cswmAB);if(cswmMB<0){cswmMB=cswmSTA;}amigoPy[amigoPy.length-1]=cswmMB;}
getDocumentItem("amigoPopup"+id).style.left=amigoPx[amigoPx.length-1];
getDocumentItem("amigoPopup"+id).style.top=amigoPy[amigoPy.length-1];
amigoPI[amigoPI.length]=id;}
if(navigator.platform=="MacPPC"){
getDocumentItem("amigoPopup"+id).style.left-=MacLeftOffset;
getDocumentItem("amigoPopup"+id).style.top-=MacTopOffset;
}
if(navigator.platform!='MacPPC'){if(navigator.userAgent.indexOf('MSIE 5.0')<=0){cswmIFSH(id);}}
}

function cswmHP(level){
if(amigoClkId==-1){return false;}
else if(level==0){
	amigoClkId=-1;
	var id = amigoPI[0];
	var count=0;
	for(count=0;count<amigoNH.length;count++){
	cswmDiI(amigoNH[count]);}
	amigoNH.length=0;
	if (id != null) {
		amigoButtonNormal("amigoMenuButton"+id);
	}
	amigoButtonClickState=false;
}
var count=level;
for(count=level;count<amigoPI.length;count++){
	getDocumentItem("amigoPopup"+amigoPI[count]).style.display="none";
	if(getDocumentItem('cswmIFrame'+amigoPI[count])){
	getDocumentItem('cswmIFrame'+amigoPI[count]).style.display='none';}
}
amigoPI.length=level;amigoPx.length=level;amigoPy.length=level;
}

function cswmIFSH(id){if(document.readyState!='complete'){return false;}var ifr;if(!getDocumentItem('cswmIFrame'+id)){ifr="<iframe src=\"javascript:false;\" id=\"cswmIFrame" + id + "\" scrolling=\"no\" frameborder=\"0\" style=\"position:absolute;top:0x;left:0px;z-index:998;display:none\"></iframe>";document.body.insertAdjacentHTML('beforeEnd',ifr);}if(getDocumentItem('cswmIFrame'+id)){ifr=getDocumentItem('cswmIFrame'+id).style;ifr.top=amigoPy[amigoPy.length-1];ifr.left=amigoPx[amigoPx.length-1];ifr.width=cswmPW;ifr.height=cswmPH;ifr.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';ifr.display='block';}}

function cswmCR(){
cswmAR=(cswmBW+cswmSLA)-amigoPx[amigoPx.length-1];if(cswmAR<cswmPW){if(cswmSPnt=="below"||cswmSPnt=="above"){cswmMB=cswmPx[amigoPx.length-1]-(cswmPW-cswmAR);if(cswmMB<0||cswmMB<cswmSLA){cswmMB=cswmSLA;}amigoPx[amigoPx.length-1]=cswmMB;}else{cswmMB=cswmSEL-cswmPW;if(cswmMB>=0){amigoPx[amigoPx.length-1]=cswmMB;}}}}

function cswmCL(){
if(amigoPx[amigoPx.length-1]<(cswmSLA)){amigoPx[amigoPx.length-1]=cswmSEL+cswmSEW;cswmCR();}}

function cswmCB(){
cswmAB=(cswmBH+cswmSTA)-amigoPy[amigoPy.length-1];if(cswmAB<cswmPH){if(cswmSPnt=="below"){cswmMB=amigoPy[amigoPy.length-1]-cswmPH-cswmSEH;if(cswmMB>=0){amigoPy[amigoPy.length-1]=cswmMB;}}else{cswmMB=amigoPy[amigoPy.length-1]-(cswmPH-cswmAB);if(cswmMB<0||cswmMB<cswmSTA){cswmMB=cswmSTA;}amigoPy[amigoPy.length-1]=cswmMB;}}}

function cswmCA(){
if(amigoPy[amigoPy.length-1]<(cswmSTA)){amigoPy[amigoPy.length-1]=cswmSET+cswmSEH;cswmCB();}}

function cswmShowInFrame(MenuID,x,y){
x+=document.body.scrollLeft;y+=document.body.scrollTop;cswmShow(MenuID,'','below',x,y,1);}

function cswmRefresh(){}

function amigoButtonDown(id,gid){
amigoCurrentButtonId=id;amigoButtonSunken(id);cswmShow(gid, id, 'right', -1, 1);}

function amigoButtonSelect(id,gid){
if(!amigoButtonClickState){amigoButtonRaised(id);}else{amigoButtonNormal(amigoCurrentButtonId);clearTimeout(amigoTI);amigoButtonDown(id,gid);}}

function amigoButtonUnSelect(id){
if(!amigoButtonClickState){amigoButtonNormal(id);}else{cswmHide();}}

function amigoButtonRaised(id){
var obj = getDocumentItem(id).style;obj.borderTopColor = "#ffffff";obj.borderLeftColor = "#ffffff";obj.borderBottomColor = "#808080";obj.borderRightColor = "#808080";obj.backgroundColor = "#d4d0c8";obj.borderWidth='1px';obj.paddingBottom = "4px";obj.paddingTop = "4px";obj.paddingLeft = "6px";obj.paddingRight = "6px";getDocumentItem(id+"Caption").style.color = "#000000";}

function amigoButtonSunken(id){
var obj = getDocumentItem(id).style;
obj.borderTopColor = "#764622";obj.borderLeftColor = "#764622";obj.borderBottomColor = "#764622";obj.borderRightColor = "#764622";obj.backgroundColor = "#e3e1e2";
obj.borderWidth='1px';
obj.borderTop="solid  1px";obj.borderBottom="solid  1px";obj.borderRight="solid  1px";obj.borderLeft="solid  1px";
obj.paddingBottom = "3px";obj.paddingTop = "7px";obj.paddingLeft = "3px";obj.paddingRight = "0px";
getDocumentItem(id+"Caption").style.color = "#000000";
}

function amigoButtonNormal(id){
var obj = getDocumentItem(id).style;
obj.borderTopColor = "";obj.borderLeftColor = "";obj.borderBottomColor = "";obj.borderRightColor = "";
obj.backgroundColor = "";obj.borderWidth='0px';obj.paddingBottom = "5px";obj.paddingTop = "5px";obj.paddingLeft = "7px";obj.paddingRight = "0px";
getDocumentItem(id+"Caption").style.color = "#3E5FA4";
}

function cswmMenuBarInit(){}

function getDocumentItem(id) {
	var res;
	
	if (document.all) {
		res = document.all(id);
	} else if (document.layers) {
	    res = document.layers[id];
	} else {
		res = document.getElementById(id);
	}
	
	return res;	
}

function showMenu_en(currentPage) {
	var choices = new Array("Presentation", "Consultancy & Services", "Solutions", "Demonstrations & Download", "Buy Now", "Jobs", "Contact us");
	var menu_links = new Array("index.phtml", "", "", "", "Orders_EscriptValidationTool.phtml", "JobOffers.phtml", "");
	var sub_choices = new Array(new Array("Mission statement", "Presentation", "References"), 
		new Array("Customer Relationship Management", "Contact Centers", "Business Intelligence","Software Development", "Project Management"), 
		new Array("Control of Siebel e-script conformity", "Java Technologies", "Open Source Solutions", "Workgroup Database"),
		new Array("Download Escript Validation Tool", "Demonstration e-commerce solution (osCommerce)", "Demonstration document management (Moregroupware)", "Demonstration bug tracking (Mantis)"), 
		new Array("Buy Escript Validation Tool"),
		new Array("Job Offers"), 
		new Array("Register", "Contacts"));
	var sub_links = new Array(new Array("index.phtml", "pres.phtml", "references.phtml"), 
		new Array("ConsultancyCRM.phtml", "ConsultancyContactCenter.phtml", "ConsultancyBI.phtml", "ConsultancySoftware.phtml", "ProjectManagement.phtml"), 
		new Array("SolutionEscriptValidationTool.phtml", "SolutionsTechnologies.phtml", "SolutionsOpenSource.phtml", "SolutionsWorkgroupDatabase.phtml"), 
		new Array("Demo_EscriptValidationTool.phtml", "Demo_ecommerce.phtml", "Demo_docManagement.phtml", "Demo_bugTracking.phtml"),
		new Array("Orders_EscriptValidationTool.phtml"),
		new Array("JobOffers.phtml"),
		new Array("signup.phtml", "Contact.phtml"));
	
	addSubMenus(sub_choices, sub_links);
	showMenu(choices, menu_links);
	showLanguageLink("Version française", currentPage + "_fr.phtml", choices.length);
}

function showMenu_fr(currentPage) {
	var choices = new Array("Présentation", "Conseils & Services", "Solutions", "Démonstrations & Téléchargements", "Acheter", "Emplois", "Contactez nous");
	var menu_links = new Array("index_fr.phtml", "", "", "", "Orders_EscriptValidationTool_fr.phtml", "JobOffers_fr.phtml", "");
	var sub_choices = new Array(new Array("Valeurs", "Présentation", "Références"), 
		new Array("Gestion de la Relation Client", "Centre de Contacts", "Informatique Décisionnelle","Développement Logiciel", "Management de Projet"), 
		new Array("Contrôle de conformité des scripts Siebel", "Technologies Java", "Solutions Open Source", "Base de données pour groupes de travail"), 
		new Array("Télécharger Escript Validation Tool", "Démonstration solution de commerce en ligne (osCommerce)", "Démonstration solution de gestion documentaire en ligne (Moregroupware)", "Démonstration solution de gestion d'anomalies (Mantis)"), 
		new Array("Acheter Escript Validation Tool"),
		new Array("Offres d'emploi"), 
		new Array("Prise de contact", "Contacts"));
	var sub_links = new Array(new Array("index_fr.phtml", "pres_fr.phtml", "references_fr.phtml"), 
		new Array("ConsultancyCRM_fr.phtml", "ConsultancyContactCenter_fr.phtml", "ConsultancyBI_fr.phtml", "ConsultancySoftware_fr.phtml", "ProjectManagement_fr.phtml"), 
		new Array("SolutionEscriptValidationTool_fr.phtml", "SolutionsTechnologies_fr.phtml", "SolutionsOpenSource_fr.phtml", "SolutionsWorkgroupDatabase_fr.phtml"), 
		new Array("Demo_EscriptValidationTool_fr.phtml", "Demo_ecommerce_fr.phtml", "Demo_docManagement_fr.phtml", "Demo_bugTracking_fr.phtml"),
		new Array("Orders_EscriptValidationTool_fr.phtml"),
		new Array("JobOffers_fr.phtml"),
		new Array("signup_fr.phtml", "Contact_fr.phtml"));
	
	addSubMenus(sub_choices, sub_links);
	showMenu(choices, menu_links);
	showLanguageLink("English version", currentPage + ".phtml", choices.length);
}
	
function showMenu(choices, menu_links) {
 	var output = "";
	var i;
	var obj_class;
	
	for (i=0; i<choices.length; i++) {
		if (menu_links[i] != "") {
			obj_class="amigoLinkButton";
		} else {
			obj_class="amigoButton";
		}
		output = output + '<div unselectable="on" id="amigoMenuButtonRoot_' + i + '" class="' + obj_class + '"'
			+ ' onmouseover="amigoButtonDown(this.id, \'Root_' + i + '\');"'
			+ ' onmouseout="amigoButtonUnSelect(this.id);"'
			+ ' onmousedown="amigoButtonDown(this.id, \'Root_' + i + '\');"'
			+ ' style="width:100%;border-width:0px;padding-top:5px;padding-bottom:5px;padding-left:7px;padding-right:0px;"';
		if (menu_links[i] != "") {
			output = output + ' onClick="cswmHP(0);location.href=\'' + menu_links[i] + '\';"';
		}
		
		output = output + '>';
		output = output + '<table width="100%" border=0 cellpadding=0 cellspacing=0>';
		output = output + '<tr><td width="100%" class="amigoButtonFont" id="amigoMenuButtonRoot_' + i + 'Caption">';
		output = output + choices[i];
		output = output + '</td></tr> </table></div>';
	}	
	
	putHtmlMenu("amigoMenuRoot", output);
}

function showLanguageLink(language_name, language_link, item_number) {
 	var output;

	//output = '<a href="' + language_link +'">';
	//output = output + '<div align="center" class="accueil">' + language_name + '</div></a>';

	output = '<div unselectable="on" id="amigoMenuButtonRoot_' + item_number + '" align="center" class="amigoLanguageLink"'
			+ ' onmouseover="amigoButtonDown(this.id, \'Root_' + item_number + '\');"'
			+ ' onmouseout="amigoButtonUnSelect(this.id);"'
			+ ' onmousedown="amigoButtonDown(this.id, \'Root_' + item_number + '\');"'
			+ ' style="width:100%;border-width:0px;padding-top:5px;padding-bottom:5px;padding-left:7px;padding-right:0px;"'
			+ ' onClick="cswmHP(0);location.href=\'' + language_link + '\';">';
	output = output + '<table width="100%" border=0 cellpadding=0 cellspacing=0>';
	output = output + '<tr><td width="100%" class="amigoLanguageLink" id="amigoMenuButtonRoot_' + item_number + 'Caption">';
	output = output + language_name;
	output = output + '</td></tr> </table></div>';

	putHtmlMenu("amigoMenuLanguage", output);

}

function addSubMenus(sub_choices, sub_links) {
 	var output = "";
	var i;
	var j;
	var cur_links;
	var cur_choices;
	
	for (i=0; i<sub_choices.length; i++) {
		output = output + '<div id="amigoPopupRoot_' + i + '" class="amigoPopupBox" onselectstart="return false;">';
		output = output + '<table border=0 cellpadding=0 cellspacing=0><tr><td>';
		output = output + '<div style="border-style:solid; border-width: 1px; border-color:#764622 #764622 #764622 #764622">';
		output = output + '<table border=0 cellpadding=0 cellspacing=0>';
		if (sub_choices[i] != null) {
			cur_links = sub_links[i];
			cur_choices = sub_choices[i];
			for(j=0; j<cur_choices.length; j++) {
				output = output + '<tr onmouseover="cswmT(\'off\');cswmHiI(\'Root_' + i + '_' + j + '\',1);cswmST(1);"';
				output = output + ' onmouseout="cswmT(350);cswmST();"';
				output = output + ' onClick="cswmHP(0);location.href=\'' + cur_links[j] + '\';">';
				output = output + '<td unselectable="on" nowrap bgcolor="#e3e1e2" id="amigoItemRoot_' + i + '_' + j + '" class="amigoItem">';
				output = output + cur_choices[j];
				output = output + '</td> <td unselectable="on" bgcolor="#e3e1e2" id="amigoExpandRoot_'  + i + '_' + j + '" class="amigoExpand">';
				output = output + '</td></tr>'; 
			}
		}
	 	output = output + '</table></div></td></tr>	</table></div>';
	}
	
	putHtmlMenu("amigoSubMenus", output);
}

function putHtmlMenu(menuId, output) {
	var myObj;
	
	if (document.all) {
		document.all(menuId).innerHTML = output;
	}
	else if (document.layers) {
	    document.layers[menuId].document.open();
	    document.layers[menuId].document.writeln(output);
	    document.layers[menuId].document.close();
	}
	else {
		myObj = document.getElementById(menuId);
		if (myObj) {
			myObj.innerHTML = output;
		} 
	}
}

function openWindow(targetUrl, windowName) {
	try {
		var newWindow=window.open(targetUrl, windowName, 'scrollbars=1, resizable=1, width=800, height=700'); 
		if (! newWindow) {
			// Could not open window, just redirect
			window.location=targetUrl;
		} else {
			history.go(-1); 
			newWindow.focus();
		}
	} catch (ex) {
		// Could not open window, just redirect
		Window.location=targetUrl;
	}
}

