var Host;
var Protocal;
var Root;
var Spacer = '<td></td>';

function isUndefined( JSvariable ) {
  var bIsUndefined;

  if ("object" == typeof (JSvariable)) {
      bIsUndefined = false;
  }
  else {
      bIsUndefined = (String (JSvariable).valueOf () == "undefined" ? true : false);
  }

  return bIsUndefined;
}
	//these variables have to be declared on individual page
	//please take this numbers from menu arrays, arrays starts from 0
	//var current_active_menu;
	//var current_active_item; 
	
	var uagent = navigator.userAgent.toLowerCase();
	
	function getVer(aname,sp) {
		return parseFloat(uagent.substring(uagent.indexOf(sp, uagent.indexOf(aname))+1))	
	}
	var navVersion = 0;

	var isExp=uagent.indexOf('msie')!=-1;
	if (isExp) navVersion = getVer('msie', ' ');

	var isNS=uagent.indexOf('netscape')!=-1;
	if (isNS) navVersion = getVer('netscape', '/');

	var platform = "undef";
	if (uagent.indexOf('win')!=-1) platform = "win";
	if (uagent.indexOf('mac')!=-1) platform = "mac";

	var active_menu;
	var timeout_array = new Array(6);

if (isUndefined(Protocal)) {
    Protocal = "https://";
}

if (isUndefined(Host)) {
    Host = "www.conferenceplus.com";
}

if (isUndefined(Root)) {
    Root = "conferenceplus";
}

var HostRoot = Host + "/" + Root;

	/* use this in the page head to set styles for the browser */
	function setStyles() {
		if(isExp){
			document.write("<link rel='stylesheet' href='http://" + HostRoot + "/ie.css' type='text/css'>");
		}
		else{
			document.write("<link rel='stylesheet' href='http://" + HostRoot + "/ns.css' type='text/css'>");
		}
	}
	
	function rand(num) {
		return (new Date()).getTime() % num;
	}

	function Button(title,location,menu,width,mwidth) {
		this.title = title;
		this.location = location;
		this.menu = menu;
		this.width = width; // for ie 4.0 and mac ie
		this.mwidth = mwidth; // for ie 4.0 and mac ie
	}

	function Item(title,location,indent) {
		this.title = title;
		this.location = location;
		this.indent = indent; //0,1 if you want an indent of a particular menu item
	}

