
// == browser info ===============================
if(navigator)
{
	user = navigator
	IS_NETSCAPE = (user.appName.toLowerCase().indexOf("netscape") != -1);
	IS_IE = (user.appName.toLowerCase().indexOf("internet") != -1);
	IS_SAFARI = (user.userAgent.toLowerCase().indexOf("safari") != -1);
	
	IS_OPERA = (user.appName.toLowerCase() == "opera");
	
	if(user.userAgent.indexOf("Opera")>-1)
	{
		IS_IE = false;
		IS_OPERA = true;
	}
	// browser version
	if (user.appVersion)
	{  // don't try to parseInt a string (NA = "")
		VERSION_IS = parseInt(user.appVersion);
		if (IS_IE)
		{  // fix for IE 5.0 appVersion bug (returns 4.0 version number)
			if (navigator.userAgent.indexOf("5.0") != -1) VERSION_IS = parseInt(user.appVersion);
		}
	}
	// user OS/platform
	if (user.userAgent && user.appVersion)
	{
		agt = user.userAgent.toLowerCase();  // abbreviation
		IS_WIN = ((agt.indexOf("win") != -1) || (agt.indexOf("16bit") != -1));
		IS_MAC = (agt.indexOf("mac") != -1);
		
		IS_OSX = IS_MAC && (agt.indexOf("os x") != -1);
	}
}	

var  styleStr = "";

if(IS_OSX)
{
	styleStr +="input.typeText{font-family:'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif;}\n"
}

if(IS_SAFARI)
{
	styleStr +="body.login object,div.search object{margin-top:1px;}\n"
}

if(IS_MAC && IS_IE)
{
	styleStr +="div.entry,div.QBNSpecial{position:static;}\n"
}

if(!(IS_WIN && IS_IE))
{
	styleStr +="div.search input{width:134px;height:auto;}\n"
}

if(styleStr.length>0)
{
	styleStr = "<style>\n"+styleStr;
	styleStr += "</style>";
	document.writeln(styleStr);
}



// == preload ===============================

var preloadList = new Array();

function preloadImages(srcList)
{
	for(var i=0;i<srcList.length;i++)
	{
		preloadIndex = preloadList.length;
		preloadList[preloadIndex] = new Image();
		preloadList[preloadIndex].src = srcList[i];
	}
}

preloadImages([	
					
				]);

// == swf buttons/header ===============================

function writeSWFButtons(labelname,urlList,width)
{
	var width = (width)? width : 160 ;
	var URLStr="";
	var HTMLStr = "";
	for(var i=0;i<urlList.length;i++)
	{
		URLStr += "&getURL"+(i+1)+"="+urlList[i];
	}
	HTMLStr +="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\""+width+"\" height=\"18\">\n";
	HTMLStr +="<param name=\"movie\" value=\"/_swf/swfloader.swf\">\n";
	HTMLStr +="<param name=\"flashvars\" value=\"swfSrc=/_swf/buttons.swf&swfHeight=18&frameLabel="+labelname+URLStr+"\">\n";
	HTMLStr +="<param name=\"quality\" value=\"high\">\n";
	HTMLStr +="<param name=\"salign\" value=\"tl\">\n";
	HTMLStr +="<param name=\"bgcolor\" value=\"#f4f4f4\">\n";
	HTMLStr +="<param name=\"wmode\" value=\"transparent\">\n";
	HTMLStr +="<param name=\"menu\" value=\"false\">\n";
	HTMLStr +="<embed src=\"/_swf/swfloader.swf\" flashvars=\"swfSrc=/_swf/buttons.swf&swfHeight=18&frameLabel="+labelname+URLStr+"\" width=\""+width+"\" height=\"18\" quality=\"high\" salign=\"tl\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>\n";
	HTMLStr +="</object>";

	document.write(HTMLStr);
}

function writeSWFHeader(flashvars)
{
	// - flashvars:
	// - ntYear,ntMonth,ntDay,ntHours,ntMinutes,playJingle

	var HTMLStr = "";
	
	HTMLStr +="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"870\" height=\"61\">\n";
	HTMLStr +="<param name=\"movie\" value=\"/_swf/nt_header.swf\">\n";
	HTMLStr +="<param name=\"flashvars\" value=\""+flashvars+"\">\n";
	HTMLStr +="<param name=\"quality\" value=\"high\">\n";
	HTMLStr +="<param name=\"salign\" value=\"tl\">\n";
	HTMLStr +="<param name=\"menu\" value=\"false\">\n";
	HTMLStr +="<embed src=\"/_swf/nt_header.swf\" flashvars=\""+flashvars+"\" width=\"870\" height=\"61\" quality=\"high\" salign=\"tl\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
	HTMLStr +="</object>\n";
	
	document.write(HTMLStr);
}

function writeSWFNTBHeader()
{
	flashvars="getURL1=broadcastTo('ntb')";
	
	var HTMLStr = "";
	
	HTMLStr +="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"155\" height=\"13\">\n";
	HTMLStr +="<param name=\"movie\" value=\"/_swf/ntb_header.swf\">\n";
	HTMLStr +="<param name=\"flashvars\" value=\""+flashvars+"\">\n";
	HTMLStr +="<param name=\"quality\" value=\"high\">\n";
	HTMLStr +="<param name=\"salign\" value=\"tl\">\n";
	HTMLStr +="<param name=\"menu\" value=\"false\">\n";
	HTMLStr +="<embed src=\"/_swf/ntb_header.swf\" flashvars=\""+flashvars+"\" width=\"155\" height=\"13\" quality=\"high\" salign=\"tl\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
	HTMLStr +="</object>\n";
	
	document.write(HTMLStr);
}

