// GLOBAL JAVASCRIPT FILE FOR JOHN HANCOCK INSURANCE AND FINANCIAL SERVICES //

// BROWSER DETECTION //
function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 
 
   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isFirefox    = (ua.indexOf('firefox/') != -1);   
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);

  NetscapeVer = navigator.userAgent; 
  NSVersion = NetscapeVer.substring(82,85);
  this.isNS7even = (NSVersion == 7.0);

   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
   this.isIEMac = (this.isIE && this.isMac);
}
var browser = new BrowserDetect();

if (browser.isNS47x) {
	alert("It appears you are using an outdated version of Netscape, you will now be redirected to the Netscape site.");
	location.href = "http://channels.netscape.com/ns/browsers/default.jsp";	
}


// IMAGE SWAPPING AND PRELOADING
function init() {
	MM_preloadImages(
		'/images/nav/learn_on.gif',
		'/images/nav/explore_on.gif',
		'/images/nav/contact_on.gif',
		'/images/nav/about_on.gif',
		'/images/nav/search_on.gif',
		'/images/forfinancialprof_on.gif',
		'/images/forbenefitsmang_on.gif',
		'/images/menu_arrow.gif'
	);
}

function imgRoll (OorF,imName,subPath) {
	if (subPath == 'nav') { subPath = '/nav/'; } else { subPath = ''; }
	document.images[imName].src = '/images/' + subPath + imName + '_' + OorF + '.gif';
}

function nav_imgRoll (OorF,imName) {
	document.getElementById(imName).src = '/images/nav/' + imName + '_' + OorF + '.gif';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

	
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 500
ypSlideOutMenu.hideDelay = 250
ypSlideOutMenu.minCPUResolution = 10
// constructor
function ypSlideOutMenu(id, dir, left, top, width, height) {
	this.ie = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	if (this.ie || this.ns4 || this.dom) {
		this.id = id
		this.dir = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType = dir == "right" || dir == "down" ? "-" : "+"
		this.dim = this.orientation == "h" ? width : height
		this.hideTimer = false
		this.aniTimer = false
		this.open = false
		this.over = false
		this.startTime = 0
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")
		ypSlideOutMenu.Registry[id] = this
		var d = document
		var strCSS = '<style type="text/css">';
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px; '
		strCSS += 'overflow:hidden; z-index:10; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '
		strCSS += '}'
		strCSS += '</style>'
		d.write(strCSS)
		this.load()
	}
}
ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp
	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container = obj1
		this.menu = obj2
		this.style = this.ns4 ? this.menu : this.menu.style
		this.homePos = eval("0" + this.dirType + this.dim)
		this.outPos = 0
		this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 
		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
		//set initial state
		this.endSlide()
	}
}
ypSlideOutMenu.showMenu = function(id) {
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	
	if (!obj) {
		return false;	
	}	

	if (obj.container) {
		obj.over = true
		for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}
ypSlideOutMenu.hideMenu = function(id) {
	var obj = ypSlideOutMenu.Registry[id];
	
	if (!obj) {
		return false;	
	}
	
	if (obj.container) {
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	}
}
ypSlideOutMenu.hideAll = function() {
	var reg = ypSlideOutMenu.Registry
	for (menu in reg) {
		ypSlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}
ypSlideOutMenu.hide = function(id) {
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime() 
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}
ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-") d = -d
		else if (this.open && this.dirType == "+") d = -d
		else if (!this.open && this.dirType == "-") d = -this.dim + d
		else d = this.dim + d
		this.moveTo(d)
	}
}
ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}
ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}
ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }

/* --- DROP DOWN POSITIONING --- */
	/* menu heights */
	menu1Height = 300;
	menu2Height = 300;
	menu3Height = 300;
	menu4Height = 300;
	menu5Height = 300;
	menu6Height = 300;	
	menu7Height = 300;
	menu8Height = 300;
	menu9Height = 300;
	menu10Height = 300;
	menu11Height = 300;
	
	/* menu left positioning */
	LeftOffset1 = -280;
	LeftOffset2 = -280;
	LeftOffset3 = -280;	
	LeftOffset4 = -280;
	LeftOffset5 = -280;	
	LeftOffset6 = -280;	
	LeftOffset7 = -280;
	LeftOffset8 = -280;
	LeftOffset9 = -280;
	LeftOffset10 = -280;
	LeftOffset11 = -280;	
	/* menu top positioning */
	TopOffset = 0;
	
	if (browser.isMozilla || browser.isNS7up) {
		LeftOffset1 = LeftOffset1 + 10;
		LeftOffset3 = LeftOffset3 + 10;
		LeftOffset2 = LeftOffset2 + 10;
		LeftOffset4 = LeftOffset4 + 10;		
		LeftOffset5 = LeftOffset5 + 10;		
		LeftOffset6 = LeftOffset6 + 10;	
		LeftOffset7 = LeftOffset7 + 10;	
		LeftOffset8 = LeftOffset8 + 10;	
		LeftOffset9 = LeftOffset9 + 10;	
		LeftOffset10 = LeftOffset10 + 10;	
		LeftOffset11 = LeftOffset10 + 11;	
		TopOffset = TopOffset + 2;
	}
	if (browser.isSafari || browser.isIEMac || browser.isFirefox || browser.isOpera) {
		menu1Height = menu1Height - 4;
		menu2Height = menu2Height - 12;
		menu3Height = menu3Height - 2;
		menu4Height = menu4Height - 14;
		menu5Height = menu5Height - 4;
		LeftOffset1 = LeftOffset1 + 0;
		LeftOffset2 = LeftOffset2 + 0;
		LeftOffset3 = LeftOffset3 + 0;
		LeftOffset4 = LeftOffset4 + 10;
		LeftOffset5 = LeftOffset5 + 10;		
		LeftOffset6 = LeftOffset6 + 10;		
		LeftOffset7 = LeftOffset7 + 10;	
		LeftOffset8 = LeftOffset8 + 10;	
		LeftOffset9 = LeftOffset9 + 10;	
		LeftOffset10 = LeftOffset10 + 10;
		LeftOffset11 = LeftOffset11 + 10;	
		TopOffset = TopOffset + 2;
	}
	if ( (browser.isFirefox && browser.isWin) || (browser.isOpera && browser.isWin) ) {
		menu1Height = menu1Height + 4;
		menu2Height = menu2Height + 12;
		menu3Height = menu3Height + 2;		
		menu4Height = menu4Height + 14;
		menu5Height = menu5Height + 4;			
		menu6Height = menu6Height + 4;	
		menu7Height = menu7Height + 4;	
		menu8Height = menu8Height + 4;	
		menu9Height = menu9Height + 4;	
		menu10Height = menu10Height + 4;	
		menu11Height = menu11Height + 4;	
	}
	if (browser.isOpera && browser.isMac) {
		menu1Height = menu1Height + 2;
		menu2Height = menu2Height + 6;
		menu3Height = menu3Height + 1;
		menu4Height = menu4Height + 7;
		menu5Height = menu5Height + 2;
		menu6Height = menu6Height + 2;
		menu7Height = menu7Height + 2;
		menu8Height = menu8Height + 2;
		menu9Height = menu9Height + 2;
		menu10Height = menu10Height + 2;
			menu11Height = menu11Height + 2;
	}	
	if (browser.isIEMac || (browser.isFirefox && browser.isWin) || (browser.isNS7up && browser.isMac) ) {
		TopOffset = TopOffset - 1;
	}
	if (browser.isNS7up && browser.isMac) {
		menu1Height = menu1Height - 4;
		menu2Height = menu2Height - 12;
		menu3Height = menu3Height - 2;
		menu4Height = menu4Height - 14;
		menu5Height = menu5Height - 4;
		menu6Height = menu6Height - 4;
		menu7Height = menu7Height - 4;
		menu8Height = menu8Height - 4;
		menu9Height = menu9Height - 4;
		menu10Height = menu10Height - 4;
		menu11Height = menu11Height - 4;
	}
	
