/* -----------------------------------------------
Title: Connection Magazine Base Script
Author: Jarid Love
Last Modified: 10 Dec 2008
----------------------------------------------- */

/* Environment Variables
---------------------------------------------------- */
var isSSL = (location.protocol == "https:")?true:false;
var isStage = (location.href.indexOf("stage") > 0 || location.href.indexOf("usability") > 0) ? true : false;
var isTest = (location.href.indexOf("wwwtest.provo.novell.com") > 0) ? true : false;
var isDev = (location.href.indexOf("wwwdev.provo.novell.com") > 0) ? true : false;
var redirect = (location.href.indexOf("forceRedirect=false") > 0) ? false: true;
function getSecureUrl() {
	return (isDev)?"https://secure-wwwdev.provo.novell.com":(isTest)?"https://secure-wwwtest.provo.novell.com":(isStage)?"https://secure-wwwstage.provo.novell.com":"https://secure-www.novell.com";
}

var s = (isDev)?"http://wwwdev.provo.novell.com":(isTest)?"http://wwwtest.provo.novell.com":(isStage)?"http://wwwstage.provo.novell.com":"http://www.novell.com";
var ss = (isSSL)? getSecureUrl() : s;
var n_domain = location.host; 
var n_dirs = location.pathname.split("/");
var n_root = (n_dirs.length>=2)?n_dirs[1]:null;
var n_root2 = (n_dirs.length>=3)?n_dirs[2]:null;

var isDOM = document.getElementById?true:false; // all DOM based browsers including IE
var isNS4 = document.layers?true:false;
var isIE = document.all?true:false;
var isMac = (navigator.appVersion.indexOf("Mac") != -1)?true:false;
var isWin = (navigator.appVersion.indexOf("Win") != -1)?true:false;
var isLinux = (navigator.platform.indexOf("Linux") != -1)?true:false;
var usragent = navigator.userAgent.toLowerCase();
var isOperaBadDom = (usragent.substr(usragent.indexOf("opera")+6,1)<=6)?true:false; // this detects opera 6 or below which have crappy DOM support
var isOperaGoodDom = (usragent.substr(usragent.indexOf("opera")+6,1)>6)?true:false;
var isKonqueror = (usragent.indexOf("konqueror")>=0)?true:false;
var langCompatible = (isDOM && n_domain.indexOf("novell.com") >= 0);

/* Cookie Functions
---------------------------------------------------- */
function readCookie(name) {
	var cks = document.cookie.split(';');
	for(var i=cks.length-1; i >= 0; i--) {
		var c = cks[i];
		while(c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}
		if(c.indexOf(name+"=")==0) {
			return c.substring(name.length+1,c.length);
		}
	}
	return null;
}

