
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
function getSty(id) {
return (isNS4 ? getRef(id) : getRef(id).style);
} 
var popTimer = 0;
var litNow = new Array();
function popOver(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllBut(menuNum);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
if (targetNum > 0) {
thisX = parseInt(menu[menuNum][0].ref.right) + parseInt(menu[menuNum][itemNum].ref.right);
thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
with (menu[targetNum][0].ref) {
right = parseInt(thisX + menu[targetNum][0].x);
top = parseInt(thisY + menu[targetNum][0].y);
visibility = 'visible';
}
}
}
function popOut(menuNum, itemNum) {
if ((menuNum == 0) && !menu[menuNum][itemNum].target)
hideAllBut(0)
else
popTimer = setTimeout('hideAllBut(0)', 500);
}
function getTree(menuNum, itemNum) {
itemArray = new Array(menu.length);

while(1) {
itemArray[menuNum] = itemNum;
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
}
}

function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
with (menu[menuCount][changeArray[menuCount]].ref) {
if (isNS4) bgColor = newCol;
else backgroundColor = newCol;
}
}
}
}
function hideAllBut(menuNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
menu[count][0].ref.visibility = 'hidden';
changeCol(litNow, false);
}

function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
this.isVert = isVert;
this.popInd = popInd
this.x = x;
this.y = y;
this.width = width;
this.overCol = overCol;
this.backCol = backCol;
this.borderClass = borderClass;
this.textClass = textClass;
this.parentMenu = null;
this.parentItem = null;
this.ref = null;
}

function Item(text, href, frame, length, spacing, target) {
this.text = text;
this.href = href;
this.frame = frame;
this.length = length;
this.spacing = spacing;
this.target = target;
this.ref = null;
}

function writeMenus() {

if (!isDOM && !isIE4 && !isNS4) return;
for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
var str = '', itemX =74, itemY =155;
for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
var itemID = 'menu' + currMenu + 'item' + currItem;
var w = (isVert ? width : length);
var h = (isVert ? length : width);
if (isDOM || isIE4) {
str += '<div id="' + itemID + '" style="position: absolute; right: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
str += '<layer id="' + itemID + '" right="' + itemX + '" top="' + itemY + '" width="' + w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
if (borderClass) str += 'class="' + borderClass + '" ';
str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
str += '<table width="110" border="1" bordercolor="#4993E6" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 0:0) + '"><tr><td align="center" height="25" >' + '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
if (target > 0) {
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;
if (popInd) str += '<td valign="top" width="15" height="15">' + popInd + '</td>';
}
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (isDOM) {
var newDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
ref = newDiv.style;
ref.position = 'absolute';
ref.visibility = 'hidden';
}
if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position:absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menu' + currMenu + 'div');
}
if (isNS4) {
ref = new Layer(0);
ref.document.write(str);
ref.document.close();
}

for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
itemName = 'menu' + currMenu + 'item' + currItem;
if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);
if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
}
}
with(menu[0][0]) {
ref.right = x;
ref.top = y;
ref.visibility = 'visible';
}
}

var menu = new Array();
var defOver = '#ffffff', defBack = '#ffffff';
var defLength = 22;
menu[0] = new Array();
menu[0][0] = new Menu(false, '', 25, 0, 0, '#1941a5', '#c4d7f8', '', 'itemText');



menu[0][1] = new Item('&#1589;&#1601;&#1581;&#1607; &#1575;&#1589;&#1604;&#1740;','home.htm', '', 100, 5, 0);
menu[0][2] = new Item('&#1605;&#1581;&#1589;&#1608;&#1604;&#1575;&#1578;', 'products.htm', '', 100, 5, 5);
menu[0][3] = new Item('&#1605;&#1583;&#1740;&#1585;&#1740;&#1578;','modiriyat.htm','',100,5,0);
menu[0][4] = new Item('&#1711;&#1575;&#1604;&#1585;&#1740; &#1578;&#1589;&#1575;&#1608;&#1740;&#1585; &#1588;&#1585;&#1705;&#1578;','#','',100,5,7);
menu[0][5] = new Item('&#1583;&#1585;&#1576;&#1575;&#1585;&#1607; &#1605;&#1575;', 'aboutus.htm','',100,5,0);
menu[0][6] = new Item('English', 'under construction.htm','',100,5,0);