var myMenu1 = new ypSlideOutMenu("menu1", "down", 0, 0, 200, menu1Height)
var myMenu2 = new ypSlideOutMenu("menu2", "down", 0, 0, 200, menu2Height)
var myMenu3 = new ypSlideOutMenu("menu3", "down", 0, 0, 200, menu3Height)
var myMenu4 = new ypSlideOutMenu("menu4", "down", 0, 0, 200, menu4Height)
var myMenu5 = new ypSlideOutMenu("menu5", "down", 0, 0, 200, menu5Height)
var myMenu6 = new ypSlideOutMenu("menu6", "down", 0, 0, 200, menu6Height)
var myMenu7 = new ypSlideOutMenu("menu7", "down", 0, 0, 200, menu7Height)
var myMenu8 = new ypSlideOutMenu("menu8", "down", 0, 0, 200, menu8Height)
var myMenu9 = new ypSlideOutMenu("menu9", "down", 0, 0, 200, menu9Height)
var myMenu10 = new ypSlideOutMenu("menu10", "down", 0, 0, 200, menu10Height)
var myMenu11 = new ypSlideOutMenu("menu11", "down", 0, 0, 200, menu11Height)

myMenu1.onactivate = repositionMenu1
myMenu2.onactivate = repositionMenu2
myMenu3.onactivate = repositionMenu3
myMenu4.onactivate = repositionMenu4
myMenu5.onactivate = repositionMenu5
myMenu6.onactivate = repositionMenu6
myMenu7.onactivate = repositionMenu7
myMenu8.onactivate = repositionMenu8
myMenu9.onactivate = repositionMenu9
myMenu10.onactivate = repositionMenu10
myMenu11.onactivate = repositionMenu11


menu1ID = 'aboutus';
menu2ID = 'newsandhigh';
menu3ID = 'mediacentre';
menu4ID = 'medres';
menu5ID = 'findaphy';
menu6ID = 'eventsandhap';
menu7ID = 'newsletter';
menu8ID = 'aboutdubai';
menu9ID ='careers';
menu10ID = 'contactus';
menu11ID = 'links';
menu12ID = 'index';

browsMin_Top = 0;

menu1FixedTop = 145;
menu2FixedTop = 172;
menu3FixedTop = 199;
menu4FixedTop = 232;
menu5FixedTop = 267;
//menu6FixedTop = 297;
menu7FixedTop = 297;
menu8FixedTop = 297;
menu9FixedTop = 326;

menu1SubmenuHeight = 90;
menu2SubmenuHeight = 30;
menu3SubmenuHeight = 50;
menu4SubmenuHeight = 30;
menu5SubmenuHeight = 90;
menu6SubmenuHeight = 0;
menu7SubmenuHeight = 70;
menu8SubmenuHeight = 50;



function repositionMenu1() {
	menu1Left = getWindowWidth() / 2 + LeftOffset1;	
	if (getWindowWidth() < 777) {
		menu1Left = 0;
	}
	
	menu1Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu1Top = browsMin_Top;
	}		

	myMenu1.container.style ? myMenu1.container.style.left = menu1Left + "px" : myMenu1.container.left = menu1Left;
	myMenu1.container.style ? myMenu1.container.style.top = menu1FixedTop + "px" : myMenu1.container.left = menu1Top;
}