function deleteCookie(name,path,domain) {
	if(readCookie(name)) { document.cookie = name + "=" +
		((path) ? ";path=" + path : ";path=/") +
		((domain) ? ";domain=" + domain : ";domain=.novell.com") +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

function createCookie(name,value,days,path,domain) {
	var expires = "";
	if(days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires +
		((path) ? ";path=" + path : ";path=/") +
		((domain) ? ";domain=" + domain : ";domain=.novell.com");
}

/* Localization Functions
---------------------------------------------------- */
function getPageCharset() {
	var mt = document.getElementsByTagName('meta');
	for(var i=0; i<mt.length; i++) {
		var ct = mt[i].getAttribute('content');
		if(ct != null && ct.toLowerCase().indexOf('charset=') != -1) {
			return ct.substring(ct.toLowerCase().indexOf('charset=')+8);
		}
	}
	return "iso-8859-1";
}

var n_lang = readCookie("novell_language");
var n_country = readCookie("novell_country");
var n_cnt=(n_country!=null && n_country.length>3)?n_country.substring(0,2):"US";
var n_enc = getPageCharset();

/* Include menu script, css, and local phone number
---------------------------------------------------- */
var n_phone_js = (n_lang != null && n_lang != "en-us") ? "/"+n_lang : "";
if(n_country != null && n_country != "US|United States"){
	n_phone_js += "/"+n_country.substring(0,2);
}
document.write('<script type="text/javascript" src="' + ss + n_phone_js + '/sitewide/contact/sales/contact_phone_var_js"><\/script>');

if(isDOM) { 
	var hasHdrNav = true;
	if(window.name == "printer_friendly") {
		document.write('<link rel="stylesheet" type="text/css" href="'+ss+'/common/inc/css/pf_connect.css" title="Printer Friendly" />');
		var s_prop15=location.href;
		window.onload = function() {
			print();	
		}
		hasHdrNav = false;
	}
	document.write('<script type="text/javascript" src="'+ss+'/common/inc/nav/main_2008.js"><\/script>');
}

function showPrinterFriendly() {
	if(document.getElementById("contentcontainer")) {
		var pfwindow = window.open(location.href,"printer_friendly","width=800,height=600,scrollbars=yes,resizable=yes");
		pfwindow.focus();
	}
	else window.open(s+'/inc/pf/pf.jsp?url='+escape(location.href)+'&sourceid=PrinterFriendlyFromFooter');
}

/* Load Translated Text
---------------------------------------------------- */
function loadHdrTransltion(suffix) {
	suffix = (suffix == null || suffix == 'en-us' || n_lang == null) ? 'en-us' : suffix;
	document.write('<script type="text/javascript" src="/common/inc/local/hdr_menu_'+suffix+'.js"><\/script>');
}
if(n_domain.indexOf("novell.de") >= 0) {
	loadHdrTransltion("de-de");
}
else if(n_domain.indexOf("novell.co.jp") >= 0) {
	loadHdrTransltion("ja-jp");
}
else {
	loadHdrTransltion((typeof navlang!="undefined") ? navlang : n_lang);
}

/* Misc get functions
---------------------------------------------------- */
function getRandomInt(min, max) {
	return (min >= max) ? max : Math.floor(((max+1 - min)*Math.random())+min);
}

function getItemWidth(obj) {
	var width = obj.clientWidth;
	return (width == 0) ? obj.offsetWidth : width;
}

function getItemHeight(obj) {
	var height = obj.clientHeight;
	return (height == 0) ? obj.offsetHeight : height;
}

function getXY(obj) {
	var intX = 0;
	var intY = 0;
	try {
		do { // Walk up our document tree until we find the body and add the distance from the parent to our counter.
			intX += obj.offsetLeft;
			intY += obj.offsetTop;
			obj = obj.offsetParent;
		} while(obj.tagName != "BODY" && obj.tagName != "HTML")
	}
	finally {
		return new Array(intX,intY);
	}
}

function getQueryParm(name) {
	var params = document.params;
	if(!params) {
		document.params = (location.search.substring(1)).split("&");
		params = document.params;
	}
	for(var i = 0; i < params.length; i++) {
		var param = params[i].split("=");
		if(param[0] == name) return param[1];
	}
	return null;
}

/* open link in new window (mainly for links to external site)
---------------------------------------------------- */
function openExternal(URL, w, h, s, n, r) {
	// It is possible to bypass w and h by passing in 'noW', 'noH'
	var attr = "";
	if(typeof w != "undefined" && w!= 'noW') attr += "width=" + w;
	if(typeof h != "undefined" && h != 'noH') attr += ",height=" + h;
	if(attr.length > 0) { // when no width or height is specified, use window core defaults, do not add any other values
		attr += (typeof s != "undefined" && s == true) ? ',scrollbars=yes' : ',scrollbars=no'; // default on sized window = no scrollbars
		attr += (typeof r != "undefined" && r == false) ? ',resizable=no' : ',resizable=yes'; // default on sized window = resizable
	}
	if(attr.charAt(0)==",") attr = attr.substring(1);
	var winExt = (!n) ? window.open(URL,'_blank',attr) : window.open(URL,n,attr);
	if(winExt && winExt.blur) winExt.focus();
}

/* tracking functions
---------------------------------------------------- */
// code to track adwords
var gAdword = getQueryParm("google_adword");
if(gAdword && gAdword != null) document.cookie = "google_adword=GooglePS:"+gAdword+";path=/;domain=.novell.com";

// code to track newsletter links
var gnews = getQueryParm("gnews");
if(gnews && gnews != null) document.cookie = "g_newsletter=GlobalNews:"+gnews+";path=/;domain=.novell.com";

/* Functions to hide/show plugins (ie. flash)
---------------------------------------------------- */
function hidePlugins(hideall) {
	// hide select boxes in IE versions > 7 because they show through menus
	var agt=navigator.userAgent.toLowerCase();
	if(isIE && (agt.indexOf("msie 4") >= 0 || agt.indexOf("msie 5") >= 0 || agt.indexOf("msie 6") >= 0)) {
		var selects = document.getElementsByTagName("select");
		for(var i = selects.length-1; i >=0 ; i--) {
			selects[i].style.visibility = "hidden";
		}
	}
	// hide flash content because it shows through navigation
	if(typeof flash != "undefined") {
		// if flash.forcehide, hide property has been manually set
		// if linux, wmode not supported, so hide flash
		// if flash version is less than 6,0,79,0 hide flash because wmode not supported widely
		if(flash.forcehide || isLinux || (flash.version <= 6 && flash.rev < 79) || isOperaGoodDom) hideFlash(hideall);
	}
	hiddenElmnts = true;
};

function hideFlash(hideall) {
	for(var i = 0; i < flash.movies.length; i++) {
		var elmt = document.getElementById("flash_"+i);
		var y = getXY(elmt)[1];
		if ((y > 0 && y < 418) || (typeof hideall != 'undefined' && hideall == 'all')) {
			//elmt.parentNode.style.background = "#e7e7e7";
			elmt.style.visibility = 'hidden';
		}
	}
};

function showPlugins(hideall) {
	// show select boxes in IE versions > 7 that were hidden because they show through menus
	var agt=navigator.userAgent.toLowerCase();
	if(isIE && (agt.indexOf("msie 4") >= 0 || agt.indexOf("msie 5") >= 0 || agt.indexOf("msie 6") >= 0)) {
		var selects = document.getElementsByTagName("select");
		for(var i = selects.length-1; i >=0 ; i--) {
			selects[i].style.visibility = "inherit";
		}
	}
	// show flash content that was hidden because it shows through navigation
	if(typeof flash != "undefined") {
		if(flash.forcehide || isLinux || (flash.version <= 6 && flash.rev < 79) || isOperaGoodDom) showFlash(hideall);
	}
	hiddenElmnts = false;
};

function showFlash(hideall) {
	for(var i = 0; i < flash.movies.length; i++) {
		var elmt = document.getElementById("flash_"+i);
		var y = getXY(elmt)[1];
		if ((y > 0 && y < 418) || (typeof hideall != 'undefined' && hideall == 'all')) {
			elmt.style.visibility = 'visible';
		}
	}
};

/* Figures Section
---------------------------------------------------- */
var popupVisible = false;
var popupLoaded = false;
var imageLoadedBeforePopup = false;

function initFigures() {
	$("#articlefigures h5").click(function() {
		if($("#articlefigures")[0].visibleFig) {
			if($("#articlefigures")[0].visibleFig == this) {
				hideFig(this);
			}
			else {
				showFig(this, $("#articlefigures")[0].visibleFig);
			}
		}
		else {
			showFig(this);
		}
	});
	$("#articlefigures h5:first").parent().css("border-top","0px solid #ffffff");
}

function showFig(newFig,oldFig) {
	if(oldFig) {
		$(oldFig).siblings("div.figurecontainer").slideUp("fast",function() {
			//$(newFig).siblings("div.figurecontainer").slideDown("fast");
			$(newFig).siblings("div.figurecontainer").find("img").hide().end().slideDown("fast",function() { $(this).children("a").children("img").fadeIn("fast") });
		});	
	}
	else {
		$(newFig).siblings("div.figurecontainer").find("img").hide().end().slideDown("fast",function() { $(this).children("a").children("img").fadeIn("fast") });
	}
	$("#articlefigures")[0].visibleFig = newFig;
}

function hideFig(oldFig) {
	$(oldFig).siblings("div.figurecontainer").slideUp("fast");
	$("#articlefigures")[0].visibleFig = null;
}

function getCaptionForImg(src) {
	var pathArray = src.split("/");
	return $("#articlefigures a[href*="+pathArray[pathArray.length-1]+"]").siblings("p.figurecaption").text();
}

function zoomFigure(url,caption) {
	var imgCaption = (caption) ? caption : getCaptionForImg(url);
	var isSWF = (url.lastIndexOf(".swf") != -1) ? true : false;
	
	var figurePopup = $("#popup");
	var insert = (isSWF) ? '<div id="flashcontent" style="position:relative;"><div id="subflashcontent"></div></div>' : '<img src="'+url+'" alt="" onload="resizePopup(this.width+42);centerPopup()" />';		
	
	if(figurePopup.size() == 0) {
		figurePopup = $("<div>").attr("id","popup").html('<div id="popuphdr">'+
								'<div id="popuphdrcontainer">'+
									'<div id="popuphdrcontent">'+
										'<strong>Figure</strong>'+
										'<ul></ul>'+
										'<p id="popupclose"><img src="/connectionmagazine/img/btn_close.png" alt="close" onclick="closePopup();" /></p>'+
									'</div>'+
								'</div>'+
							'</div>'+
							'<div id="popupbody"><div id="popupbodycontainer"><div id="popupcontent">'+insert+'</div></div></div>');
		$("body").append(figurePopup);
		$('#popup').draggable({ cancel: '#popupcontent' });
	}
	else {
		$("#popupcontent").html(insert);
	}
	
	if(isSWF){
		var file = url.replace(/.swf/ig,"").split("_");		
		var flashWidth;
		var flashHeight;
		var defaults = false;
		
		if((file[1] == null) || (file[2] == null)){ //file did not specify dimensions, so specify default
			defaults = true;
		}
		else{
			flashWidth = file[1];
			flashHeight = file[2];
			
			if (flashWidth == null || !flashWidth.toString().match(/^[-]?\d*\.?\d*$/)) defaults = true;
			if (flashHeight == null || !flashHeight.toString().match(/^[-]?\d*\.?\d*$/)) defaults = true;
		}
		
		if(defaults){
			flashWidth = 500;
			flashHeight = 300;
		}
			
		swfobject.embedSWF(url, "subflashcontent", flashWidth, flashHeight, "8.0.0");
		var width = parseInt(flashWidth)+42;
				
		resizePopup(flashWidth);
	}
	else{
		x=new Image;
		x.src=url;
		resizePopup(x.width+42);
	}

	var prevLnk = "";
	var nextLnk = "";
	var figures = $("#articlefigures a");
	var figurePages = $("#popuphdrcontent ul").empty();
	for(var i = 0; i < figures.size(); i++) {
		var pgLink = $("<li>");
		if(figures[i].href == url) {
			if(figures.size() > 1) {
				prevLnk = (i == 0) ? figures[figures.length - 1].href : figures[i - 1].href;
				nextLnk = (i == figures.length-1) ? figures[0].href : figures[i + 1].href;
			}
			pgLink.html((i < 9) ? "0"+(i+1) : i+1);
		}
		else {
				pgLink.html('<a href="'+figures[i].href+'" onclick="zoomFigure(this.href);return false;">'+((i < 9) ? "0"+(i+1) : i+1) + '</a>');
		}
		figurePages.append(pgLink);
	}
	if(nextLnk != "") {
		var nextLnkLi = $("<li>");
		nextLnkLi.html('<a href="'+nextLnk+'" onclick="zoomFigure(this.href);return false;"><img src="/connectionmagazine/img/btn_next_black.png" alt="next" /></a>');
		figurePages.append(nextLnkLi);
	}
	if(prevLnk != "") {
		var prevLnkLi = $("<li>");
		prevLnkLi.html('<a href="'+prevLnk+'" onclick="zoomFigure(this.href);return false;"><img src="/connectionmagazine/img/btn_prev_black.png" alt="previous" /></a>');
		figurePages.prepend(prevLnkLi);
	}
	
	var captionContainer = $("#popupcaption");
	if(captionContainer.size() == 0) {
		captionContainer = $("<p>").attr("id","popupcaption");
		var contentContainer = $("#popupcontent");
		contentContainer.prepend(captionContainer);
	}
	captionContainer.html(imgCaption);
	
	if(!popupVisible) {
		figurePopup.css("visibility","hidden");
	}
	figurePopup.css("display","block");
	popupLoaded = true;
	
	if(imageLoadedBeforePopup || isSWF) {
		centerPopup(flashHeight);
	}
}

function centerPopup(manualHeight) {
	if(!popupLoaded) {
		imageLoadedBeforePopup = true;
		return;
	}
	
	var figurePopup = document.getElementById("popup");
	// if(popupVisible) return;	

	var width = figurePopup.offsetWidth;
	var height = (manualHeight) ? (parseInt(manualHeight) + figurePopup.offsetHeight) : figurePopup.offsetHeight;
	var viewSize = getViewableWindowSize();
	var scrollDistance = getScrollXY();
	
	var leftPos = viewSize[0]/2 - width/2;
	if(leftPos < 20) leftPos = 20;
	figurePopup.style.left = (leftPos + scrollDistance[0]) + "px";

	var topPos = viewSize[1]/2 - height/2 - 40;
	if(topPos < 20) topPos = 20;
	figurePopup.style.top = (topPos + scrollDistance[1]) + "px";

	figurePopup.style.visibility = "visible";
	popupVisible = true;
}

function resizePopup(width) {
	// var figurePopup = document.getElementById("popup");
	// if(!figurePopup) return;
	// figurePopup.style.width = Math.max(width,640)+"px";
}

function getViewableWindowSize() {
	if( typeof( window.innerWidth ) == 'number' ) { // Non-IE
		return [window.innerWidth, window.innerHeight];
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { // IE 6+ in 'standards compliant mode'
		return [document.documentElement.clientWidth, document.documentElement.clientHeight];
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { // IE 4 compatible
		return [document.body.clientWidth, document.body.clientHeight];
	}
	return [0, 0];
}

function getScrollXY() {
	if(typeof(window.pageYOffset) == 'number' ) { // Netscape compliant
		return [window.pageXOffset,window.pageYOffset];
	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) { // DOM compliant
		return [document.body.scrollLeft,document.body.scrollTop];
	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { // IE6 standards compliant mode
		return [document.documentElement.scrollLeft,document.documentElement.scrollTop];
	}
	return [0, 0];
}

function closePopup() {
	var figurePopup = document.getElementById("popup");
	figurePopup.style.display = "none";
	popupVisible = false;
}

/* Issue Index Functions
---------------------------------------------------- */
function initIssueIndex() {
	var indexLists = $("#issueindex ul");
	for(var i = 0; i < indexLists.size(); i++) {
		var indexList = indexLists[i];
		var indexLnks = indexList.getElementsByTagName("a");
		for(var j = indexLnks.length-1; j >= 0; j--) {
			indexLnks[j].onmouseover = function(){
				if(this.parentNode.parentNode.selectedItem == this) return;
				else if(this.parentNode.parentNode.selectedItem) this.parentNode.parentNode.selectedItem.className = "";
				this.className = "on";
				this.parentNode.parentNode.selectedItem = this;
			}
			if(j== 0) {
				indexList.selectedItm = indexLnks[j];
				indexLnks[j].onmouseover();
		
			}
		}
	}
}

function showIssueIndex(lnk) {
	var issueIndex = document.getElementById("issueindex");
	if(!issueIndex) return;
	
	if(lnk) {
		var showBtn = lnk.getElementsByTagName("img")[0];
		if(showBtn.src.indexOf("plus") >= 0) {
			$(issueIndex).children("div").hide().end().slideDown("fast",function() { $(this).children("div").fadeIn("slow"); });
			showBtn.src = "/connectionmagazine/img/btn_minus.png";
			showBtn.alt = "Show Menu for Current Issue";
		}
		else {
			$(issueIndex).children("div").fadeOut("slow",function() { $(this).parent().slideUp(); });
			showBtn.src = "/connectionmagazine/img/btn_plus.png";
			showBtn.alt = "Hide Menu for Current Issue";
		}
	}
}

/* Header Navigation
---------------------------------------------------- */
function showNovellMenuWithSlide() {
	var mnuContainer = document.getElementById("n_menu");
	mnuContainer.mouseOverMnu = true;
	clearTimeout(mnuContainer.hideTimer);
	mnuContainer.hideTimer = null;
	if(mnuContainer.style.height == "auto" || mnuContainer.slideInProgress) return;
	with(mnuContainer.style) {
		height = "0px";
		display = "block";
	}
	if(typeof flash != "undefined") {
		var fp = new FlashObj("/img/flash/home/flash_off.swf","100%","100%");
		fp.setVersion(8);
		fp.write("flashpause");
	}
	mnuContainer.mnuHeight = getItemHeight(document.getElementById("n_menu_content"));
	hidePlugins();
	slideMenu(1);
}

function hideNovellMenuWithSlide(delay) {
	var mnuContainer = document.getElementById("n_menu");
	mnuContainer.mouseOverMnu = false;
	if(mnuContainer.slideInProgress || mnuContainer.style.height == "0px") return;
	mnuContainer.mnuHeight = getItemHeight(document.getElementById("n_menu_content"));
	if(delay && delay > 0) mnuContainer.hideTimer = setTimeout("slideMenu(-1)", delay);
	else slideMenu(-1);
}

function slideMenu(direction) {
	var mnuContainer = document.getElementById("n_menu");
	if(mnuContainer.mouseOverMnu == false && direction == 1) direction = -1;
	if(mnuContainer.mouseOverMnu == true && direction == -1) direction = 1;
	mnuContainer.slideInProgress = true;
	var rerunFunction = true;
	if(mnuContainer.style.height == "auto" && direction == -1) document.getElementById("n_menu_close").firstChild.innerHTML = mnuContainer.openMsg;
	
	// calculate new height
	var containerHeight =  getItemHeight(mnuContainer);
	var mnuHeight =  mnuContainer.mnuHeight;

	var newHeight = (direction > 0) ? containerHeight + Math.max(1,(mnuHeight - containerHeight)/mnuContainer.slideSpeed) : (containerHeight == 71) ? 0 : containerHeight - Math.max(1,(containerHeight-71)/mnuContainer.slideSpeed);

	if(newHeight >= mnuHeight) {
		newHeight = mnuHeight;
		rerunFunction = false;
	}
	else if(newHeight <= 1){
		newHeight = 0;
		rerunFunction = false;
	}

	// set height and position
	document.getElementById("n_menu_content").style.top = Math.min(0,newHeight - mnuHeight)+"px";
	mnuContainer.style.height = newHeight + "px";
	
	// determine if rerun or end
	if(rerunFunction) setTimeout("slideMenu("+direction+")",20);
	else {
		if(newHeight <= 1) {
			mnuContainer.style.display = "none";
			showPlugins();
			if(typeof flash != "undefined") {
				var pause = document.getElementById("flashpause");
				var fp = new FlashObj("/img/flash/home/flash_on.swf","100%","100%");
				fp.setVersion(8);
				fp.write("flashpause");
			}
		}
		else {
			mnuContainer.style.height = "auto";
			document.getElementById("n_menu_close").firstChild.innerHTML = mnuContainer.closeMsg; 
		}
		if(mnuContainer.callback && mnuContainer.callback.length > 0) {
			eval(mnuContainer.callback);
			mnuContainer.callback = null;
		}
		mnuContainer.slideInProgress = false;
	}
}

function addPause() {
	var pause = document.createElement("div");
	pause.id = "flashpause";
	with(pause.style) {
		position = "absolute";
		top = "0px";
		right = "0px";
		overflow = "hidden";
		width = "10px";
		height = "10px";
	}
	document.getElementById("hdr").appendChild(pause);
}

function initNovellMenu() {
	var mnuContainer = document.getElementById("n_menu");
	if(!mnuContainer) return false;
	
	mnuContainer.slideSpeed = 3;
	mnuContainer.slideInProgress = false;
	mnuContainer.parentNode.onmouseout = function() {
		clearTimeout(this.showTimer);
		this.showTimer = null;
	}
	mnuContainer.parentNode.onmouseover = function() {
		this.showTimer = setTimeout("showNovellMenuWithSlide()",400);
	}
	mnuContainer.onmouseover = showNovellMenuWithSlide;
	mnuContainer.onmouseout = function() {
		hideNovellMenuWithSlide(500);
	}
	
	mnuContainer.closeMsg = "- Close Menu";
	mnuContainer.openMsg = "+ Connection Menu";

	var closeBtn = document.createElement("div");
	closeBtn.id = "n_menu_close";
	closeBtn.innerHTML = '<a href="#" onclick="hideNovellMenuWithSlide();this.blur();return false;">'+mnuContainer.closeMsg+'</a>';
	mnuContainer.appendChild(closeBtn);
	
	var menuCanopy = document.createElement("div");
	menuCanopy.id = "n_menu_canopy";
	mnuContainer.appendChild(menuCanopy);

	var homeLink = document.getElementById("hdr_home").cloneNode(true);
	homeLink.id = "n_menu_home";
	menuCanopy.appendChild(homeLink);
	
	var ncmHomeLink = document.getElementById("hdr_ncmhome").cloneNode(true);
	ncmHomeLink.id = "n_menu_ncmhome";
	menuCanopy.appendChild(ncmHomeLink);
	
	var mnuLnk = document.getElementById("hdr_lnks_menu").getElementsByTagName("a")[0];
	mnuLnk.onclick = function() {
		if(showNovellMenuWithSlide) showNovellMenuWithSlide();
		return false;	
	}
	
	addPause();
	return true;
}

function showCodeSample(id) {
	var code = $("#"+id).html();
	
	var figurePopup = $("#popup");
	if(figurePopup.size() == 0) {
		figurePopup = $("<div>").attr("id","popup").html('<div id="popuphdr">'+
								'<div id="popuphdrcontainer">'+
									'<div id="popuphdrcontent">'+
										'<strong>Code Sample</strong>'+
										'<ul></ul>'+
										'<p id="popupclose"><img src="/connectionmagazine/img/btn_close.png" alt="close" onclick="closePopup();" /></p>'+
									'</div>'+
								'</div>'+
							'</div>'+
							'<div id="popupbody"><div id="popupbodycontainer"><div id="popupcontent"><code>'+code+'</code></div></div></div>');
		$("body").append(figurePopup);
		$('#popup').draggable({ cancel: '#popupcontent' });
	}
	else {
		$("#popupcontent").html('<code>'+code+'</code>');
	}
	
	if(!popupVisible) {
		figurePopup.css("visibility","hidden");
	}
	figurePopup.css("display","block");
	popupLoaded = true;
	
	centerPopup();
}

/* Onload Initialization
---------------------------------------------------- */
$(document).ready(function() {
	if(window.name != "printer_friendly") {
		if($("#articlefigures").size() > 0) initFigures();
		if($("#issueindex").size() > 0) initIssueIndex();
		initNovellMenu();
	}
});