var menu = new Array();

	function get_object(name) {
		if (document.all) {
			return document.all[name];
		} else {
			return document.getElementById(name);
		}
	}

	function getPageOffsetLeft(el)	{
		return el.offsetParent != null ? el.offsetLeft + getPageOffsetLeft(el.offsetParent) : el.offsetLeft;
	} 

	function getPageOffsetTop(el)	{
		return el.offsetParent != null ? el.offsetTop + getPageOffsetTop(el.offsetParent) : el.offsetTop;
	} 

	function getElOffsetLeft(el)	{
		return isExp ? el.offsetParent.clientLeft + getPageOffsetLeft(el) : getPageOffsetLeft(el);
	} 

	function getElOffsetTop(el)	{
		return isExp ? el.offsetParent.clientTop + getPageOffsetTop(el) : getPageOffsetTop(el);
	} 

	function activate(i) {
			
		if (timeout_array[i] != null) clearTimeout(timeout_array[i]);

		if (active_menu != null && active_menu != i) do_hide(active_menu);
				
		var m = get_object("m" + i);
		var b = get_object("b" + i);
		var sml = get_object("menuAncor");

		var x, y;

		x = getPageOffsetLeft(b);
		y = getPageOffsetTop(sml);
		if (isExp) {
			if (!(isExp && platform == "mac")) {
				x += b.offsetParent.clientLeft; 
				y += (sml.offsetParent.clientTop + sub_menu_pos); 
			} else {
				y += (sml.offsetParent.clientTop + sub_menu_pos - 5); 
			}
		} else {
				y += (sml.offsetParent.clientTop + sub_menu_pos); 
		}

		if (current_active_menu != i) {
			b.className = 'menuButtonActive';	
		}
			
		if (isExp)
			b.style.cursor = "hand";
		else
			b.style.cursor = "pointer";

		if (m != null) {
			m.style.left = x + "px";
			m.style.top = y + "px"; 
			m.style.visibility ="visible";
			if (isExp)
				m.style.cursor = "hand";
			else
				m.style.cursor = "pointer";
		}
			
		active_menu = i;
	}
	
	function deactivate(i) {
		if (timeout_array[i] != null) clearTimeout(timeout_array[i]);
		timeout_array[i] = setTimeout("do_hide(" + i + ")", 50);
	}

	function do_hide(i) {
		if (current_active_menu != i) get_object("b" + i).className = 'menuButton';
		var m = get_object("m" + i);

		if (m != null) m.style.visibility ="hidden";

		if (active_menu == i) active_menu = null;
	}

	function activate_item(o,i,j) {
		if (!(current_active_menu == i && current_active_item == j)) o.className = 'menuItemActive';
	}


	function deactivate_item(o,i,j) {
		if (!(current_active_menu == i && current_active_item == j)) o.className = 'menuItem';
	}

	function print_amenu() {
	   document.writeln(Spacer);

		for (var i = 0; i < menu.length; i++) {
		
			document.writeln('<td width="' + menu[i].mwidth + '" onmouseover="activate(' + i + ');" onmouseout="deactivate(' + i + ');">');
			if (current_active_menu == i)
				document.writeln('<div class="menuButtonActive">');
			else
				document.writeln('<div class="menuButton">');				

			if (i == menu.length - 1) {
				document.writeln('<div id="b' + i + '" style="padding: 0px 8px 0px 8px;" onclick="location.href=\'' + menu[i].location + '\'">');
			} else {
				if (!isExp && !isNS)			
					document.writeln('<div id="b' + i + '" onclick="location.href=\'' + menu[i].location + '\'">');
				else
					document.writeln('<div id="b' + i + '" style="padding: 0px 8px 0px 8px;" onclick="location.href=\'' + menu[i].location + '\'">');
			}

			document.writeln('<a href="' + menu[i].location + '">' + menu[i].title + '</a>');
			document.writeln('</div>');
			document.writeln('</div>');
			document.writeln('</td>');
		}
	}

	function print_asubmenu() {
		if (!isExp && !isNS) return;	
		for (var i = 0; i < menu.length; i++) {
			if (menu[i].menu != null) {
				document.writeln('<div id="m' + i + '" class="subMenu" onmouseover="activate(' + i + ');" onmouseout="deactivate(' + i + ');">');
				for (var j = 0; j < menu[i].menu.length; j++) {	
					if (current_active_menu == i && current_active_item == j)	
						document.writeln('<div class="menuItemActive" onmouseover="activate_item(this,' + i + ',' + j + ');" onmouseout="deactivate_item(this,' + i + ',' + j + ');" onclick="location.href=\'' + menu[i].menu[j].location + '\'">');
					else						
						document.writeln('<div class="menuItem" onmouseover="activate_item(this,' + i + ',' + j + ');" onmouseout="deactivate_item(this,' + i + ',' + j + ');" onclick="location.href=\'' + menu[i].menu[j].location + '\'">');
					document.writeln('<div id="w' + i + "" + j + '" style="padding: 4px 8px 4px ' + ((menu[i].menu[j].indent + 1 ) * 8) + 'px;">');
					document.writeln('<a href="' + menu[i].menu[j].location + '">' + menu[i].menu[j].title + '</a>');
					document.writeln('</div>');
					document.writeln('</div>');
				}
				document.writeln('</div>');
				//fixing sizes/position here
				get_object("m" + i).style.top = (getElOffsetTop(get_object("menuAncor")) + 27) + "px"; 
				if (isExp) {
						for (j = 0; j < menu[i].menu.length; j++) {
							if (platform == "win" && navVersion >= 5)
								get_object("w" + i + "" + j).style.width = (get_object("m" + i).offsetWidth - 2) + "px";
						}
						if (!(platform == "win" && navVersion >= 5))
							get_object("m" + i).style.width = menu[i].width + "px";
				}
			}
		}
	}

	function print_menu() {
		 menu = menuMain;
	 
	 print_amenu();
	}
		
	function print_submenu() {
	 menu = menuMain;
	 
	 print_asubmenu();
	}
	
	function openWindow(URL, features) {
		winA = window.open(URL, "_blank", features);
	}
	
	function openTCWindow(URL, Order) {
	 var sWindow = "sys" + Order;
		winA = window.open(URL, sWindow, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=825,height=620,left=0,top=0');
	}

	
	function DisplayCountrySelectionFlash()
	{
		document.write('<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 height=352 width=680 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 VIEWASTEXT>\n');
		document.write('<PARAM NAME="_cx" VALUE="17992">\n');
		document.write('<PARAM NAME="FlashVars" VALUE="">\n');
		document.write('<PARAM NAME="Movie" VALUE="images/CountrySelection/map1.swf">\n');
		document.write('<PARAM NAME="Src" VALUE="images/CountrySelection/map1.swf">\n');
		document.write('<PARAM NAME="WMode" VALUE="Window">\n');
		document.write('<PARAM NAME="Play" VALUE="-1">\n');
		document.write('<PARAM NAME="Loop" VALUE="-1">\n');
		document.write('<PARAM NAME="Quality" VALUE="High">\n');
		document.write('<PARAM NAME="SAlign" VALUE="">\n');
		document.write('<PARAM NAME="Menu" VALUE="-1">\n');
		document.write('<PARAM NAME="Base" VALUE="">\n');
		document.write('<PARAM NAME="Scale" VALUE="ShowAll">\n');
		document.write('<PARAM NAME="DeviceFont" VALUE="0">\n');
		document.write('<PARAM NAME="EmbedMovie" VALUE="0">\n');
		document.write('<PARAM NAME="BGColor" VALUE="">\n');
		document.write('<PARAM NAME="SWRemote" VALUE="">\n');
		document.write('<PARAM NAME="MovieData" VALUE="">\n');
		document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">\n');
		document.write('<PARAM NAME="Profile" VALUE="0">\n');
		document.write('<PARAM NAME="ProfileAddress" VALUE="">\n');
		document.write('<PARAM NAME="ProfilePort" VALUE="0">\n');
		document.write('<embed src="images/CountrySelection/map1.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="680" height="352"> </embed></OBJECT>\n');
	}
		