function repositionMenu2() {
	menu2Left = getWindowWidth() / 2 + LeftOffset2;
	if (getWindowWidth() < 777) {
		menu2Left = 271;
	}		
	menu2Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu2Top = browsMin_Top;
	}		
	myMenu2.container.style ? myMenu2.container.style.left = menu2Left + "px" : myMenu2.container.left = menu2Left;
	
	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu2.container.style ? myMenu2.container.style.top = menu2FixedTop + menu1SubmenuHeight + "px" : 
		myMenu2.container.left = menu2Top;
	}
	else {		
		myMenu2.container.style ? myMenu2.container.style.top = menu2FixedTop + "px" : myMenu2.container.left = menu2Top;
	}
}
function repositionMenu3() {
	menu3Left = getWindowWidth() / 2 + LeftOffset3;
	if (getWindowWidth() < 777) {
		menu3Left = 433;
	}	
	menu3Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu3Top = browsMin_Top;
	}		
	myMenu3.container.style ? myMenu3.container.style.left = menu3Left + "px" : myMenu3.container.left = menu3Left;
	
	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu3.container.style ? myMenu3.container.style.top = menu3FixedTop + menu1SubmenuHeight + "px" : 
		myMenu3.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu3.container.style ? myMenu3.container.style.top = menu3FixedTop + menu2SubmenuHeight + "px" : 
		myMenu3.container.left = menu2Top;
	}
	else {
		myMenu3.container.style ? myMenu3.container.style.top = menu3FixedTop + "px" : myMenu3.container.left = menu2Top;
	}	
}
function repositionMenu4() {
	menu4Left = getWindowWidth() / 2 + LeftOffset4;
	if (getWindowWidth() < 777) {
		menu4Left = 530;
	}	
	menu4Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu4Top = browsMin_Top;
	}	
	myMenu4.container.style ? myMenu4.container.style.left = menu4Left + "px" : myMenu4.container.left = menu4Left;
	
	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu4.container.style ? myMenu4.container.style.top = menu4FixedTop + menu1SubmenuHeight + "px" : 
		myMenu4.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu4.container.style ? myMenu4.container.style.top = menu4FixedTop + menu2SubmenuHeight + "px" : 
		myMenu4.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu4.container.style ? myMenu4.container.style.top = menu4FixedTop + menu3SubmenuHeight + "px" : 
		myMenu4.container.left = menu2Top;
	}
	else {
		myMenu4.container.style ? myMenu4.container.style.top = menu4FixedTop + "px" : myMenu4.container.left = menu2Top;
	}	
}
function repositionMenu5() {
	menu5Left = getWindowWidth() / 2 + LeftOffset5;
	if (getWindowWidth() < 777) {
		menu5Left = 684;
	}	
	menu5Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu5Top = browsMin_Top;
	}	
	myMenu5.container.style ? myMenu5.container.style.left = menu5Left + "px" : myMenu5.container.left = menu5Left;
	
	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu5.container.style ? myMenu5.container.style.top = menu5FixedTop + menu1SubmenuHeight + "px" : 
		myMenu5.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu5.container.style ? myMenu5.container.style.top = menu5FixedTop + menu2SubmenuHeight + "px" : 
		myMenu5.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu5.container.style ? myMenu5.container.style.top = menu5FixedTop + menu3SubmenuHeight + "px" : 
		myMenu5.container.left = menu2Top;
	}
	else if (curmenu == "menu4") {
		myMenu5.container.style ? myMenu5.container.style.top = menu5FixedTop + menu4SubmenuHeight + "px" : 
		myMenu5.container.left = menu2Top;
	}
	else {
		myMenu5.container.style ? myMenu5.container.style.top = menu5FixedTop + "px" : myMenu5.container.left = menu2Top;
	}
}
function repositionMenu6() {
	menu6Left = getWindowWidth() / 2 + LeftOffset6;
	if (getWindowWidth() < 777) {
		menu6Left = 684;
	}	
	menu6Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu6Top = browsMin_Top;
	}	
	myMenu6.container.style ? myMenu6.container.style.left = menu6Left + "px" : myMenu6.container.left = menu6Left;

	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + menu1SubmenuHeight + "px" : 
		myMenu6.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + menu2SubmenuHeight + "px" : 
		myMenu6.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + menu3SubmenuHeight + "px" : 
		myMenu6.container.left = menu2Top;
	}
	else if (curmenu == "menu4") {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + menu4SubmenuHeight + "px" : 
		myMenu6.container.left = menu2Top;
	}
	else if (curmenu == "menu5") {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + menu5SubmenuHeight + "px" : 
		myMenu6.container.left = menu2Top;
	}
	else {
		myMenu6.container.style ? myMenu6.container.style.top = menu6FixedTop + "px" : myMenu6.container.left = menu2Top;
	}	
}
function repositionMenu7() {
	menu7Left = getWindowWidth() / 2 + LeftOffset7;
	if (getWindowWidth() < 777) {
		menu7Left = 684;
	}	
	menu7Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu7Top = browsMin_Top;
	}	
	myMenu7.container.style ? myMenu7.container.style.left = menu7Left + "px" : myMenu7.container.left = menu7Left;

	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu1SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu2SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu3SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else if (curmenu == "menu4") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu4SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else if (curmenu == "menu5") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu5SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else if (curmenu == "menu6") {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + menu6SubmenuHeight + "px" : 
		myMenu7.container.left = menu2Top;
	}
	else {
		myMenu7.container.style ? myMenu7.container.style.top = menu7FixedTop + "px" : myMenu7.container.left = menu2Top;
	}	
}
function repositionMenu8() {
	menu8Left = getWindowWidth() / 2 + LeftOffset8;
	if (getWindowWidth() < 777) {
		menu8Left = 684;
	}	
	menu8Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu8Top = browsMin_Top;
	}	
	myMenu8.container.style ? myMenu8.container.style.left = menu8Left + "px" : myMenu8.container.left = menu8Left;

	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu1SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu2SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu3SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu4") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu4SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu5") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu5SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu6") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu6SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else if (curmenu == "menu7") {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + menu7SubmenuHeight + "px" : 
		myMenu8.container.left = menu2Top;
	}
	else {
		myMenu8.container.style ? myMenu8.container.style.top = menu8FixedTop + "px" : myMenu8.container.left = menu2Top;
	}	
}