menu[1] = new Array();
menu[1][0] = new Menu(true, '<img src="a2.gif" width="15" height="15">', 0,0,0,"#000000", "#e6681a", 'itemBorder', 'itemText');


menu[2] = new Array();
menu[2][0] = new Menu(true, '<img src="arrow.gif" width="15" height="15">',0,0,0,"#ffffff", "#e6681a", 'itemBorder', 'itemText');

menu[3] = new Array();
menu[3][0] = new Menu(true, '<img src="arrow.gif" width="15" height="15">',0,0,0,"#ffffff", "#e6681a", 'itemBorder', 'itemText');
menu[3][1] = new Item('&#1606;&#1585;&#1605; &#1575;&#1601;&#1586;&#1575;&#1585;', '#', '', 22, 0, 10);
menu[3][2] = new Item('&#1575;&#1740;&#1606;&#1578;&#1585;&#1606;&#1578;', '#', '', 22, 0, 8);
menu[3][3] = new Item('&#1583;&#1575;&#1606;&#1604;&#1608;&#1583; &#1606;&#1585;&#1605; &#1575;&#1601;&#1586;&#1575;&#1585;', '#', '', 22, 0, 0);
menu[3][4] = new Item('&#1605;&#1602;&#1575;&#1604;&#1575;&#1578;', '#', '', 22, 0, 0);

menu[4] = new Array();
menu[4][0] = new Menu(true, '>',0,0,0, '#000000', '#777777', 'crazyBorder', 'crazyText');


menu[5] = new Array();
menu[5][0] = new Menu(true,'', -75, -128, -100,"#1941a5", "#c4d7f8", 'itemBorder', 'itemText');
menu[5][1] = new Item('&nbsp; &#1602;&#1575;&#1576; &#1607;&#1575;&#1740; &#1583;&#1608; &#1588;&#1593;&#1604;&#1607; &#1605;&#1607;&#1578;&#1575;&#1576;&#1740; *&#1580;&#1583;&#1740;&#1583;', 'fluorescentfixture2.htm', '', 28, 0, 0);
menu[5][2] = new Item('&#1602;&#1575;&#1576; &#1607;&#1575;&#1740; &#1605;&#1607;&#1578;&#1575;&#1576;&#1740; &#1576;&#1583;&#1608;&#1606; &#1578;&#1585;&#1575;&#1606;&#1587; &#1608; &#1575;&#1587;&#1578;&#1575;&#1585;&#1578;&#1585;', 'fluorescentfixture.htm', '', 28, 0, 0);
menu[5][3] = new Item('&#1576;&#1575;&#1604;&#1575;&#1587;&#1578; &#1575;&#1604;&#1705;&#1578;&#1585;&#1608;&#1606;&#1740;&#1705;&#1740; &#1604;&#1575;&#1605;&#1662; &#1605;&#1607;&#1578;&#1575;&#1576;&#1740;', 'fluorescentballast.htm', '', 28, 0, 0);
menu[5][4] = new Item('&#1576;&#1575;&#1604;&#1575;&#1587;&#1578; &#1575;&#1604;&#1705;&#1578;&#1585;&#1608;&#1606;&#1740;&#1705;&#1740; &#1604;&#1575;&#1605;&#1662; &#1607;&#1575;&#1604;&#1608;&#1688;&#1606;', 'halogenballast.htm', '', 28, 0, 0);
menu[5][5] = new Item('&#1605;&#1581;&#1575;&#1601;&#1592; &#1607;&#1575;&#1740; &#1608;&#1604;&#1578;&#1575;&#1688;', 'Voltageguard.htm', '', 28, 0, 0);



