// browser upgrade splash page check
var browserName = navigator.appName;
var browserVer = navigator.appVersion;
var browserOK = 1;


// establish browser ver.
var n = (navigator.appName == "Netscape")
var n4 = (document.layers) ? 1:0
var ie = (navigator.appName == "Microsoft Internet Explorer")
var ie4 = (document.all) ? 1:0
var browserName = navigator.appName;

var rolloversOK = 0;
browserVer = parseInt(navigator.appVersion);
if (n && browserVer >= 3) rolloversOK = 1;
else if (ie && browserVer >= 4) rolloversOK = 1;

if (n4) {
	// Test for Unix NS4 version and don't allow DHTML elements in it
	if (navigator.appVersion.indexOf("X11") >= 0) {
		n4 = 0;
	}
}
else if (ie4) {
	// Test for Mac IE4 version and don't allow DHTML elements in it
	if ((navigator.appVersion.indexOf("Macintosh") >= 0) || (navigator.appVersion.indexOf("Mac_") >= 0)) {
		ie4 = 0;
	}
}


var version = "no";
var top_adjust = 0;
var offset;
var browserWidth;
var browserOffset;
var pageWidth = 1600;


if (n4) {
	version = "ok";
	top_adjust = -2;
} else if (ie4) {
	version = "ok";
	top_adjust = 5;
}

	
// popup menu vars
var totalMenus = 1
var menuPosX = 0
var menuPosY = new Array(totalMenus)
var itemsOnMenu = new Array(totalMenus)
var menuItems = new Array(totalMenus)
var urlLinks = new Array(totalMenus)
var lastMenu = -99
var lastHotItem = -99
var bgHot = "#FFCC66"
var bgNormal = "#F8A705"



// Services

menuPosY[0] = 175
itemsOnMenu[0] = 3
menuItems[0] = new Array(itemsOnMenu[1])
urlLinks[0] = new Array(itemsOnMenu[1])

menuItems[0][0] = "Iranian Members"
menuItems[0][1] = "Foreign Members"
menuItems[0][2] = "Internaional Organization"


urlLinks[0][0] = "member.htm"
urlLinks[0][1] = "foreignmembers.htm"
urlLinks[0][2] = "inter-org.htm"

function doPopup (whichMenu, whichHotItem) {

	if (version != "ok") {return}

	// see if the menu needs to be redrawn
	newMenu = 0
	if (whichMenu != lastMenu) {
		lastMenu = whichMenu
		newMenu = 1 
	} else if (whichHotItem != lastHotItem) {
		newMenu = 1
	}
	// redo the popup table if necessary	
	if (newMenu) {
		lastHotItem = whichHotItem
		popupWidth = "130"; insideWidth = "130";  // for the first two 
		if ((whichMenu == 0) || (whichMenu == 1)) {   // when only this if is used: 01=12-32 03=14-23 04||00=1-234 11=2-134 21=14-23 31=13-24 41=134-2 40=1-234 
			popupWidth = "132"; insideWidth = "130"; // for the third
		}		
		if ((whichMenu == 3) || (whichMenu == 4)) {   
			popupWidth = "130"; insideWidth = "130"; // for the last
		}
		
		popupHeight = (itemsOnMenu[whichMenu] * 16)
	
		theTable  = '<table width=' + popupWidth + ' height=' + (popupHeight + 1) + ' bgcolor=#79889F cellpadding=0 cellspacing=0 border=0><tr><td>\n'
		theTable += '<table align="center" valign="center" width=' + insideWidth + ' height=' + popupHeight + ' bgcolor=' + bgNormal + ' cellspacing=0 cellpadding=0 border=0>\n'
		theTable += '<tr bgcolor=#79889F><td width="100%" height=1></td></tr>\n' 
		for (x = 0; x < itemsOnMenu[whichMenu]; x++ ) {
			bg2Use = bgNormal; class2Use = "notHot";
			if (x == whichHotItem) { bg2Use = bgHot; class2Use = "notHot"; }
			theTable += '<tr bgcolor=' + bg2Use + '><td height=15><a href="' + urlLinks[whichMenu][x] + '" class="' + class2Use + '" onMouseOver="doPopup(' + whichMenu + ',' + x + ');">&nbsp;' + menuItems[whichMenu][x] + '</a></td></tr>\n'
			if (x != itemsOnMenu[whichMenu]) { theTable += '<tr bgcolor=#79889F><td width="100%" height=1></td></tr>\n' }
		}
		theTable += '</table>\n</td></tr></table>\n'

		if (n4) {
			browserWidth = window.innerWidth;
			browserOffset = 42;
			if (browserWidth < pageWidth ) {
				browserWidth = pageWidth;
			}
			offset = (browserWidth - pageWidth)/2;
			menuPosX = offset + browserOffset;
	
			whichLayer = "nsPopup"
			document.layers[whichLayer].visibility = 'hide'
		    	document.layers[whichLayer].document.write(theTable)
			document.layers[whichLayer].document.close()
			if (whichHotItem == -1) {
				document.layers["nsBuffer"].visibility = 'hide'
				document.layers["nsBuffer"].document.write(theTable)
				document.layers["nsBuffer"].document.close()
				document.layers["nsBuffer"].moveTo(menuPosX, menuPosY[whichMenu])
				document.layers["nsBuffer"].visibility = 'show'
			}
			document.layers[whichLayer].moveTo(menuPosX, menuPosY[whichMenu])
			document.layers[whichLayer].visibility = 'show'
		}
		else if (ie4) {
			browserWidth = parseInt(document.body.offsetWidth);
			browserOffset = 45;
			if (browserWidth < pageWidth ) {
				browserWidth = pageWidth;
			}
			offset = (browserWidth - pageWidth)/2;
			menuPosX = offset + browserOffset + 65;

			whichLayer = "iePopup"
			document.all[whichLayer].innerHTML = theTable
			document.all[whichLayer].style.posLeft = menuPosX
			document.all[whichLayer].style.posTop = menuPosY[whichMenu]
			document.all[whichLayer].style.visibility = 'visible'
		}
	}
}

function hidePopups() {
  if (version != "ok") {return}
  lastMenu = -99
  lastHotItem = -99
  if (n4) {
  	document.layers["nsPopup"].visibility = "hide";
  	document.layers["nsBuffer"].visibility = "hide";
  } else if (ie4) { 
	document.all["iePopup"].style.visibility = 'hidden';
  }
}

// dropdown
function go() {
var i=document.list.index.selectedIndex
	parent.location=document.list.index.options[i].value+""
	return false;
}