function repositionMenu9() {
	menu9Left = getWindowWidth() / 2 + LeftOffset9;
	if (getWindowWidth() < 777) {
		menu9Left = 684;
	}	
	menu9Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu9Top = browsMin_Top;
	}	
	myMenu9.container.style ? myMenu9.container.style.left = menu9Left + "px" : myMenu9.container.left = menu9Left;

	var curmenu = document.getElementById(varCurrentMenu).value;
	
	if (curmenu == "menu1") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu1SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu2") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu2SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu3") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu3SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu4") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu4SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu5") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu5SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu6") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu6SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu7") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu7SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else if (curmenu == "menu8") {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + menu8SubmenuHeight + "px" : 
		myMenu9.container.left = menu2Top;
	}
	else {
		myMenu9.container.style ? myMenu9.container.style.top = menu9FixedTop + "px" : myMenu9.container.left = menu2Top;
	}
}

function repositionMenu10() {
	menu10Left = getWindowWidth() / 2 + LeftOffset10;
	if (getWindowWidth() < 777) {
		menu10Left = 684;
	}	
	menu10Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu10Top = browsMin_Top;
	}	
	myMenu10.container.style ? myMenu10.container.style.left = menu10Left + "px" : myMenu10.container.left = menu10Left;
	myMenu10.container.style ? myMenu10.container.style.top = 407 + "px" : myMenu10.container.left = menu10Top;
}



function repositionMenu11() {
	menu11Left = getWindowWidth() / 2 + LeftOffset11;
	if (getWindowWidth() < 777) {
		menu11Left = 684;
	}	
	menu11Top = ((getWindowHeight() - 500)/2) + TopOffset;
	if (getWindowHeight() < 507) {
		menu11Top = browsMin_Top;
	}	
	myMenu11.container.style ? myMenu11.container.style.left = menu11Left + "px" : myMenu11.container.left = menu11Left;
	myMenu11.container.style ? myMenu11.container.style.top = 327 + "px" : myMenu11.container.left = menu11Top;
}


function getWindowWidth() {
	return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}

function getWindowHeight() {
	return window.innerHeight ? window.innerHeight : document.body.offsetHeight;
}

