MENU1 = new Array (
	93,15,
	"#303468","#FFFFFF","#C8C8D8",  // color, bgcolor, hicolor
	"Verdana",1,
	"#303468",1,
	"Profile", "ourcompany.htm",
	"Vision", "ourcompany.htm#vi",
	"Mission", "ourcompany.htm#mis",
	"Set of Values", "ourcompany.htm#set"
);

MENU2 = new Array (
	285,15,
	"#303468","#FFFFFF","#C8C8D8",  // color, bgcolor, hicolor
	"Verdana",1,
	"#303468",1,
	"Retailer and Wholesaler of Industrial Chemicals", "ourbusinesses/retail.htm",
	"Raw Materials for Special Products", "ourbusinesses/raw.htm",
	"Screen Printing Supplies and Machineries", "ourbusinesses/printing.htm",
	"As an Indentor", "ourbusinesses/indentor.htm",
	"Laboratory Reagents and Equipments", "ourbusinesses/lab.htm",
	"Other Services", "ourbusinesses/services.htm",
	"Realty", "ourbusinesses/realty.htm",
	"List of Available Chemicals", "ourbusinesses/chemlist.htm"
	
);

MENU3 = new Array (
	105,20,
	"#F9D840","#000000","#405E8F",  // color, bgcolor, hicolor
	"Arial",2,
	"#F9D840",1,
	"Stuff Magazine", "stuff.htm",
	"Gigguide", "gig.htm",
	"Indigo", "project.htm"
);

MENU4 = new Array (
	85,20,
	"#F9D840","#000000","#405E8F",  // color, bgcolor, hicolor
	"Arial",2,
	"#F9D840",1,
	"XTras", "others.htm"
	// "XPort", "downloads.htm",
	// "XCitements", "games.htm"
);

var activeMenu 		= null;
var activeMenuItem 	= null;
var MENUS 		= new Array(1);
var isLoaded		= 0;

// [ setup ] ------------------------------------------------------------------

function createMenusNS()
{
	var menuCount = 1;

	while(eval("window.MENU"+menuCount)) {
		menuArray = eval("MENU"+menuCount);
		
		menu = new Layer(menuArray[0],window);
		
		MENUS[menuCount] 	= menu;
		menu.menuNdx 			= menuCount;
		menu.onmouseout 		= menu_out;
		menu.show				= menu_show;
		menu.hide				= menu_hide;
		
		style 				= menu;
		style.visibility 	= 'hide';
		style.color 		= menuArray[2];
		style.bgColor 		= menuArray[7];
		style.left 			= 0;
		style.top 			= 0;
		style.zIndex 		= 100;
				
		prevstyle = null;
		ndx = 9;
		while (menuArray[ndx]) {
			
			mitem = new Layer(menuArray[0],menu);
			mitem.document.write ('&nbsp;<font color="'+menuArray[2]+'" face="'+menuArray[5]+'" size="'+menuArray[6]+'">'+menuArray[ndx]+'</font>');
			mitem.document.close();
			mitem.captureEvents(Event.MOUSEUP);
			
			mitem.menu 			= menu;
			mitem.onmouseover 	= menuitem_over;
			mitem.onmouseup 	= menuitem_click;
			mitem.lolite 		= menuitem_lolite;
			mitem.hilite 		= menuitem_hilite;
			mitem.href 			= menuArray[ndx+1];

			menu.lastitem 		= mitem;

			style = mitem;

			style.visibility 	= 'inherit';
			style.zIndex		= 101;
			style.bgColor 		= menuArray[3];
			style.locolor 		= menuArray[3];
			style.hicolor 		= menuArray[4];

			style.left 			= menuArray[8];
			style.top 			= (prevstyle == null) ? menuArray[8] : prevstyle.top + prevstyle.clip.height;
			style.clip.right 	= menuArray[0]-menuArray[8]*2;
			style.clip.bottom 	= menuArray[1];

			prevstyle 			= style;
									
			ndx += 2;
		}	
		
		menu.clip.right = menuArray[0];
		menu.clip.bottom = menu.lastitem.top + menu.lastitem.clip.height + menuArray[8];
		
		menuCount++;			
	}
	isLoaded = 1;
}