menu[6] = new Array();
menu[6][0] = new Menu(true, '',0,0,0,"#e6681a", "#1B0C55", 'itemBorder', 'itemText');
menu[6][1] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1705;&#1575;&#1605;&#1662;&#1740;&#1608;&#1578;&#1585;', 'news1.htm', '', 22, 0,0);
menu[6][2] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1593;&#1604;&#1605;&#1740;', 'news2.htm', '', 22, 0, 0);
menu[6][3] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1575;&#1580;&#1578;&#1605;&#1575;&#1593;&#1740;', 'news3.htm', '', 22, 0, 0);
menu[6][4] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1601;&#1585;&#1607;&#1606;&#1711;&#1740;', 'news4.htm', '', 22, 0, 0);
menu[6][5] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1608;&#1585;&#1586;&#1588;&#1740;', 'news5.htm', '', 22, 0, 0);
menu[6][6] = new Item('&#1575;&#1582;&#1576;&#1575;&#1585; &#1607;&#1606;&#1585;&#1740;', 'news6.htm', '', 22, 0, 0);

menu[7] = new Array();
menu[7][0] = new Menu(true, '',-75,-128,-100,"#1941a5", "#c4d7f8", 'itemBorder', 'itemText');
menu[7][1] = new Item('&#1606;&#1605;&#1575;&#1740;&#1588;&#1711;&#1575;&#1607; &#1578;&#1607;&#1585;&#1575;&#1606;', 'gallery_tehran.htm', '', 22, 0, 0);
menu[7][2] = new Item('&#1606;&#1605;&#1575;&#1740;&#1588;&#1711;&#1575;&#1607; &#1605;&#1588;&#1607;&#1583;', 'gallery_mashhad.htm', '', 22, 0, 0);


menu[8] = new Array();
menu[8][0] = new Menu(true, '',0,0,0, "#e6681a", "#1b0c55", 'itemBorder', 'itemText');
menu[8][1] = new Item('&#1570;&#1605;&#1608;&#1586;&#1588; &#1607;&#1705;','hack.htm','',22,0,0);
menu[8][2] = new Item('&#1608;&#1740;&#1585;&#1608;&#1587;&#1607;&#1575;','virus.htm','',22,0,0);
menu[8][3] = new Item('&#1587;&#1585;&#1608;&#1740;&#1587; &#1670;&#1578;','chat.htm','',22,0,0);
menu[8][4] = new Item('&#1587;&#1585;&#1608;&#1740;&#1587; &#1608;&#1576;&#1604;&#1575;&#1711;','weblog.htm','',22,0,0);



menu[9] = new Array();
menu[9][0] = new Menu(true, '',0,0,0, "#e6681a", "#1B0C55", 'itemBorder', 'itemText');
menu[9][1] = new Item('&#1578;&#1575;&#1585;&#1610;&#1582;&#1670;&#1607;', 'kavoshgar.php?bakhsh=Content&pa=showpage&pid=1', '',20,0,0);
menu[9][2] = new Item('&#1608;&#1592;&#1575;&#1610;&#1601; &#1608; &#1575;&#1607;&#1583;&#1575;&#1601;','kavoshgar.php?bakhsh=Content&pa=showpage&pid=4','',20,0,0);
menu[9][3] = new Item('&#1578;&#1588;&#1705;&#1610;&#1604;&#1575;&#1578;','kavoshgar.php?bakhsh=Content&pa=showpage&pid=3','',20,0,0);

menu[10] = new Array();
menu[10][0] = new Menu(true, '',0,0,0, "#e6681a", "#1B0C55", 'itemBorder', 'itemText');
menu[10][1] = new Item('&#1586;&#1576;&#1575;&#1606;&#1607;&#1575;&#1740; &#1576;&#1585;&#1606;&#1575;&#1605;&#1607; &#1606;&#1608;&#1740;&#1587;&#1740;','programing.htm','',22,0,0);
menu[10][2] = new Item('&#1588;&#1576;&#1740;&#1607; &#1587;&#1575;&#1586;&#1740;','n.a.htm','',22,0,0);
menu[10][3] = new Item('&#1591;&#1585;&#1575;&#1581;&#1740; &#1608;&#1576; &#1587;&#1575;&#1740;&#1578;','web.htm','',22,0,0);




var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = clickHandle;
function clickHandle(evt)
{
if (isNS4) document.routeEvent(evt);
hideAllBut(0);
}
function moveRoot()
{
with(menu[0][0].ref) right = ((parseInt(right) < 100) ? 100 : 5);
}