function getImgX(menID) {
	return document.getElementById(menID).x ? document.getElementById(menID).x : document.all[menID].offsetLeft;
}
function getImgY(menID) {
	return document.getElementById(menID).y ? document.getElementById(menID).y : document.getElementById(menID).offsetTop;
}

/* ---- SUB MENU FLY-OUTS ---- */
ypSlideOutSubMenu.Registry = []
ypSlideOutSubMenu.aniLen = 300
ypSlideOutSubMenu.hideDelay = 150
ypSlideOutSubMenu.minCPUResolution = 10
// constructor
function ypSlideOutSubMenu(id, dir, left, top, width, height) {
	this.ie = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	if (this.ie || this.ns4 || this.dom) {
		this.id = id
		this.dir = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType = dir == "right" || dir == "down" ? "-" : "+"
		this.dim = this.orientation == "h" ? width : height
		this.hideTimer = false
		this.aniTimer = false
		this.open = false
		this.over = false
		this.startTime = 0
		this.gRef = "ypSlideOutSubMenu_"+id
		eval(this.gRef+"=this")
		ypSlideOutSubMenu.Registry[id] = this
		var d = document
		var strCSS = '<style type="text/css">';
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px; '
		strCSS += 'overflow:hidden; z-index:10; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '
		strCSS += '}'
		strCSS += '</style>'
		d.write(strCSS)
		this.load()
	}
}
ypSlideOutSubMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp
	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container = obj1
		this.menu = obj2
		this.style = this.ns4 ? this.menu : this.menu.style
		this.homePos = eval("0" + this.dirType + this.dim)
		this.outPos = 0
		this.accelConst = (this.outPos - this.homePos) / ypSlideOutSubMenu.aniLen / ypSlideOutSubMenu.aniLen 
		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutSubMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutSubMenu.hideMenu('" + this.id + "')")
		//set initial state
		this.endSlide()
	}
}
ypSlideOutSubMenu.showMenu = function(id) {
	var reg = ypSlideOutSubMenu.Registry
	var obj = ypSlideOutSubMenu.Registry[id]
	if (!obj) {
		return false;	
	}
	
	if (obj.container) {
		obj.over = true
		for (menu in reg) if (id != menu) ypSlideOutSubMenu.hide(menu)
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}
ypSlideOutSubMenu.hideMenu = function(id) {
	var obj = ypSlideOutSubMenu.Registry[id]
	if (!obj) {
		return false;	
	}
	
	if (obj.container) {
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("ypSlideOutSubMenu.hide('" + id + "')", ypSlideOutSubMenu.hideDelay);
	}
}
ypSlideOutSubMenu.hideAll = function() {
	var reg = ypSlideOutSubMenu.Registry
	for (menu in reg) {
		ypSlideOutSubMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}
ypSlideOutSubMenu.hide = function(id) {
	var obj = ypSlideOutSubMenu.Registry[id]
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutSubMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime() 
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutSubMenu.minCPUResolution)
}
ypSlideOutSubMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutSubMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutSubMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-") d = -d
		else if (this.open && this.dirType == "+") d = -d
		else if (!this.open && this.dirType == "-") d = -this.dim + d
		else d = this.dim + d
		this.moveTo(d)
	}
}
ypSlideOutSubMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}
ypSlideOutSubMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutSubMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutSubMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}
ypSlideOutSubMenu.prototype.onactivate = function() { }
ypSlideOutSubMenu.prototype.ondeactivate = function() { }