function createMenusIE()
{	
	// [ PHASE 1 : Create ] --------------------------------------------------------------------------------------------
	menuCount = 1;
	menuStr = "";
	while(eval("window.MENU"+menuCount)) {
		menuArray 	= eval("MENU"+menuCount);
		menuStr    += '<span id="rMENU'+menuCount+'" style="position:absolute">';
		ndx 		= 9;
		while (menuArray[ndx]) {
			menuStr += 	'<span id="rMENU'+menuCount+'ITEM'+((ndx-9)/2+1)+'" style="position:absolute">'+
							'<font color="'+menuArray[2]+'" face="'+menuArray[5]+'" size="'+menuArray[6]+'">&nbsp;'+
							menuArray[ndx]+
							'</font>'+
						'</span>';							  
			ndx += 2;
		}
		menuStr += '</span>';
		menuCount++;
	}
	
	window.document.body.insertAdjacentHTML('BeforeEnd',menuStr);
	
	// [ PHASE 2 : Setup/Connect ] -------------------------------------------------------------------------------------
	menuCount = 1;
		
	while(eval("window.MENU"+menuCount)) {
		menuArray = eval("MENU"+menuCount);
				
		menu = document.all["rMENU"+menuCount];
		
		MENUS[menuCount]	= menu;
		menu.menuNdx 			= menuCount;
		menu.onmouseout 		= menu_out;
		menu.show				= menu_show;
		menu.hide				= menu_hide;
		menu.timerid			= null;
		
		style 					= menu.style;
		style.visibility 		= 'hidden';
		style.color 			= menuArray[2];
		style.backgroundColor 	= menuArray[7];
		style.left 				= 0;
		style.top 				= 0;
		style.zIndex 			= 100;
		style.pixelWidth 		= menuArray[0];
		
		prevstyle = null;
		ndx = 9;
		while (menuArray[ndx]) {
			mitem = document.all["rMENU"+menuCount+"ITEM"+((ndx-9)/2+1)];

			mitem.menu 			= menu;
			mitem.onmouseover 	= menuitem_over;
			mitem.onmouseup 	= menuitem_click;
			mitem.lolite 		= menuitem_lolite;
			mitem.hilite 		= menuitem_hilite;
			mitem.href			= menuArray[ndx+1];

			menu.lastitem 		= mitem;

			style 					= mitem.style;
			style.visibility 		= 'inherit';
			style.zIndex 			= 101;
			style.backgroundColor 	= menuArray[3];
			style.locolor 			= menuArray[3];
			style.hicolor 			= menuArray[4];
			style.cursor 			= "hand";

			style.pixelLeft 		= menuArray[8];
			style.pixelTop 			= (prevstyle == null) ? menuArray[8] : prevstyle.pixelTop + prevstyle.pixelHeight;
			style.pixelWidth 		= menuArray[0]-menuArray[8]*2;
			style.pixelHeight 		= menuArray[1];

			prevstyle = style;
									
			ndx += 2;
		}
		
		menu.style.pixelHeight = menu.lastitem.style.pixelTop + menu.lastitem.style.pixelHeight + menuArray[8];
		
		menuCount++;			
	}
	isLoaded = 1;
}

function resize()
{
	if (document.layers) {
		if (saveInnerWidth < window.innerWidth || 
			saveInnerWidth > window.innerWidth || 
			saveInnerHeight > window.innerHeight || 
			saveInnerHeight < window.innerHeight ) 
    	window.location.reload();
	}
}

function startup()
{
	if (document.layers) 	createMenusNS();
	else					createMenusIE();
	
	window.onresize=resize;
	window.saveInnerWidth = window.innerWidth;
	window.saveInnerHeight = window.innerHeight;
}

window.onload = startup;

// ||||[ SERVICE ROUTINES ]|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

// [ menu ] -------------------------------------------------------------------

function clearTimer(menuNdx) {
	if (MENUS[menuNdx].timerid) {
		clearTimeout(MENUS[menuNdx].timerid);
		MENUS[menuNdx].timerid = null;
	}
}

function getRealLeft(el) {
	if (document.layers) return el.x;
	
	//xStr=el.tagName + "=" + el.offsetLeft;
		
    xPos 	= el.offsetLeft;
    tempEl 	= el.parentElement;
	
    while (tempEl != null) {
		//xStr += "\n" + tempEl.tagName + "=" + tempEl.offsetLeft;
        xPos  += tempEl.offsetLeft;
        tempEl = tempEl.parentElement;
    }
	//alert(xStr);
    return xPos;
}