function writeQuicktime(src,width,height)
{
	var HTMLStr = "";
	if(src.indexOf(".swf")>-1)
	{
		HTMLStr +="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\""+width+"\" height=\""+height+"\">\n";
		HTMLStr +="<param name=\"movie\" value=\""+src+"\">\n";
		HTMLStr +="<param name=\"quality\" value=\"high\">\n";
		HTMLStr +="<param name=\"salign\" value=\"tl\">\n";
		HTMLStr +="<param name=\"menu\" value=\"false\">\n";
		HTMLStr +="<embed src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" quality=\"high\" salign=\"tl\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
		HTMLStr +="</object>\n";
	}
	else
	{
		height +=16;
		HTMLStr +="<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0\" width=\""+width+"\" height=\""+height+"\">\n";
		HTMLStr +="	<param name=\"src\" value=\""+src+"\">\n";
		HTMLStr +="	<param name=\"autoplay\" value=\"true\">\n";
		HTMLStr +="	<param name=\"bgcolor\" value=\"#ffffff\">\n";
		HTMLStr +="	<param name=\"cache\" value=\"true\">\n";
		HTMLStr +="	<param name=\"controller\" value=\"true\">\n";
		HTMLStr +="	<embed src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" autoplay=\"true\" bgcolor=\"#ffffff\" cache=\"true\" controller=\"true\" pluginspage=\"http://www.apple.com/quicktime/download/\"></object>\n";
	}
	document.write(HTMLStr);
}

/*
	thanks to Dan Steinman for his niffty path tool
	http://www.dansteinman.com/dynduo/duopath/duopath.html
	
	coz precalculated is faster, faster, faster
*/
	var duoPathBookshelf2Text = new Array(-197,-184,-170,-154,-137,-119,-101,-84,-68,-53,-41,-29,-20,-12,-5,-0,3,5,6,6,5,4,2,0);
	var duoPathBookshelf2Visual = new Array(-197,-198,-199,-200,-201,-201,-201,-200,-198,-195,-190,-185,-177,-169,-158,-145,-130,-113,-94,-75,-55,-35,-17,0);
	
	var duoPathCertified2Text = new Array(0,-15,-33,-52,-72,-93,-114,-133,-151,-167,-180,-191,-201,-208,-214,-218,-221,-223,-223,-223,-222,-221,-220,-218,-218);
	var duoPathCertified2Visual = new Array(0,0,2,3,4,5,5,5,3,0,-4,-10,-17,-27,-38,-51,-67,-85,-104,-125,-146,-166,-185,-203,-218);
	
	var pathIndex=0; 
	var moveID=null;
	
	delay=10;

// == certified ===============================
		
	function moveCertified2Text()
	{
		clearTimeout(moveID);
		var xPos = duoPathCertified2Text[pathIndex];
		pathIndex+=1;
		document.getElementById('certified').style.left=xPos+"px";
		
		if(pathIndex<duoPathCertified2Text.length-1)
		{
			moveID=setTimeout("moveCertified2Text()",delay);
		}
		else
		{
			document.getElementById("back").style.display="block";
		}
	}
	
	function moveCertified2Visual()
	{
		clearTimeout(moveID);
		
		if(document.getElementById("back").style.display=="block")
		{
			document.getElementById("back").style.display="none";
		}
		var xPos = duoPathCertified2Visual[pathIndex];
		pathIndex-=1;
		document.getElementById('certified').style.left=xPos+"px";
		
		if(pathIndex>0){
			moveID=setTimeout("moveCertified2Visual()",delay);
		}
	}
	
// == bookshelf ===============================		

	function moveBookshelf2Text()
	{
		clearTimeout(moveID);
		var yPos = duoPathBookshelf2Text[pathIndex];
		pathIndex+=1;
		document.getElementById('bookshelf').style.top=yPos+"px";
		
		if(pathIndex<duoPathBookshelf2Text.length-1)
		{
			moveID=setTimeout("moveBookshelf2Text()",delay);
		}
		else
		{
			document.getElementById("back").style.display="block";
		}
	}
	
	function moveBookshelf2Visual()
	{
		clearTimeout(moveID);
		if(document.getElementById("back").style.display=="block")
		{
			document.getElementById("back").style.display="none";
		}
		var yPos = duoPathBookshelf2Visual[pathIndex];
		pathIndex-=1;
		document.getElementById('bookshelf').style.top=yPos+"px";
		
		if(pathIndex>0){
			moveID=setTimeout("moveBookshelf2Visual()",delay);
		}
	}
	
// ====================================

function openInPopup(aObj,w,h)
{
	window.open(aObj.href,aObj.target,"width="+w+",height="+h+",left=50,top=50,status=yes,directories=no,location=no,menubar=no,resizable=no,toolbar=no,scrollbars=no");
	return false;
}
	
	
// ====================================

var pageInit

window.onload = function()
{
	if(pageInit)
	{
		pageInit();
	}
	if(IS_IE && IS_MAC)
	{
		aList = document.getElementsByTagName('a');
		for(var i=0;i<aList.length;i++)
		{
			aList[i].onfocus = function()
			{
				this.blur();
			}
		}
	}
}