// DROP DOWN POSITIONING
/* menu heights */
submenu1aHeight = 100;
submenu1bHeight = 150;
submenu2aHeight = 195;
submenu2bHeight = 240;
if (browser.isSafari || browser.isIEMac || browser.isFirefox || (browser.isNS7up && browser.isMac)) {
	submenu1aHeight = submenu1aHeight - 10;
	submenu1bHeight = submenu1bHeight - 10;
	submenu2aHeight = submenu2aHeight - 10;
	submenu2bHeight = submenu2bHeight - 10;
}
if (browser.isFirefox && browser.isWin) {
	submenu1aHeight = submenu1aHeight + 10;
	submenu1bHeight = submenu1bHeight + 10;
	submenu2aHeight = submenu2aHeight + 10;
	submenu2bHeight = submenu2bHeight + 10;
}
if (browser.isOpera && browser.isMac) {
	submenu1aHeight = submenu1aHeight - 5;
	submenu1bHeight = submenu1bHeight - 5;
	submenu2aHeight = submenu2aHeight - 5;
	submenu2bHeight = submenu2bHeight;
}

var mySubMenu1a = new ypSlideOutSubMenu("submenu1a", "right", 0, 0, 185, submenu1aHeight)
var mySubMenu1b = new ypSlideOutSubMenu("submenu1b", "right", 0, 0, 175, submenu1bHeight)
var mySubMenu2a = new ypSlideOutSubMenu("submenu2a", "right", 0, 0, 175, submenu2aHeight)
var mySubMenu2b = new ypSlideOutSubMenu("submenu2b", "right", 0, 0, 175, submenu2bHeight)

mySubMenu1a.onactivate = repositionSubMenu1a
mySubMenu1b.onactivate = repositionSubMenu1b
mySubMenu2a.onactivate = repositionSubMenu2a
mySubMenu2b.onactivate = repositionSubMenu2b

subLeftPos = 176;

function repositionSubMenu1a() {	
	submenuLeft = menu1Left + subLeftPos;
	submenuTop = menu1Top;
	mySubMenu1a.container.style ? mySubMenu1a.container.style.left = submenuLeft + "px" : mySubMenu1a.container.left = submenuLeft;
	mySubMenu1a.container.style ? mySubMenu1a.container.style.top = 165 + "px" : mySubMenu1a.container.top = submenuTop;
}
function repositionSubMenu1b() {
	submenuLeft = menu1Left + subLeftPos;
	submenuTop = menu1Top;
	mySubMenu1b.container.style ? mySubMenu1b.container.style.left = submenuLeft + "px" : mySubMenu1b.container.left = submenuLeft;
	mySubMenu1b.container.style ? mySubMenu1b.container.style.top = 160 + "px" : mySubMenu1b.container.top = submenuTop;
}
function repositionSubMenu1c() {
	submenuLeft = menu1Left + subLeftPos;
	submenuTop = menu1Top;
	mySubMenu1c.container.style ? mySubMenu1b.container.style.left = submenuLeft + "px" : mySubMenu1b.container.left = submenuLeft;
	mySubMenu1c.container.style ? mySubMenu1b.container.style.top = 0 + "px" : mySubMenu1c.container.top = submenuTop;
}
function repositionSubMenu2a() {
	submenuLeft = menu2Left + subLeftPos;
	submenuTop = menu2Top;
	mySubMenu2a.container.style ? mySubMenu2a.container.style.left = submenuLeft + "px" : mySubMenu2a.container.left = submenuLeft;
	mySubMenu2a.container.style ? mySubMenu2a.container.style.top = submenuTop + "px" : mySubMenu2a.container.top = submenuTop;
}
function repositionSubMenu2b() {
	submenuLeft = menu2Left + subLeftPos;
	submenuTop = menu2Top;
	mySubMenu2b.container.style ? mySubMenu2b.container.style.left = submenuLeft + "px" : mySubMenu2b.container.left = submenuLeft;
	mySubMenu2b.container.style ? mySubMenu2b.container.style.top = submenuTop + "px" : mySubMenu2b.container.top = submenuTop;
}


function subActive(id,OorF) {
	classN = 'menuAr';
	if (OorF == 'on') { classN = 'hover'; }
	document.getElementById(id).className = classN;
}	


if (browser.isNS7x && browser.isWin) {
	document.write('<style type="text/css">.menu { -moz-opacity: 1.0; } .sub-menu { -moz-opacity: 1.0; } </style>');
}