function getRealTop(el) {
	if (document.layers) return el.y;
	
    yPos 	= el.offsetTop;
    tempEl 	= el.offsetParent;
	
    while (tempEl != null) {
        yPos  += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
	
    return yPos;
}

function fixLeftBounds(menuNdx,tryLeft)
{
	visibleWidth	= document.layers ? window.innerWidth : document.body.clientWidth;
	visibleLeft 	= document.layers ? window.pageXOffset : document.body.scrollLeft;
	visibleRight 	= visibleLeft + visibleWidth;
	
	menuWidth = document.layers ? MENUS[menuNdx].width : MENUS[menuNdx].style.pixelWidth;
	
	//right
	if ((tryLeft + menuWidth) > visibleRight) tryLeft = visibleRight - menuWidth;
	
	//left
	if (tryLeft < visibleLeft) tryLeft = visibleLeft;

	return tryLeft;	
}

function fixTopBounds(menuNdx,tryTop)
{
	visibleHeight	= document.layers ? window.innerHeight : document.body.clientHeight;
	visibleTop		= document.layers ? window.pageYOffset : document.body.scrollTop;
	visibleBottom   = visibleTop + visibleHeight;
	
	menuHeight = document.layers ? MENUS[menuNdx].height : MENUS[menuNdx].style.pixelHeight;
	
	//bottom
	if ((tryTop + menuHeight) > visibleBottom) tryTop = visibleBottom - menuHeight;
	
	//top
	if (tryTop < visibleTop) tryTop = visibleTop;
	
	return tryTop;
}
	

function menu_popup(menuNdx,linkobj,xoff,yoff) {
	if (isLoaded == 1) {
		if (activeMenu != null) 	activeMenu.hide();
		if (activeMenuItem != null) activeMenuItem.lolite();
	
		clearTimer(menuNdx);
		
		MENUS[menuNdx].show(
			fixLeftBounds(menuNdx,getRealLeft(linkobj)+(xoff | 0)),
			fixTopBounds(menuNdx,getRealTop(linkobj)+(yoff | 0))
		);
	}
}

function menu_popdown(menuNdx) {
	if (isLoaded == 1) {
		clearTimer(menuNdx);
		MENUS[menuNdx].timerid = setTimeout("MENUS["+menuNdx+"].hide()",700);
	}
}

function menu_hide()
{
	if (document.layers)	this.visibility = "hide";
	else					this.style.visibility = "hidden";	
	if (this == activeMenu) activeMenu = null;
}

function menu_show(x,y)
{
	if (document.layers) {this.left = x; this.top = y;}
	else				 {this.style.left = x; this.style.top = y;}	

	if (document.layers) 	this.visibility = "show";
	else					this.style.visibility = "visible";
	activeMenu = this;
}

function menu_out() 
{
	clearTimer(this.menuNdx);
	this.timerid = setTimeout("MENUS["+this.menuNdx+"].hide()",100);
}

// [ menuitem ] ---------------------------------------------------------------

function menuitem_over()
{
	if (activeMenuItem != null) activeMenuItem.lolite();
	this.hilite();
	
	activeMenuItem = this;
	clearTimer(this.menu.menuNdx);
}

function menuitem_click()
{
	document.location.href = this.href;
}

function menuitem_lolite()
{
	if (document.layers)	this.bgColor = this.locolor;
	else					this.style.backgroundColor = this.style.locolor;
}

function menuitem_hilite()
{
	if (document.layers)	this.bgColor = this.hicolor;
	else					this.style.backgroundColor = this.style.hicolor;
}

//------------------------------------------------------------------------------------

function siteWindow() {
	WindowFront = window.open('../sitemap/index.html','sitemap','toolbar=no,status=no,resizable=no,location=no,dependent=yes,directories=no,menubar=no,'+(document.all?'scrollbars=no':'scrollbars=yes')+',width=595,height='+(document.all?'330':'373')+',screenX=0,screenY=0,top=0,left=0');
	WindowFront.focus();
}

function closeWin() {
	window.close();
}

function infoRequest() {
	WindowFront = window.open('../contact/info_request.html','info','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=469,height='+(document.all?'500':'505')+',top=0,left=0');
	WindowFront.focus();
//	alert(location.href);
//	the formmail CHMOD settings had to be changed to execute for all 3 categories; upload as ASCII to the server.
}

function siteTarget(x) {
  window.opener.location= x;
  window.close();
	}
function callBack() {
	WindowFront = window.open('../contact/callback.html','callback','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=315,height=73,top=0,left=0');
	WindowFront.focus();
	}