////////////////////////////////////////////////////////////////////////////////////////////////////////

//											2003-2004 :- Security-info.com

//

//

// Dynamic menu

// This menu is developped for www.security-info.com

//

// Author		  : Prabath Rathugama.

// Developped for : eCommerce Technologies - Sri Lanka.

////////////////////////////////////////////////////////////////////////////////////////////////////////
	var objDiv = null;
	var strImgPath = "fr/templates/fr/images/menu/";
	var BackCount = '';

	//Main Menu object
	function objMenu(){
		//this.mnuLeft = 10;
		this.mnuTop = 10;
		this.mnuHeading = "";
		this.mnuImagePath ="";

		strImgPath = this.mnuImagePath;

		//Font styles
		this.mnuFontFace = 'verdana';
		this.mnuFontSize = 1;
		this.mnuFontColor = 'red';
		this.weight = 'bold';

		this.mainMenuID = 0;
		this.mainMenuTitle = "";

		this.mnuID = new Array();
		this.mnuTitle = new Array();
		this.mnuURL = new Array();

		this.Mncontainer = "";
		this.strFnlMenu = "";
		this.init_menu = init_menu;
		this.AddMenu = AddMenu;
		this.show_menu  = show_menu;
		this.on_out = on_out;
		this.CreateLayer = CreateLayer;

		this.mouse_event = mouse_event;
		this.mouse_move = mouse_move;

		this.HideMenus = HideMenus;
		this.mouse_over = mouse_over;
		this.mouse_out = mouse_out;
	}

	//Handle all mouse events
	function mouse_event(dv){
		var d = window.event || window.Event;
		var itm = document.getElementById(dv);
		var itR=0,itL=0,itT=0,itB=0;

		if(itm){ //For IE
			objDiv = dv;
			itR = parseInt(itm.style.width) + parseInt(itm.style.left);
			itL = parseInt(itm.style.left);
			itT = parseInt(itm.style.top);
			itB = parseInt(itm.style.height) ;

			if((itL > d.x-2) || itR < d.x || (itT+32) > d.y || itB > d.y ){
				itm.style.top=-1000;

				//This should be an external function
				ChangeButton(false);
			}


			//window.status = itB +  ' - ' + d.y;
		}


		if(document.captureEvents){
			document.captureEvents(Event.MOUSEMOVE)
			document.onmousemove = mouse_move;
		}
	}


	function mouse_move(e){ //For Netscape
		var itm = document.getElementById(objDiv);

		if(itm){
			var itR=0,itL=0,itT=0,itB=0;
			itR = parseInt(itm.style.width) + parseInt(itm.style.left);
			itL = 0; //parseInt(itm.style.left);
			itT = parseInt(itm.style.top);
			itB = parseInt(itm.style.height) ;

			itR = parseInt(itm.style.width) + parseInt(itm.style.left);
			itL = parseInt(itm.style.left);
			if((itL > e.clientX-2) || itR < e.clientX  || (itT+20) > e.clientY || itB > e.clientY ){
				itm.style.top=-1000;
				//alert('');
				//This should be an external function
				ChangeButton(false);
				document.onmousemove = null;
				document.releaseEvents(Event.MOUSEMOVE)
			}
		}
	}
	function CreateLayer(id){
		var container=null;;
		if(document.all){ //For microsoft internet explorer

			if(!document.all("mnuHost"+id)){
				document.writeln('<SPAN ID ="mnuHost'+ id + '"></SPAN>');
				container = document.all("mnuHost"+id);
			}

		}else if(document.getElementById){ //For netscape naviagtor

			if(!document.getElementById("mnuHost"+id)){
				container = document.createElement("span");
				container.id = "mnuHost"+id;
				document.body.appendChild(container);
			}
		}
		this.Mncontainer = container;
	}


	function mouse_over(tr,i,mx){
		var tmpTr = document.getElementById(tr.id);
		var tmpTdm = document.getElementById('tdm'+i);
		var tmpTdT = document.getElementById('img'+(i-1));
		var tmpTdB = document.getElementById('img'+(i));
		var imgMT = document.getElementById('imgT');

		if(tmpTr){
			//tmpTr.background = 'hilight.gif';
			tmpTr.className  = "mnuMenuOver";
			if(tmpTdT){
				tmpTdT.src = strImgPath + 'bhl.gif';
			}


			if(tmpTdB){
				if(i==mx-1){
					var imgMB = document.getElementById('img'+(mx-1));
					if(imgMB){
						imgMB.src = strImgPath+'mbhl.gif';
					}
				}
				else if(i==0){
					imgMT.src=strImgPath+'mthl.gif';
					tmpTdB.src = strImgPath+'thl.gif';
				}
				else{
					tmpTdB.src = strImgPath+'thl.gif';
				}
			}
		}
	}


	function mouse_out(tr,i,mx){
		var tmpTr = document.getElementById(tr.id);
		var tmpTdT = document.getElementById('img'+(i-1));
		var tmpTdB = document.getElementById('img'+(i));

		if(tmpTr){
			tmpTr.className  = "mnuLeftRightBorder";

			if(tmpTdT){
				tmpTdT.src = strImgPath+'mnurow.gif';
			}

			if(tmpTdB){
				tmpTdB.src = strImgPath+'mnurow.gif';
			}

			var imgMB = document.getElementById('img'+(mx-1));
			var imgMT = document.getElementById('imgT');

			if(imgMB){
				imgMB.src = strImgPath+'mnubotbar.gif';
			}

			if(imgMT){
				imgMT.src = strImgPath+'mnutopbar.gif';
			}
		}
	}


	function init_menu(){
		var menuProp = null;
		var strMenu="";
		var strMenuFont = "";
		var strItem = "";
		var strBg ="";
		var mx = 0;

		//Write menus
		strMenu += '<DIV style="WIDTH: 182px;POSITION: absolute; HEIGHT: 66px;TOP:30;LEFT:0;z-index:5">';
		strMenu += '<table width="182" border="0" cellpadding="0" cellspacing="0" >';

		mx = this.mnuID.length ;
		strMenuFont = '<font face="' + this.mnuFontFace + '" size="' + this.mnuFontSize + '" color="' + this.mnuFontColor + '" cursor="hand"><b>';

		//Menu Heading
		strBg = '<img src="'+strImgPath+'mnutopbar.gif" height="5" width="182" border="0" id="imgT">';
		strMenu +='<tr>';
		strMenu +='<td width="182"  height="5" valign="middle">' + strBg  +  '</td>';
		strMenu +='</tr>';

		for(i=0;i<mx;i++){
			//Create menu string
			strItem = '<font style="cursor:hand" onclick="javascript:window.location.href=\''+ this.mnuURL[i]  + '\'">' + this.mnuTitle[i] + '</font>';
			strMenu +='<tr id="tr'+ i  + '" bgcolor="#F0F0F0" onmouseover="javascript:mouse_over(this,' + i + ','+ mx +');" onmouseout="javascript:mouse_out(this,' + i + ',' + mx + ');" id="tr'+ i + '" onclick="javascript:window.location.href=\''+ this.mnuURL[i]  + '\'">';
			strMenu +='<td class="mnuLeftRightBorder" height="5" width="180" valign="middle" id="td'+ i + '">&nbsp;&nbsp;&nbsp;&nbsp;' +  strItem   +  '</td>';
			strMenu +='</tr>';

			if(i<mx-1){
				strBg = '<img src="'+strImgPath+'mnurow.gif" height="11" width="180" border="0" id="img'+ i  + '">';
				strMenu +='<tr  bgcolor="#F0F0F0">';
				strMenu +='<td class="mnuLeftRightBorder" id="tdg' + i + '">'+ strBg +'</td>';
				strMenu +='</tr>';
			}
		}

		//Menu Bottom
		strBg = '<img src="'+strImgPath+'mnubotbar.gif" height="5" width="182" border="0" id="img'+(mx-1)+'">';
		strMenu +='<tr>';
		strMenu +='<td width="182"   height="10" valign="top">' + strBg  +  '</td>';
		strMenu +='</tr>';
		strMenu +='<tr>';
		strMenu +='<td width="182"   height="2" valign="middle" onmouseover="javascript:HideMenus('+(this.mainMenuID)+','+(this.mainMenuID)+',true);">&nbsp;</td>';
		strMenu +='</tr>';
		strMenu += '</table></DIV></DIV>';

		this.strFnlMenu= strMenu;
	}


	//This function hides all given menus befor display a menu
	function HideMenus(Start,End,Md){
		var objElement = null;
		var changed = true;

		for(i=Start;i<=End;i++){
			//For both Netsape and IE
			objElement = document.getElementById('mnuHost'+i);
			if(objElement){
				objElement.innerHTML = '';

				if(Md && changed ){
					ChangeButton(false);
					changed = false;
				}
			}
		}
	}

	//Display created menu
	function show_menu(MainMenuID){
		var objElement = null;
		objElement = document.getElementById('mnuHost'+MainMenuID);
		var tst = document.getElementById('tdd1');

		if(objElement){
			//This should be an external function
			ChangeButton(true);

			///////////////////////////////////////////////////////////////////////////////////
			var mnuLeft = 0;

			if(document.all){ //For IE
				mnuLeft =  ((document.body.scrollWidth - 760)/2) +  this.mnuLeft;
				if((mnuLeft+340) > document.body.offsetWidth){
					mnuLeft =   document.body.offsetWidth - 540;
				}
				//mnuLeft =  this.mnuLeft;
				mnuLeft =  mnuLeft - 120;
			}else if(document.getElementById){ //For netscape
				mnuLeft =  ((window.innerWidth - 760)/2) +  this.mnuLeft;

				if((mnuLeft+140) > document.body.offsetWidth){
					mnuLeft =   document.body.offsetWidth - 140;
				}
			}
			///////////////////////////////////////////////////////////////////////////////////
			//var strTmp = '<DIV style="WIDTH: 103px; POSITION: absolute;TOP:'+ this.mnuTop +';LEFT:' + mnuLeft + ';" id="dvHost'+this.mainMenuID+'" onmouseout="mouse_event(\'dvHost' + this.mainMenuID + '\');">';
			var strTmp = '<DIV style="WIDTH: 180px; POSITION: absolute;TOP:'+ this.mnuTop +';LEFT:' + mnuLeft + ';" id="dvHost'+this.mainMenuID+'" onmouseout="mouse_event(\'dvHost' + this.mainMenuID + '\');">';
			objElement.innerHTML = strTmp + this.strFnlMenu;
		}
	}

	function on_over(tr){
		tr.style.className = "asss";
	}

	//On menu mouse out
	function on_out(id){
		var dv = document.getElementById(id);
		 if(dv){
			dv.style.top = -1000;
		}
	}

	function tmpMenu(MainID){
		this.mainMenuID[MainID] = AddMenu;
	}

	//Adding menus to the main menu
	function AddMenu(MainID,MainMenu,MenuID,MenuTitle,URL,NewMenu){
		this.mnuID[this.mnuID.length] = MenuID;
		this.mnuTitle[this.mnuTitle.length] = MenuTitle;
		this.mnuURL[this.mnuURL.length] = URL;
		this.mainMenuID = MainID;
		this.mainMenuTitle = MainMenu;
	}

// popup window
function popupWindow() {
  window.open('../common/popup.php','popUp','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=264,height=273');
}
function PopupWindowEng(no) {
  var theWIN;
  var thiswidth;
  var thisheight;
  	if (no == 2){
		thiswidth = 264;
		thisheight = 240;
		theWIN = window.open('index.php?module=popups&action=credit','popUp','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=264,height=200');
	}
	else{
		thiswidth = 264;
		thisheight = 415;
		theWIN = window.open('index.php?module=popups&action=mentionslegales','popUp','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=264,height=355');
	}
	theWIN.resizeTo(thiswidth,thisheight) ;
	theWIN.focus() ;
}
function PopupWindowHomeNousContacterEng() {
 var theWIN;
  var thiswidth;
  var thisheight;
  thiswidth = 264;
	thisheight = 332;
 	theWIN = window.open('index.php?module=popups&action=nouscontacter','popUp','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=264,height=273');
 	theWIN.resizeTo(thiswidth,thisheight) ;
	theWIN.focus() ;
}
