onscroll = function() {
	var pos;
	
	if (window.innerHeight) pos = window.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) pos = document.documentElement.scrollTop;
	else if (document.body) pos = document.body.scrollTop;

	var dropObj = document.getElementById("fade");
	dropObj.style.top = pos + "px";
}

function fixFrames () {
	if (window.name != "mainFrame") {
		location.href = "http://www.virtualight.com/index.html?" + location.pathname;
	}
}

window.onload = function () {
	fixFrames ();
	updateBreadCrumbs();
	if (top.mainFrame.articlecount != undefined) populatePagesMenu();
	top.document.title = "Virtualight: " + top.mainFrame.document.title;
}

function updateBreadCrumbs() {
	var temp = top.breadcrumbs.join();
	if (top.mainFrame.document.title != "undefined" && top.mainFrame.document.title != "Home" && temp.indexOf(top.mainFrame.document.title) == -1 ) {
		top.breadcrumbs[top.breadcrumbs.length] = top.mainFrame.document.title;
		top.breadcrumbsurls[top.breadcrumbsurls.length] = top.mainFrame.location.href;
	}
	if (top.breadcrumbs.length > 7) top.breadcrumbs.shift();
	if (top.breadcrumbsurls.length > 7) top.breadcrumbsurls.shift();
}

function advance (which) {
	var pagenumber;
	if (which == "next" && thispage + 1 <= articlecount) {
		location.href = (thispage + 1) + ".html";
	} else if (which == "prev" && thispage - 1  >= 1) {
		location.href = (thispage - 1) + ".html";
	} else if (which == "first") {
		location.href = "1.html";
	} else if (which == "last") {
		location.href = articlecount + ".html";
	}
}

function goTo() {
	top.mainFrame.location.href = document.pagesform.pagesmenu.options[document.pagesform.pagesmenu.selectedIndex].value;
}

function populatePagesMenu() {
	for (var x = 0; x < top.mainFrame.articlecount; x++) {
		top.mainFrame.document.pagesform.pagesmenu.options[x] = new Option(x+1, (x+1) + ".html", false, false);
	}
	document.pagesform.pagesmenu.options[top.mainFrame.thispage-1].selected = true; 
}

function popUp (which,wwidth,wheight,count) {
	if(top.imagewindow != undefined) {
		if (top.imagewindow.closed == false) top.imagewindow.close();
	}
	window.sequencepath = which.substring(0,which.lastIndexOf("/")+1);
	if (count) {
		window.whichpage = which; window.slidecount = count; 
		eval("top.imagewindow = window.open('/imageviewer/slideviewer.html','imageviewer','menubar=0,resizable=1,width=" + (wwidth+20) +  ',height=' + (wheight+10) + "')");
	} else {
		eval("top.imagewindow = window.open(which,'imageviewer','menubar=0,resizable=1,width=" + (wwidth+20) +  ',height=' + (wheight+10) + "')");
	}
}

function preloadimages() {
  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];}}
}