//Start of browserdetect.js

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//End of browserdetect.js

// Start of domhelper.js

function getWindowHeight(x)
{
	var h = 0;
	
	if( typeof( window.innerWidth ) == 'number' )
	{
		h = window.innerHeight;
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		h = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		h = document.body.clientHeight;
	}

	h = h * (x/100);
	h = Math.round(h);
	return h;
}

/**
 * Create a new node
 * @param {String} name Kind of node you want (i.e. DIV; SPAN etc.)
 * @returns node
 */
function newnode (name)
{
	return document.createElement(name);
}

/**
 * Create a new textnode
 * @param {String} text Content of the new Textnode
 * @returns Textnode
 */
function newtextnode (text)
{
	return document.createTextNode(text);
}

/**
 * Create a new Attribute Node
 * @param {String} attr Name of the new Attribute Node
 * @param {String} val Content of the new Attribute Node
 * @returns Attribute Node
 */
function newAttribute(attr,val)
{
	var ret = document.createAttribute(attr);
	ret.nodeValue=(val);
	return ret;
}

/**
 * Add a new Attribute Node to a Node
 * @param {DOM} node Node you want to add the Attribute to
 * @param {String} attr Name of the new Attribute Node
 * @param {String} val Content of the new Attribute Node
 * @returns Attribute Node
 */
function addNewAttribute(node,attr,val)
{
	if (node)
	{
	
		if (attr === "style")
		{
			var valarr = val.split(":");
			if (valarr[0]==="text-indent")
			{
				node.style.textIndent=valarr[1].split(";")[0];
			}
			else node.style.valarr[0]=valarr[1].split(";")[0];
		}
		else node.setAttributeNode(newAttribute(attr,val));
	}
	else alert(val);
}

/**
 * Creates a new div node
 * @param {String} divid id of the div (null to not set id)
 * @param {String} divclass class of the div (null to not set class)
 * @returns new div node
 *
 */
function createDiv (divid,divclass)
{
	var node = document.createElement("div"),
		idattr = document.createAttribute("id"),
		classattr = document.createAttribute("class");
	
	if (divid)
	{
		idattr.nodeValue=divid;
		node.setAttributeNode(idattr);
	}
	
	if (divclass)
	{
		classattr.nodeValue=divclass;
		node.setAttributeNode(classattr);
	}
		
	return node;
}

/**
 * Creates a new link node
 * @param {String} text Text of the Link Node
 * @param {String} url URL of the Link Node
 * @returns new link node
 *
 */
function newLink (text,url)
{
	var ret = newnode("a");
	addNewAttribute(ret,"href",url);
	ret.appendChild(newtextnode(text));
	
	return ret;
}

/**
 * Creates a new image node
 * @param {String} src Filename of image file
 * @param {String} alt alternative display text
 * @returns new image node
 *
 */
function newImg (src,alt)
{
	var ret = newnode("img");
	addNewAttribute(ret,"src",src);
	addNewAttribute(ret,"alt",alt);
	
	return ret;
}

function newTable(node)
{
	var tablenode,tdnode,trnode;
	tablenode = newnode ("table");
	addNewAttribute(tablenode,"class","intextimagetbl");
	trnode = newnode("tr");
	tdnode = newnode("td");
	
	tdnode.appendChild(node);
	trnode.appendChild(tdnode);
	tablenode.appendChild(trnode);
	
	return tablenode;
	
}

function newTable2(tdnode)
{
	var tablenode,trnode;
	tablenode = newnode ("table");
	addNewAttribute(tablenode,"class","intextimagetbl");
	trnode = newnode("tr");
	// tdnode = newnode("td");
	
	// tdnode.appendChild(node);
	trnode.appendChild(tdnode);
	tablenode.appendChild(trnode);
	
	return tablenode;
	
}

function cleanWhitespace(node)
{
  for (var i=0; i<node.childNodes.length; i++)
  {
    var child = node.childNodes[i];
    if(child.nodeType == 3 && !/\S/.test(child.nodeValue))
    {
      node.removeChild(child);
      i--;
    }
    if(child.nodeType == 1)
    {
      cleanWhitespace(child);
    }
  }
  return node;
}

// End of domhelper.js
// Start of pagiobj.js

(function(){
	var dash = /-(.)/g;
	function toHump(a, b){return b.toUpperCase();};
	String.prototype.encamel = function(){return this.replace(dash, toHump);};
})();

function getStyle(el, styleprop){
	// el = document.getElementById(el);
	if(window.getComputedStyle){
		return document.defaultView.getComputedStyle(el, null).getPropertyValue(styleprop);
	}
	else if(el.currentStyle){
		return el.currentStyle[styleprop.encamel()];
	}
	return null;
}

function pagination (nodeid)
{
	this.name = nodeid;
	this.node = document.getElementById(nodeid);
	this.setHeight = setHeight;
	this.pageUp = pageUp;
	this.pageDown = pageDown;
	this.content = this.node.cloneNode(true);
	this.contcontainer = createDiv (null,null);
	this.navcontainer = new navcontainer ();
	this.lineheight = parseInt(getStyle(this.node, "line-height"));
	this.contentheight =0;
	this.contcontainerheight =0;
	var thisobj = this;
	
	addNewAttribute(this.content,"id",null);
	
	this.node.innerHTML = "";
	
	this.content.style.maxHeight="none";
	this.content.style.minHeight="0";
	this.content.style.height="auto";
	this.content.style.padding="0";
	this.content.style.margin="0";
	
	this.contcontainer.style.maxHeight="none";
	this.contcontainer.style.minHeight="0";
	this.contcontainer.style.height="auto";
	this.contcontainer.style.padding="0";
	this.contcontainer.style.margin="0";
	
	this.contcontainer.appendChild(this.content);
	this.node.appendChild(this.contcontainer);
	this.node.appendChild(this.navcontainer.node);
	// this.content.style.border="red 1px solid";
	// this.contcontainer.style.border="blue 1px solid";
	this.contcontainer.style.overflow="hidden";
	this.content.style.position="relative";
	this.setHeight();
	
	this.navcontainer.arright.onclick = function(){thisobj.pageUp();};
	this.navcontainer.arleft.onclick = function(){thisobj.pageDown();};
	
	this.pageUp = pageUp;
	this.pageDown = pageDown;
}

function setHeight ()
{
	var curheight = parseInt(getStyle(this.node, "max-height")),
	    //lineheight = parseInt(getStyle(this.content, "line-height")),
		navheight = this.navcontainer.node.offsetHeight,
		newheight = 0;
		
	this.contcontainerheight = parseInt((curheight - navheight) / this.lineheight) * this.lineheight;
	this.contentheight = this.content.offsetHeight;
	this.contcontainer.style.maxHeight = this.contcontainerheight+"px";
	// alert(this.contentheight+" "+this.contcontainerheight+" "+Math.ceil(parseFloat(this.contentheight) / parseFloat(this.contcontainerheight)));
	this.navcontainer.pagetotal = Math.ceil(parseFloat(this.contentheight) / parseFloat(this.contcontainerheight));
	this.navcontainer.curpage = 1;
	this.navcontainer.init();
}

function pageUp()
{
	if (this.navcontainer.curpage < this.navcontainer.pagetotal)
	{
		//alert ("style.top: "+this.content.style.top);
		if (!this.content.style.top) this.content.style.top = - this.contcontainerheight + "px";
		else this.content.style.top = parseInt(this.content.style.top) - this.contcontainerheight + "px";
		// this.content.style.top = this.content.offsetTop - this.contcontainerheight + "px";
		this.navcontainer.curpage++;
		this.navcontainer.init();
	}
}

function pageDown()
{
	if (this.navcontainer.curpage > 1)
	{
		//alert ("style.top: "+this.content.style.top);
		if (!this.content.style.top) this.content.style.top = - this.contcontainerheight + "px";
		else this.content.style.top = parseInt(this.content.style.top) + this.contcontainerheight + "px";
		// this.content.style.top = this.content.offsetTop - this.contcontainerheight + "px";
		this.navcontainer.curpage--;
		this.navcontainer.init();
	}
}

function navcontainer ()
{
	var pnode = newnode("p");
	this.node=createDiv (null,"navcontainer");
	pnode.innerHTML = "";
	this.pagetotal = 0;
	this.curpage = 0;
	
	this.arleft = newnode("span");
	pnode.appendChild(this.arleft);
	var arrowtemp = newImg ("/script/arrow_left_b.png","<-")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_left_r.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_left_b.png\"");
	this.arleft.appendChild(arrowtemp);
	this.arleft.style.cursor="pointer";
	
	this.curpagedisp = newnode("span");
	this.curpagedisp.appendChild (newtextnode(this.curpage+""));
	pnode.appendChild(this.curpagedisp);
	
	pnode.appendChild(newtextnode("/"));
	
	this.totalpagedisp = newnode("span");
	this.totalpagedisp.appendChild (newtextnode(this.pagetotal+""));
	pnode.appendChild(this.totalpagedisp);
	
	this.arright = newnode("span");
	pnode.appendChild(this.arright);
	var arrowtemp = newImg ("/script/arrow_right_b.png","<-")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_right_r.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_right_b.png\"");
	this.arright.appendChild(arrowtemp);
	this.arright.style.cursor="pointer";
	
	this.node.appendChild(pnode);
	
	this.init = navcontainerinit;	
	
}

function navcontainerinit ()
{
	this.curpagedisp.removeChild(this.curpagedisp.firstChild);
	if (this.curpage < 10) this.curpagedisp.appendChild (newtextnode("0"+this.curpage));
	else this.curpagedisp.appendChild (newtextnode(""+this.curpage));
	this.totalpagedisp.removeChild(this.totalpagedisp.firstChild);
	if (this.pagetotal < 10) this.totalpagedisp.appendChild (newtextnode("0"+this.pagetotal));
	else this.totalpagedisp.appendChild (newtextnode(""+this.pagetotal));
}

// End of pagiobj.js
// Start of menu.js

var lastsubentry=null,
	lasttagpopup = null,
	mainx = 500, 
	mainy = 50,
	menuitems=null,
	timestamp=null,
	curarrow;

function openmetalayer(x)
{
	var layernode;
	layernode = document.getElementById(x);
	
	if (x === "metalayer3" || x === "metalayer") setMetalayer3SizePos(layernode);
	
	layernode.style.width=getDocumentWidth()+"px";
	layernode.style.height=getDocumentHeight()+"px";
	
	// alert(getDocumentWidth()+" x "+getDocumentHeight());
	layernode.style.visibility="visible";

}

function setMetalayer3SizePos(ml3node)
{
	var entrynode = document.getElementById("copy");
	if (!entrynode) entrynode = document.getElementById("teaser");
	// ml3node.style.width= entrynode.offsetWidth+"px";
	// ml3node.style.height= entrynode.offsetHeight+"px";
	ml3node.style.maxWidth= "1088px";
	ml3node.style.maxHeight= "570px";
	ml3node.style.top= entrynode.offsetTop+"px";
	ml3node.style.left= entrynode.offsetLeft+"px";
	
	// entrynode.style.backgroundColor="black";
	
	
}

function setMetalayer3SizePos2(ml3node)
{
	var entrynode = document.getElementById("copy");
	ml3node.style.width= ml3node.parentNode.offsetWidth+"px";
	ml3node.style.height= ml3node.parentNode.offsetHeight+"px";
	ml3node.style.top= ml3node.parentNode.offsetTop+"px";
	ml3node.style.left= ml3node.parentNode.offsetLeft+"px";
	ml3node.parentNode.style.backgroundColor="black";
	alert (ml3node.offsetWidth+" "+ml3node.parentNode.offsetWidth+"\n"+ml3node.offsetHeight+" "+ml3node.parentNode.offsetHeight+"\n"+ml3node.offsetTop+" "+ml3node.parentNode.offsetTop+"\n"+ml3node.offsetLeft+" "+ml3node.parentNode.offsetLeft)
	
}

function closemetalayer()
{
	hideAll();
	menuselectionoff();
	document.getElementById("metalayer").style.visibility="hidden";
}

function closemetalayer2()
{
	hideSubElement();
	document.getElementById("metalayer2").style.visibility="hidden";
}

function closemetalayer3()
{
	if (curarrow) curarrow.className="arrow";
	curarrow = null;
	hideMetaTagPopup();
	document.getElementById("metalayer3").style.visibility="hidden";
}

function getDocumentWidth()
{
	if (document.body.scrollWidth)
	return document.body.scrollWidth;
	var w = document.documentElement.offsetWidth;
	if (window.scrollMaxX)
	w += window.scrollMaxX;
	return w;
};

function getDocumentHeight()
{
	if (document.body.scrollHeight)
	return document.body.scrollHeight;
	return document.documentElement.offsetHeight;
};
	
function displayElement(x)
{
	var elementnode = document.getElementById(x);
	
	openmetalayer("metalayer");
	// centerElement (x);
	elementnode.style.zIndex="1001";
	elementnode.style.visibility="visible";
	timestamp=new Date().getTime();
	document.getElementById("meta").onclick=closeaction;
}

function centerElement (name)
{
	var x, y, dimx, dimy, screenx, screeny, node;
	node = document.getElementById(name);
	
	dimx = node.offsetWidth;
	dimy = node.offsetHeight;
	
	screenx = node.parentNode.offsetWidth;
	screeny = node.parentNode.offsetHeight;
	
	// mainx = node.parentNode.offsetLeft;
	// mainy = node.parentNode.offsetTop;
	
	// alert (mainx + " " + mainy);
	
	// screenx = getDocumentWidth();
	// screeny = getDocumentHeight();
	
	x = (screenx - dimx) * 0.5;
	y = (screeny - dimy) * 0.5;
	
	mainx =x+6;
	mainy = y+6;
	// alert (mainx + " " + mainy);
	//alert ("Screen:\t"+screenx+" x "+screeny+"\nBox:\t"+dimx+" x "+dimy+"\nCoordinates:\t"+x+", "+y);
	
	
	node.style.left = x+6+"px";
	node.style.top = y+6+"px";
}

function displaySubElementold(x,left,top)
{
	var elementnode = document.getElementById(x),
		archivepopup = document.getElementById("archivepopup"),
		popupnode;
	openmetalayer("metalayer2");
	//elementnode.style.visibility="visible";
	
	popupnode = archivepopup.appendChild(elementnode.cloneNode(true));
	
	addNewAttribute(popupnode,"id","archpopmeta");
	popupnode.style.left=elementnode.offsetLeft+mainx-90+"px";
	popupnode.style.top=elementnode.offsetTop+mainy+15+"px";
	popupnode.style.zIndex="1011";
	popupnode.style.visibility="visible";
	archivepopup.style.visibility="visible";
	// popupnode.style.opacity=1;
	//popupnode.filters.alpha.opacity=100;
	lastsubentry=x;
	// archivepopup.style.visibility="hidden";
}

function displaySubElement(x,left1,top1)
{
	var elementnode = document.getElementById(x),
		archivepopup = document.getElementById("archivepopup"),
		popupnode,
		archnode = document.getElementById("archive"),
		archwidth= archnode.offsetWidth,
		archheight=archnode.offsetHeight,
		archtop=archnode.offsetTop,
		archleft=archnode.offsetLeft;
	openmetalayer("metalayer2");
	//elementnode.style.visibility="visible";
	
	popupnode = archivepopup.appendChild(elementnode.cloneNode(true));
	
	addNewAttribute(popupnode,"id","archpopmeta");
	
	popupnode.style.zIndex="1011";
	popupnode.style.visibility="visible";
	archivepopup.style.visibility="visible";
	popupnode.style.left=(((archwidth+40) / 2) - ((popupnode.offsetWidth+40) / 2))+archleft+"px";
	popupnode.style.top=(((archheight+40) / 2) - ((popupnode.offsetHeight+40) / 2))+archtop+"px";
	// popupnode.style.opacity=1;
	//popupnode.filters.alpha.opacity=100;
	lastsubentry=x;
	// archivepopup.style.visibility="hidden";
}

function displaySubElementContrib(x,left1,top1)
{
	var elementnode = document.getElementById(x),
		archivepopup = document.getElementById("archivepopup"),
		popupnode,
		archnode = document.getElementById("contributors"),
		archwidth= archnode.offsetWidth,
		archheight=archnode.offsetHeight,
		archtop=archnode.offsetTop,
		archleft=archnode.offsetLeft;
	openmetalayer("metalayer2");
	//elementnode.style.visibility="visible";
	
	popupnode = archivepopup.appendChild(elementnode.cloneNode(true));
	
	addNewAttribute(popupnode,"id","contribpopmeta");
	
	popupnode.style.zIndex="1011";
	popupnode.style.display="block";
	popupnode.style.visibility="visible";
	archivepopup.style.visibility="visible";
	popupnode.style.left=(((archwidth+40) / 2) - ((popupnode.offsetWidth+40) / 2))+archleft+60+"px";
	popupnode.style.top=(((archheight+40) / 2) - ((popupnode.offsetHeight+40) / 2))+archtop+"px";
	
	// popupnode.style.opacity=1;
	//popupnode.filters.alpha.opacity=100;
	lastsubentry=x;
	// archivepopup.style.visibility="hidden";
}

function hideSubElement()
{
	var metalayernode = document.getElementById("archivepopup");
	
	// hideElement(lastsubentry);
	if (metalayernode.firstChild) metalayernode.removeChild(metalayernode.firstChild);
	metalayernode.style.visibility="hidden";
}

function hideElement(x)
{
	if (document.getElementById(x) !== null)
	{
		document.getElementById(x).style.visibility="hidden";
	}
}

function hideAll()
{
	hideElement('about');
	hideElement('archive');
	hideElement('search');
	hideElement('subscribe');
	hideElement('disclaimer');
	hideElement('contributors');
	hideElement('contact');

	if (lastsubentry !== null)
	{
		hideElement(lastsubentry);
		lastsubentry=null;
	}
}

function displayTagPopup(x,node)
{
	var elementnode = document.getElementById(x),popupnode,notelocker=document.getElementById('notelocker');
	notelocker.style.display="block";
	openmetalayer("metalayer3");
		
	popupnode = document.getElementById("metatagpopup").appendChild(elementnode.cloneNode(true));
	
	addNewAttribute(popupnode,"id","tagpopmeta");
	popupnode.style.left=elementnode.offsetLeft+90+"px";
	//popupnode.style.top=elementnode.offsetTop+70+"px";
	popupnode.style.top=centerTagPopup(popupnode)+140+"px";
	popupnode.style.zIndex="501"
	popupnode.style.visibility="visible";
	
	notelocker.style.display="none";
	
	if (node) node.className="arrowselected";
	curarrow = node;
}

function displayHeadlineTagPopup(x,node)
{
	var elementnode = document.getElementById(x),popupnode,notelocker=document.getElementById('notelocker');
	notelocker.style.display="block";
	openmetalayer("metalayer3");
		
	popupnode = document.getElementById("metatagpopup").appendChild(elementnode.cloneNode(true));
	
	addNewAttribute(popupnode,"id","tagpopmeta");
	popupnode.style.left=elementnode.offsetLeft+90+"px";
	//popupnode.style.top=elementnode.offsetTop+70+"px";
	popupnode.style.top="150px";
	popupnode.style.zIndex="501"
	popupnode.style.visibility="visible";
	
	notelocker.style.display="none";
	
	if (node) node.className="arrowselected";
	curarrow = node;
}

function centerTagPopup(node)
{
	var newy,dimy;
	dimy = node.offsetHeight;
	newy = (colheight - dimy) * 0.5;
	return newy;
}

function hideTagPopup()
{
	
	var metalayernode = document.getElementById("archivepopup");
	metalayernode.removeChild(metalayernode.firstChild);
	
}

function hideMetaTagPopup()
{
	
	var metalayernode = document.getElementById("metatagpopup");
	metalayernode.removeChild(metalayernode.firstChild);
	
}

function menuclick (node)
{
	
	addNewAttribute(node,"class","buttonselected");
}

function menuselectionoff()
{
	initmenuitems();
	
	var i=0, length = menuitems.length;
	
	
	
	while (i < length)
	{
		addNewAttribute(menuitems[i],"class","button");
		i++;
	}
}

function initmenuitems()
{
	if (!menuitems)
	{
		menuitems=new Array(document.getElementById("archivebutton"),
						document.getElementById("searchbutton"),
						document.getElementById("contributorsbutton"),
						document.getElementById("aboutbutton"),
						document.getElementById("disclaimerbutton"),
						document.getElementById("subscribebutton"));
	}
}

function closeaction ()
{
	if ((new Date().getTime() - timestamp) > 100 && this.getAttribute("id").toLowerCase()!="meta")
	{
		alert(this.getAttribute("id"));
		//closemetalayer();closemetalayer2();
	}
	
}

// End of menu.js
// Start of columns2_click.js
/* Version 1.1.25 09/15/2010 01:15AM */

// Holds the reformatted Columns of the Article
var colstore = new Array(),


	tablestore = new Array(),

// Height of the Columns
	colheight = 440,

	idcount = 0,

// ID of Div holding the Paginated Output
	pagconid="copy",

// ID of Div holding the temporary paginated output
	tempconid="temp",

	curpagestore = 0,
	cursubarchpagestore = 0,
	
	intextimages = new Array(),
	intextimagespage = new Array(),

	finaltagstore = new Array(),

	gallerycount = 10000,

	profiling = true,
	debug = false,
	debugreformat = false,
	silentprofiling = true,
	profilingstore = new Array(),

	stopwatchtime = 0,

	timerrun = false,

	disableCoverLinks = false,

	oldstylepageflip = false,
	tempimgtitle ="",
	is_ie = (BrowserDetect.browser.toLowerCase() === "explorer");

/* 
Reformat Node
Expects id of a div
*/

function reformat(id,cols)
{
	var originalnode = document.getElementById(id),
		i = 0,length,tempconnode;
	if (debugreformat) alert ("reformat:Start");
	
	createPaginationContainer(originalnode,cols);
	createTempContainer(document.getElementById(pagconid));
	//return;
	
	length = originalnode.childNodes.length;
	while (i< length)
	{
		//if (debugreformat) alert ("reformat:copynodetocolstore "+i+"\/"+(length-1));
		copyNodeToColstore (originalnode.childNodes[i].cloneNode(true),0);
		//if (debugreformat) alert ("reformat:copynodetocolstore "+i+"\/"+(length-1)+" finished");
		i++;
	}
	if (debugreformat) alert ("reformat:copynodetocolstore finished");
	
	originalnode.parentNode.removeChild(originalnode);
	if (debugreformat) alert ("reformat:insertimg");
	insertImg();
	if (debugreformat) alert ("reformat:insertimg fin");
	if (debugreformat) alert ("reformat:setarrow");
	setArrow(cols);
	if (debugreformat) alert ("reformat:setarrow finished");
	
	tempconnode = document.getElementById(tempconid);
	tempconnode.parentNode.removeChild(tempconnode);
	
	if (oldstylepageflip)
	{
		fillnav(cols);
		flip(1,cols);
	}
	else
	{
		fillnav2(cols);
		flip2(1,cols);
	}
	
	
}

/**
 * Create div that holds paginated output
 * @param {DOM} prevsibnode node after which the new div will be inserted
 * @param cols number of columns
 *
 */
function createPaginationContainer (prevsibnode,cols)
{
	var con = createDiv(pagconid,null),
		i = 0,
		helperdiv,
		newcol;
	con.style.display="block";
	addNewAttribute(con,"onclick","hideAll();");
	prevsibnode.parentNode.insertBefore(con,prevsibnode.nextSibling);
	
	
	for (i = 1;i<=cols;i++)
	{
		newcol = createDiv("col"+i,"textcolumn");
		newcol.style.height=colheight+"px";
		con.appendChild(newcol);
	}
	helperdiv = createDiv(null,"reset");
	helperdiv.appendChild(newtextnode("\xa0"));
	con.appendChild(helperdiv);
	con.appendChild(createDiv("nav",null));
}

/**
 * Create div that holds temporary paginated output
 * @param {DOM} prevsibnode node after which the new div will be inserted
 */
function createTempContainer(prevsibnode)
{
	var con = createDiv(tempconid,null);
	con.style.display="block";
	prevsibnode.parentNode.insertBefore(con,prevsibnode.nextSibling);
}

/**
 * Add a new Column to the temporary paginated output and the Array that stores the columns
 */
function newColstore()
{
	var length = colstore.length;
	colstore.push(newnode("div"));
	document.getElementById(tempconid).appendChild(colstore[length]);
}

/**
 * Copies a new node to the current end of the Column Array and the temporary paginated output.
 * If the column gets too high and the node to be copied is a <p> node wrapP will be called.
 * All other types of nodes will be copied to a new Column and they will stay there
 * no matter the size to avoid endless loops and to not lose content.
 * @param node Node to be copied to the colstore array
 */
function copyNodeToColstore (node,level)
{
	if (level == 0) extractImg(node);
	if (colstore.length === 0) newColstore();
	var length = colstore.length, ret;
	colstore[length-1].appendChild(node);
	if (colstore[length-1].offsetHeight > colheight) 
	{
		switch (colstore[length-1].lastChild.nodeName)
		{
			case 'P':
				ret = wrapP ();
				if (ret !== null)
				{
					newColstore();
					if (level < 10) copyNodeToColstore (ret,++level);
					else 
					{
						alert ("infinite loop in copyNodeToColstore\nThere is most likely an unclosed tag or a bold section thats too long");
						throw "exit";
					}
				}
				break;
			default:
				colstore[length-1].removeChild(node);
				newColstore();
				colstore[length].appendChild(node);
				break;
		}
	}
}

function extractImg (node)
{
	var i = 0;
	//if (node.className) alert(node.nodeName+" "+node.className);
	
	if (node.nodeName == "DIV" && node.className == "intextimage")
	{
		addRemoveTitleMouseOver (node);
		//alert("drin");
		intextimages.push(node.cloneNode(true));
		intextimagespage.push(colstore.length + intextimages.length - 1);
		node.innerHTML="";
		node.style.display="none";
	}
	
	else if (node.nodeName == "DIV" && node.className == "gallerysmd") numberGalleries(node);
	
	while (node && i< node.childNodes.length)
	{
		extractImg(node.childNodes[i]);
		i++;
	}
	
}

function addRemoveTitleMouseOver (node)
{
	var i = 0;
	
	if (node.nodeName == "IMG" || node.nodeName == "A")
	{
		
		addNewAttribute(node,"onmouseover","tempimgtitle = this.title;this.title=\"\"");
		addNewAttribute(node,"onmouseout","this.title=tempimgtitle;");
		addNewAttribute(node,"onclick","this.title=tempimgtitle;");
	}
	
	while (node && i< node.childNodes.length)
	{
		addRemoveTitleMouseOver (node.childNodes[i]);
		i++;
	}
}

/* 
function insertImgOld()
{
	var colstorework = new Array(),
	length = intextimages.length,
	colstorepointer = 0,
	colstorelength = colstore.length,
	i = 0,
	nextemptypage;
	
	if (length > 0)
	{
		spreadimages();
		while (i < length)
		{
			colstorework[intextimagespage[i]] = newnode("div");
			colstorework[intextimagespage[i]].appendChild(intextimages[i]);
			i++;
		}
		i=0;
		while (i < colstorelength)
		{
			nextemptypage=getFirstEmpty(colstorework);
			colstorework[nextemptypage]=colstore[i];
			i++;
		}
		colstore = colstorework;
	}
	
}
 */

/* 
function insertImg2()
{
	var colstorework = new Array(),
	length = intextimages.length,
	colstorepointer = 0,
	colstorelength = colstore.length,
	i = 0,
	nextemptypage;
	
	if (length > 0)
	{
		spreadimages();
		while (i < length)
		{
			colstorework[intextimagespage[i]] = newnode("div");
			colstorework[intextimagespage[i]].appendChild(newTable(intextimages[i]));
			i++;
		}
		i=0;
		while (i < colstorelength)
		{
			nextemptypage=getFirstEmpty(colstorework);
			colstorework[nextemptypage]=colstore[i];
			i++;
		}
		colstore = colstorework;
	}
	
}
 */
 
function insertImg()
{
	var colstorework = new Array(),
	length = intextimages.length,
	colstorepointer = 0,
	colstorelength = colstore.length,
	i = 0,
	j = 0,
	nextemptypage,
	tdnode;
	
	if (length > 0)
	{
		spreadimages();
		while (i < length)
		{
			colstorework[intextimagespage[i]] = newnode("div");
			tdnode = newnode("td");
			while (j<length)
			{
				
				if (j === i) tdnode.appendChild(addNumberToRelInDiv(intextimages[j].cloneNode(true),i));
				else tdnode.appendChild(addNumberToRel(getA(intextimages[j]),i));
				j++;
			}
			colstorework[intextimagespage[i]].appendChild(newTable2(tdnode));
			i++;
			j=0;
		}
		i=0;
		while (i < colstorelength)
		{
			nextemptypage=getFirstEmpty(colstorework);
			colstorework[nextemptypage]=colstore[i];
			i++;
		}
		colstore = colstorework;
	}
	
}

function addNumberToRel(node,num)
{
	if (node && node.nodeName == "A" && node.getAttribute("rel"))
	{
		addNewAttribute(node,"rel",node.getAttribute("rel")+num);
		return node;
	}
	else return newtextnode ("");
	
}

function addNumberToRelInDiv(node,num)
{
	var i=0;
	
	if (node.nodeName == "A" && node.getAttribute("rel"))
	{
		addNewAttribute(node,"rel",node.getAttribute("rel")+num);
	}
	
	while (i< node.childNodes.length)
	{
		addNumberToRelInDiv(node.childNodes[i],num);
		i++;
	}
	
	
	return node;
}

function getA (node)
{
	var i = 0,
	ret;
	
	if (node.nodeName == "A")
	{
		return node.cloneNode(false);
	}
	
	while (i< node.childNodes.length)
	{
		ret = getA(node.childNodes[i]);
		i++;
	}
	
	return ret;
}

function getFirstEmpty(ar)
{
	var length=ar.length,i=0;
	while (i < length)
	{
		if (ar[i] == null) return i;
		i++;
	}
	return i;
}

function spreadimages()
{
	var length = intextimagespage.length,i=0,lastpage = -1;
	while (i<length)
	{
		if (intextimagespage[i] <= lastpage)
		{
			intextimagespage[i] = lastpage + 1;
		}
		lastpage = intextimagespage[i];
		i++;
	}
}

/**
 * Copies the last added <p> node word for word beginning from the end from the current column
 * to a new one until the column is within the allowed height.
 * Nodes inside the <p> node (divs, img, span etc.) will be copied to the new column without wrapping.
 */
function wrapP ()
{
	var oldnode = colstore[colstore.length-1].lastChild,
		newnode,
		oldText = new Array(),
		newText = new Array(),
		ret = null,
		length = colstore.length,
		oldTextPlain = "",
		newTextPlain = "",
		tempnode;
	
	
	oldnode.normalize();
		
	newnode = oldnode.cloneNode(false);
	
	
	
	addNewAttribute(newnode,"style","text-indent:0px;");
	
	while (colstore[length-1].offsetHeight > colheight)
	{
		oldTextPlain = "";
		newTextPlain = "";
		oldText = new Array(); 
		newText = new Array();
		if (oldnode.lastChild.nodeType == 3)
		{
			oldTextPlain = oldnode.lastChild.nodeValue;
			oldText=oldTextPlain.split(/\s/);
					
			while (colstore[length-1].offsetHeight > colheight && oldText.length>0) 
			{
				
				newText.push(oldText.pop());
				oldnode.lastChild.nodeValue=oldText.join(' ');
				oldnode.normalize();
			}
			
			newTextPlain = newText.reverse().join(' ');
			if (/^\s/.test(oldTextPlain))
			{
				//newTextPlain = "\xa0" + newTextPlain; //Hack to account for IE stripping leading whitespace, should be normal space.
				newTextPlain = " " + newTextPlain;
			}
			
			if (/\s$/.test(oldTextPlain)) newTextPlain += " ";
			
			newnode.insertBefore(newtextnode (newTextPlain),newnode.firstChild);
			
						
			if (oldText.length === 0 && oldnode.childNodes.length > 0)
			{
				tempnode = oldnode.removeChild(oldnode.lastChild);
				newnode.insertBefore(tempnode, newnode.firstChild);
						
			}
						
		}
		else
		{
			tempnode = oldnode.removeChild(oldnode.lastChild);
			newnode.insertBefore(tempnode, newnode.firstChild);
		}
	}
	return newnode;
}

/* 
function flip (page,cols)
{
	var i = 1;
	while (i <= cols)
	{
		fillcol (i,(page * cols) - (cols - i));
		i++;
	}
	switchpageindikator(page,cols);
	Slimbox.scanPage();
}
 */

function flip2 (page,cols)
{
	var i = 1;
	while (i <= cols)
	{
		fillcol (i,(page * cols) - (cols - i));
		i++;
	}
	curpagestore = page;
	switchpageindikator2(page);
	Slimbox.scanPage();
	Mediabox.scanPage();
}

function flippgup (cols)
{
	var count = Math.ceil (colstore.length / cols);
	if (curpagestore < count)
	{
		flip2(curpagestore+1,cols);
	}
}

function flippgdown (cols)
{
	var count = Math.ceil (colstore.length / cols);
	if (curpagestore > 1)
	{
		flip2(curpagestore-1,cols);
	}
}


function fillcol (col,page)
{
	var curcol = document.getElementById("col"+col),
		i = 0;
	curcol.innerHTML ="";
	if (colstore.length > (page-1))
	{
		while (colstore[page-1].childNodes.length > i)
		{
			curcol.appendChild(colstore[page-1].childNodes[i].cloneNode(true));
			
			i++;
		}
	}
}

/* 
function fillnav(cols)
{
	var count = Math.ceil (colstore.length / cols),
		i = 1,
		newspan,
		node = newnode("p");
		
	node.appendChild(newtextnode("Page "));
	for (i; i<=count;i++)
	{
		newspan = newnode("span");
		newspan.appendChild(newtextnode(i));
		addNewAttribute(newspan,"onclick","flip("+i+","+cols+")");
		addNewAttribute(newspan,"id","navspan"+i);
		newspan.style.cursor="pointer";
		
		node.appendChild(newspan);
	}
	document.getElementById("nav").appendChild(node);
}
 */

function fillnav2(cols)
{
	var count = Math.ceil (colstore.length / cols),
		i = 1,	
		node = newnode("p"),
		pgdownspan = newnode("span"),
		curpagedisp = newnode("span"),
		totalpagedispd = newnode("span"),
		totalpagedisp = newnode("span"),
		pgupspan = newnode("span");
	
	
	// pgdownspan.appendChild(newtextnode("<"));newImg (src,alt)
	var arrowtemp = newImg ("/script/arrow_left_b.png","<-")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_left_r.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_left_b.png\"");
	pgdownspan.appendChild(arrowtemp);
	addNewAttribute(pgdownspan,"onclick","flippgdown("+cols+")");
	pgdownspan.style.cursor="pointer";
	node.appendChild(pgdownspan);
	
	
	
	curpagedisp.appendChild(newtextnode("\xa0"));
	addNewAttribute(curpagedisp,"id","curpagedisp");
	node.appendChild(curpagedisp);
	
	
	//totalpagedispd.appendChild(newImg ("/script/slash.png","/"));
	totalpagedispd.appendChild(newtextnode("/"));
	node.appendChild(totalpagedispd);
	
	
	if (count > 9) totalpagedisp.appendChild(newtextnode(""+count));
	else totalpagedisp.appendChild(newtextnode("0"+count));
	node.appendChild(totalpagedisp);
	
	
	// pgupspan.appendChild(newtextnode(">"));
	var arrowtemp = newImg ("/script/arrow_right_b.png","->")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_right_r.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_right_b.png\"");
	pgupspan.appendChild(arrowtemp);
	addNewAttribute(pgupspan,"onclick","flippgup("+cols+")");
	addNewAttribute(pgupspan,"id","lastelimg");
	pgupspan.style.cursor="pointer";
	node.appendChild(pgupspan);
	
	document.getElementById("nav").appendChild(node);
}


/* 
function fillnav2(cols)
{
	var count = Math.ceil (colstore.length / cols),
		i = 1,	
		node = newnode("p"),
		pgdownspan = newnode("span"),
		curpagedisp = newnode("span"),
		totalpagedispd = newnode("span"),
		totalpagedisp = newnode("span"),
		spacer = newnode("span"),
		curpagedisp2 = newnode("span"),
		totalpagedispd2 = newnode("span"),
		totalpagedisp2 = newnode("span"),
		pgupspan = newnode("span");
	
	
	// pgdownspan.appendChild(newtextnode("<"));newImg (src,alt)
	pgdownspan.appendChild(newImg ("/script/arrow_links.jpg","<-"));
	addNewAttribute(pgdownspan,"onclick","flippgdown("+cols+")");
	pgdownspan.style.cursor="pointer";
	node.appendChild(pgdownspan);
	
	
	
	curpagedisp.appendChild(newtextnode("\xa0"));
	addNewAttribute(curpagedisp,"id","curpagedisp");
	node.appendChild(curpagedisp);
	
	
	//totalpagedispd.appendChild(newImg ("/script/slash.png","/"));
	totalpagedispd.appendChild(newtextnode("/"));
	node.appendChild(totalpagedispd);
	
	
	if (count > 9) totalpagedisp.appendChild(newtextnode(""+count));
	else totalpagedisp.appendChild(newtextnode("0"+count));
	node.appendChild(totalpagedisp);
	
	addNewAttribute(spacer,"class","spacer");
	node.appendChild(spacer);
	
	curpagedisp2.appendChild(newtextnode("\xa0"));
	addNewAttribute(curpagedisp2,"id","curpagedisp2");
	node.appendChild(curpagedisp2);
	
	
	//totalpagedispd.appendChild(newImg ("/script/slash.png","/"));
	totalpagedispd2.appendChild(newtextnode("/"));
	node.appendChild(totalpagedispd2);
	
	
	if (count > 9) totalpagedisp2.appendChild(newtextnode(""+count));
	else totalpagedisp2.appendChild(newtextnode("0"+count));
	node.appendChild(totalpagedisp2);
	
	
	// pgupspan.appendChild(newtextnode(">"));
	pgupspan.appendChild(newImg ("/script/arrow_rechts.jpg","->"));
	addNewAttribute(pgupspan,"onclick","flippgup("+cols+")");
	addNewAttribute(pgupspan,"id","lastelimg");
	pgupspan.style.cursor="pointer";
	node.appendChild(pgupspan);
	
	document.getElementById("nav").appendChild(node);
}
 */
/* 
function switchpageindikator(page,cols)
{
	var count = Math.ceil (colstore.length / cols),
		i = 1;
	for (i; i<=count;i++)
	{
		addNewAttribute(document.getElementById("navspan"+i),"class","paginav");
	}
	
	addNewAttribute(document.getElementById("navspan"+page),"class","paginavselected");
}
 */

function switchpageindikator2(page)
{
	var curpagedisp=document.getElementById("curpagedisp"),
	
	i = 0;
	while (i < curpagedisp.childNodes.length)
	{
		curpagedisp.removeChild(curpagedisp.firstChild);
		
	}
	
	if (page > 9) 
	{
		curpagedisp.appendChild(newtextnode(""+page));
		
	}
	else
	{
		curpagedisp.appendChild(newtextnode("0"+page));
		
	}
}

function setArrow (cols)
{
	parseAuthor();
	if (is_ie) return;
	var i = 0;
	while (colstore.length > i)
	{
		parseColumns (colstore[i],((i+1)%cols),cols,0);
		i++;
	}
	
}

function parseAuthor()
{
	
	var i = 0,
	authorstore = document.getElementById("contributors_store"),
	count = 0,
	curnode,
	tagvalue,
	newmark,
	onmouse,
	headernode;
	if (authorstore)
	{
		count = authorstore.childNodes.length;
		//if (!curauthor)  i = count;
		
		curauthor = curauthor.replace(/\u00a0/g,"_");
		curauthor = curauthor.replace(/&#160;/g,"_");
		curauthor = curauthor.replace(/&nbsp;/g,"_");
		curauthor = curauthor.replace(/\s/g,"_");
		
		while (i < count)
		{
			curnode = authorstore.childNodes[i];
			if (curnode.nodeType === 1)
			{
				tagvalue = curnode.getAttribute("data-metatag-author");
				
				tagvalue = tagvalue.replace(/\u00a0/g,"_");
				tagvalue = tagvalue.replace(/&#160;/g,"_");
				tagvalue = tagvalue.replace(/&nbsp;/g,"_");
				tagvalue = tagvalue.replace(/\s/g,"_");
						   
				
				
				// alert("tagvalue: "+tagvalue +"\ncurauthor: "+curauthor);
				
				if (tagvalue.toLowerCase() === curauthor.toLowerCase())
				{
					document.getElementById("notelocker").appendChild(curnode);
					
					
					newmark= newnode("span");
					var autharrowpic = newImg("/script/kleines_m_b.png","M");
					newmark.appendChild(autharrowpic);
					newmark.style.cursor="pointer";
					//newmark.appendChild(newtextnode("\u00a0") );
					addNewAttribute(newmark,"class","autharrow");
					addNewAttribute(autharrowpic,"onmouseover","this.src=\"/script/kleines_m_r.png\"");
					addNewAttribute(autharrowpic,"onmouseout","this.src=\"/script/kleines_m_b.png\"");
					addNewAttribute(autharrowpic,"onclick","this.src=\"/script/kleines_m_r.png\"");
					
					onmouse = "displayHeadlineTagPopup(\'metatagid"+ (++idcount)+"\',null);";
					newmark.setAttributeNode(newAttribute("onclick",onmouse));
					
					headernode = document.getElementById("article-header").firstChild;
					
					headernode.insertBefore(newmark,headernode.lastChild);
					newmark.style.position="relative";
					
					newmark.style.top="5px";
					newmark.style.left="38px";
					
					addNewAttribute(curnode,"id","metatagid"+ (idcount));
					addNewAttribute(curnode,"class","arrowpopupnote");
					curnode.style.left="-38px";
					i = count;
				}
			}
			
			i++;
		}
	
	}
	
}


function parseColumns (node, col,cols,offsetparent)
{
	var i = 0,
		yoff = 0,
		xoff = 0,
		targetcol,
		parnode,
		newmark,
		onmouse,
		nodevalue,
		archivenode,
		content,
		contentnode,
		j,
		index,
		taglength,
		newlist,
		k,
		sublength,
		linktitle,
		linkurl,
		newlink,
		linkext,
		mouseovernode = "content",
		isheadline = false;
		
	if (col === 0) col = cols;
	
	if (node.nodeName == "SPAN" && (node.getAttribute("data-metatag-link") || node.getAttribute("data-metatag-note") || node.getAttribute("data-metatag-notepic") || node.getAttribute("data-metatag-gallery")))
	{
		targetcol = document.getElementById("col"+col);
		parnode = node.parentNode.parentNode;
		yoff = ((node.offsetTop) - node.parentNode.parentNode.offsetTop) + targetcol.offsetTop + 0 + offsetparent;
		if (offsetparent == 1) yoff = ((node.offsetTop) - node.parentNode.parentNode.offsetTop) + ((node.parentNode.offsetTop) - node.parentNode.parentNode.parentNode.offsetTop) + targetcol.offsetTop - 3 ;
		xoff = targetcol.offsetLeft - 91;
		
		newmark= newnode("div");
		// newmark.appendChild(newImg("/arrow.png","->"));
		// newmark.style.cursor="pointer";
		newmark.appendChild(newtextnode("\u00a0") );
		addNewAttribute(newmark,"class","arrow");
		
		onmouse = "displayTagPopup(\'metatagid"+ (++idcount)+"\',this);";
		newmark.setAttributeNode(newAttribute("onclick",onmouse));
		
		
		if (node.getAttribute("data-metatag-headline"))
		{
			isheadline = true;
			document.getElementById("article-header").appendChild(newmark);
			newmark.style.position="relative";
					
			newmark.style.top="-24px";
			newmark.style.left="-507px";
			onmouse = "displayHeadlineTagPopup(\'metatagid"+ (idcount)+"\',this);";
			newmark.setAttributeNode(newAttribute("onclick",onmouse));
		}
		else if (node.getAttribute("data-metatag-gallery")) 
		{
			parnode.appendChild(newmark);
			newmark.style.position="absolute";
			newmark.style.top=yoff+(195)+"px";
			onmouse = "document.location = document.getElementById('smdgallink').getAttribute('href');";
			newmark.setAttributeNode(newAttribute("onclick",onmouse));
			newmark.style.left=xoff+"px";
		}
		else
		{
			parnode.appendChild(newmark);
			newmark.style.position="absolute";
			if (node.getAttribute("data-metatag-notepic"))
			{
				newmark.style.top=yoff+(195)+"px";
			}
			else
			{
				newmark.style.top=yoff+"px";
			}
			
			
			
			newmark.style.left=xoff+"px";
			//newmark.style.margin="0px";
			//newmark.style.padding="0px";
		}
		
		
		
		
		
		
		if (node.getAttribute("data-metatag-link"))
		{
			nodevalue = node.getAttribute("data-metatag-link");
			//var archivenode = document.getElementById(nodevalue);
			archivenode = true;
			if (archivenode)
			{
				contentnode = createDiv("metatagid"+ (idcount),"arrowpopuplink");
				// contentnode.innerHTML = "<span style=\"text-decoration:none;\">Related articles on the topic:</span><br \>"
				contentnode.innerHTML = "<span style=\"text-decoration:none;\">Related articles on &ldquo;"+nodevalue+"&rdquo;</span><br \>"
				j = 0;
				index = -1;
				taglength = tagstore.length;
				while (j < taglength)
				{
					if (tagstore[j][0].toLowerCase()  === nodevalue.replace(/\s/g,"_-_").toLowerCase())
					{
						index = j;
						j = taglength;
					}
					
					j++;
				}
				if (index !== -1)
				{
					newlist = newnode("ul");
					//addNewAttribute(newlist,"onclick",onmouse);
					k = 1;
					sublength = tagstore[index].length;
					while (k < sublength)
					{
						newlist.appendChild(newnode("li"));
						linktitle=tagstore[index][k++].replace(/&#160;/g,"\u00a0");
						linktitle=linktitle.replace(/&#39;/g,"\'");
						
						linkurl=tagstore[index][k++];
						if (linkurl !== getCoverUrl(cursiteurl))
						{
							newlink = newLink(linktitle,linkurl);
							//addNewAttribute(newlink,"onclick",onmouse);
							//addNewAttribute(newlink,"target","_blank");
							newlist.lastChild.appendChild(newlink);
						}
						else
						{
							newlist.removeChild(newlist.lastChild);
						}
					}
					contentnode.appendChild(newlist);
					
					
				}
				if (!isheadline)
				{
					contentnode.style.top = newmark.style.top;
					contentnode.style.left = newmark.style.left;
				}
				else
				{
					contentnode.style.left = "-38px";
				}
				//addNewAttribute(contentnode,"onmouseout","hideTagPopup();");
				// node.parentNode.insertBefore(contentnode,node.nextSibling);
				document.getElementById("notelocker").appendChild(contentnode);
			}
		}
		
		else if (node.getAttribute("data-metatag-note") || node.getAttribute("data-metatag-notepic"))
		{
			if (node.getAttribute("data-metatag-note"))
			{
				content = node.getAttribute("data-metatag-note");
			}
			else if (node.getAttribute("data-metatag-notepic"))
			{
				content = node.getAttribute("data-metatag-notepic");
			}
			contentnode = createDiv(null,"metanote");
			contentnode.setAttributeNode(newAttribute("id","metatagid"+ (idcount)));
			contentnode.setAttributeNode(newAttribute("class","arrowpopupnote"));
			if (!isheadline)
			{
				contentnode.style.top = newmark.style.top;
				contentnode.style.left = newmark.style.left;
			}
			else
				{
					contentnode.style.left = "-38px";
				}
			//addNewAttribute(contentnode,"onmouseout","hideTagPopup();");
			//node.parentNode.insertBefore(contentnode,node.nextSibling);
			document.getElementById("notelocker").appendChild(contentnode);
			if (node.getAttribute("data-metatag-linkextern"))
			{
				contentnode.appendChild(newtextnode(content));
				contentnode.appendChild(newnode("br"));
				linkext = newLink ("Go there now",node.getAttribute("data-metatag-linkextern"));
				//addNewAttribute(linkext,"onclick",onmouse);
				addNewAttribute(linkext,"target","_blank");
				contentnode.appendChild(linkext);
			}
			else
			{
				contentnode.appendChild(newtextnode(content));
			}
		}
		
	}
	
	while (i< node.childNodes.length)
	{
		if (node.nodeName == "SPAN") offsetparent=1;
		parseColumns(node.childNodes[i], col,cols,offsetparent);
		i++;
	}

}

function splitTagstore()
{
	var length = tagstore.length,
		curfirstl = "",
		i = 0;
		
	finaltagstore.push(new Array());
	while (i < length)
	{
		if (tagstore[i][0].toLowerCase() !== "image")
		{
			curfirstl = tagstore[i][0].charAt(0);
			if (curfirstl.toUpperCase() != finaltagstore[0][finaltagstore[0].length-1])
			{
				finaltagstore[0].push(curfirstl.toUpperCase());
				finaltagstore.push(new Array());
			}
			finaltagstore[finaltagstore.length-1].push(tagstore[i]);
		}
		
		i++;
	}
}

/* function buildArchive2 (cols,rows,node)
{
	
	var parentnode = document.getElementById(node),
		newspan,
		archnav = createDiv("archnav",null),
		i = 0,
		length = 0,
		tablestpos,
		j = 0,
		length2,
		newtable,
		k,
		tablecell1,
		tablecell2,
		l,
		sublength,
		tagdiv,
		onclickattr,
		linkdiv,
		listnode; 
	
	splitTagstore();
	length = finaltagstore[0].length;
	while (i < length)
	{
		newspan = newnode("span");
		addNewAttribute(newspan,"onclick","fliparchive("+(i)+","+cols+");");
		addNewAttribute(newspan,"class","paginav");
		// addNewAttribute(newspan,"onclick","hideSubElement();");
		newspan.appendChild(newtextnode(finaltagstore[0][i]));
		archnav.appendChild(newspan);
		i++;
	}
	parentnode.appendChild(archnav);
	parentnode.appendChild(createDiv("archcont",null));
	parentnode.appendChild(createDiv("archsubnav",null));
	
	i = 1;
	length = finaltagstore.length;
	while (i < length)
	{
		tablestore.push(new Array());
		tablestpos = tablestore.length - 1;
		
		j = 0;
		length2 = finaltagstore[i].length;
		while (j < length2)
		{
			newtable = newnode("table");
			k = 0;
			while (k < rows)
			{
				newtable.appendChild(newnode("tr"));
				tablecell1 = newnode("td");
				tablecell2 = newnode("td");
				addNewAttribute(tablecell1,"class","archtagstagcell");
				addNewAttribute(tablecell2,"class","archtagslinkcell");
				newtable.lastChild.appendChild(tablecell1);
				newtable.lastChild.appendChild(tablecell2);
				if (finaltagstore[i][j])
				{
					l = 1;
					sublength = finaltagstore[i][j].length;
					tagdiv = createDiv(null,"tagdiv");
					onclickattr = document.createAttribute("onclick");
					onclickattr.nodeValue="displaySubElement(\'"+finaltagstore[i][j][0]+"\',this.offsetLeft,this.offsetTop);";
					tagdiv.setAttributeNode(onclickattr);
					// tagdiv.appendChild(newtextnode(finaltagstore[i][j][0].replace(/&#160;/g,"\u00a0")));
					tagdiv.appendChild(newtextnode(finaltagstore[i][j][0].replace(/_-_/g,"\u00a0")));
					tagdiv.style.cursor="pointer";
					addNewAttribute(tagdiv,"class","archtagstagdiv");
					tablecell1.appendChild(tagdiv);
					
					linkdiv = createDiv (finaltagstore[i][j][0],"linkdiv");
					listnode = newnode("ul");
					linkdiv.appendChild(listnode);
					while (l < sublength)
					{
						listnode.appendChild(newnode("li"));
						listnode.lastChild.appendChild(newLink(finaltagstore[i][j][l++].replace(/&#160;/g,"\u00a0"),finaltagstore[i][j][l++]));
						
						
					}
					linkdiv.style.visibility="hidden";
					linkdiv.style.position="absolute";
					addNewAttribute(linkdiv,"class","archtagslinkdiv");
					tablecell2.appendChild(linkdiv);
				}
				else
				{
					tablecell1.appendChild(newtextnode("\u00a0"));
					tablecell2.appendChild(newtextnode("\u00a0"));
				}
				
				k++;
				j++;
			}
			
			newtable.style.display="block";
			newtable.style.cssFloat="left";
			newtable.style.styleFloat="left";
			addNewAttribute(newtable,"class","archtagstable");
			tablestore[tablestpos].push(newtable);
			
		}
		i++;
	
	}
	fliparchive(0,cols);
} */

function buildArchive2 (cols,rows,node)
{
	
	var parentnode = document.getElementById(node),
		newspan,
		archnav = createDiv("archnav",null),
		i = 0,
		length = 0,
		tablestpos,
		j = 0,
		length2,
		newtable,
		k,
		tablecell1,
		tablecell2,
		l,
		sublength,
		tagdiv,
		onclickattr,
		linkdiv,
		listnode; 
	
	splitTagstore();
	length = finaltagstore[0].length;
	while (i < length)
	{
		newspan = newnode("span");
		addNewAttribute(newspan,"onclick","fliparchive("+(i)+","+cols+");");
		addNewAttribute(newspan,"class","paginav");
		//addNewAttribute(newspan,"onclick","hideSubElement();");
		newspan.appendChild(newtextnode(finaltagstore[0][i]));
		archnav.appendChild(newspan);
		i++;
	}
	parentnode.appendChild(archnav);
	parentnode.appendChild(createDiv("archcont",null));
	parentnode.appendChild(createDiv("archsubnav",null));
	
	i = 1;
	length = finaltagstore.length;
	while (i < length)
	{
		tablestore.push(new Array());
		tablestpos = tablestore.length - 1;
		
		j = 0;
		length2 = finaltagstore[i].length;
		while (j < length2)
		{
			newtable = newnode("table");
			k = 0;
			while (k < rows)
			{
				newtable.appendChild(newnode("tr"));
				tablecell1 = newnode("td");
				tablecell2 = newnode("td");
				addNewAttribute(tablecell1,"class","archtagstagcell");
				addNewAttribute(tablecell2,"class","archtagslinkcell");
				newtable.lastChild.appendChild(tablecell1);
				newtable.lastChild.appendChild(tablecell2);
				if (finaltagstore[i][j])
				{
					l = 1;
					sublength = finaltagstore[i][j].length;
					tagdiv = createDiv(null,"tagdiv");
					onclickattr = document.createAttribute("onclick");
					onclickattr.nodeValue="displaySubElement(\'"+finaltagstore[i][j][0]+"\',this.offsetLeft,this.offsetTop);";
					tagdiv.setAttributeNode(onclickattr);
					//tagdiv.appendChild(newtextnode(finaltagstore[i][j][0].replace(/&#160;/g,"\u00a0")));
					tagdiv.appendChild(newtextnode(finaltagstore[i][j][0].replace(/_-_/g,"\u00a0")));
					tagdiv.style.cursor="pointer";
					addNewAttribute(tagdiv,"class","archtagstagdiv");
					tablecell1.appendChild(tagdiv);
					
					linkdiv = createDiv (finaltagstore[i][j][0],"linkdiv");
					//listnode = newnode("ul");
					//linkdiv.appendChild(listnode);
					while (l < sublength)
					{
						linkdiv.appendChild(newnode("p"));
						linkdiv.lastChild.appendChild(newLink(finaltagstore[i][j][l++].replace(/&#160;/g,"\u00a0"),finaltagstore[i][j][l++]));
						
						
					}
					linkdiv.style.visibility="hidden";
					linkdiv.style.position="absolute";
					addNewAttribute(linkdiv,"class","archtagslinkdiv");
					tablecell2.appendChild(linkdiv);
				}
				else
				{
					tablecell1.appendChild(newtextnode("\u00a0"));
					tablecell2.appendChild(newtextnode("\u00a0"));
				}
				
				k++;
				j++;
			}
			
			newtable.style.display="block";
			newtable.style.cssFloat="left";
			newtable.style.styleFloat="left";
			addNewAttribute(newtable,"class","archtagstable");
			tablestore[tablestpos].push(newtable);
			
		}
		i++;
	
	}
	fliparchive(0,cols);
}

function fliparchive(page,cols)
{
	var archnavdiv = document.getElementById("archnav"),
		i = 0;
	while(i < archnavdiv.childNodes.length)
	{
		addNewAttribute(archnavdiv.childNodes[i],"class","paginav");
		i++;
	}
	addNewAttribute(archnavdiv.childNodes[page],"class","paginavselected");
	if (oldstylepageflip)
	{
		buildsubarch(tablestore[page],page,cols);
	}
	else
	{
		buildsubarch2(tablestore[page],page,cols);
	}
}

/* 
function flipsubarch(page,tablest,cols)
{
	var subarchnavdiv = document.getElementById("archsubnav"),
		i = 0,
		content = document.getElementById("archcont"),
		length = tablest.length;
	
	while(i < subarchnavdiv.childNodes.length)
	{
		addNewAttribute(subarchnavdiv.childNodes[i],"class","paginav");
		i++;
	}
	addNewAttribute(subarchnavdiv.childNodes[page],"class","paginavselected");
	
	
	content.innerHTML = "";
	
	
	
	i = 0;
	while (i < cols && ( i + (page * cols) < length))
	{
		content.appendChild(tablest[i + (page * cols)].cloneNode(true));
		i++;
	}
	Slimbox.scanPage();
	// centerElement ("archive");
}
 */

function flipsubarch2(page,tablest,cols)
{
	var subarchnavdiv = document.getElementById("cursubarchpagedisp"),
		i = 0,
		content = document.getElementById("archcont"),
		length = tablest.length;
	
	while (i < subarchnavdiv.childNodes.length)
	{
		subarchnavdiv.removeChild(subarchnavdiv.firstChild);
	}
	
	if (page > 8) subarchnavdiv.appendChild(newtextnode(""+(page+1)));
	else subarchnavdiv.appendChild(newtextnode("0"+(page+1)));
	cursubarchpagestore = page+1;
	
	
	content.innerHTML = "";
	
	
	
	i = 0;
	while (i < cols && ( i + (page * cols) < length))
	{
		content.appendChild(tablest[i + (page * cols)].cloneNode(true));
		i++;
	}
	Slimbox.scanPage();
	Mediabox.scanPage();
	// centerElement ("archive");
}

/* 
function buildsubarch(tablest,page,cols)
{
	var length = Math.ceil(tablest.length/cols),
		i = 0,
		parent = document.getElementById("archsubnav"),
		newspan;
		
	parent.innerHTML = "";
	while (i < length)
	{
		newspan = newnode("span");
		addNewAttribute(newspan,"onclick","flipsubarch("+(i)+",tablestore["+page+"],"+cols+");");
		//addNewAttribute(newspan,"onclick","hideSubElement();");
		newspan.appendChild(newtextnode((++i) +""));
		parent.appendChild(newspan);
		
	}
	flipsubarch(0,tablest,cols);
}
 */

function buildsubarch2(tablest,page,cols)
{
	var length = Math.ceil(tablest.length/cols),
		i = 0,
		parentnode = document.getElementById("archsubnav"),
		node = newnode("p"),
		pgdownspan = newnode("span"),
		curpagedisp = newnode("span"),
		totalpagedispd = newnode("span"),
		totalpagedisp = newnode("span"),
		pgupspan = newnode("span");
	
	
	parentnode.innerHTML = "";
	
	// pgdownspan.appendChild(newtextnode("<"));
	var arrowtemp = newImg ("/script/arrow_left_r.png","<-")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_left_b.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_left_r.png\"");
	pgdownspan.appendChild(arrowtemp);
	addNewAttribute(pgdownspan,"onclick","flipsubarchpgdown(tablestore["+page+"],"+cols+");");
	pgdownspan.style.cursor="pointer";
	node.appendChild(pgdownspan);
	
	curpagedisp.appendChild(newtextnode("\xa0"));
	addNewAttribute(curpagedisp,"id","cursubarchpagedisp");
	node.appendChild(curpagedisp);
	
	
	//totalpagedispd.appendChild(newImg ("/script/slash.png","/"));
	totalpagedispd.appendChild(newtextnode("/"));
	node.appendChild(totalpagedispd);
	
	
	if (length > 9) totalpagedisp.appendChild(newtextnode(""+length));
	else totalpagedisp.appendChild(newtextnode("0"+length));
	node.appendChild(totalpagedisp);
	
	
	// pgupspan.appendChild(newtextnode(">"));
	var arrowtemp = newImg ("/script/arrow_right_r.png","->")
	addNewAttribute(arrowtemp,"onmouseover","this.src=\"/script/arrow_right_b.png\"");
	addNewAttribute(arrowtemp,"onmouseout","this.src=\"/script/arrow_right_r.png\"");
	pgupspan.appendChild(arrowtemp);
	addNewAttribute(pgupspan,"onclick","flipsubarchpgup(tablestore["+page+"],"+cols+");");
	pgupspan.style.cursor="pointer";
	node.appendChild(pgupspan);
	
	parentnode.appendChild(node);
	
	flipsubarch2(0,tablest,cols);
}

function flipsubarchpgup (tablest,cols)
{
	var length = Math.ceil(tablest.length/cols);
	if (cursubarchpagestore < length)
	{
		flipsubarch2(cursubarchpagestore,tablest,cols);
	}
}

function flipsubarchpgdown (tablest,cols)
{
	if (cursubarchpagestore > 1)
	{
		flipsubarch2(cursubarchpagestore-2,tablest,cols);
	}
}

function buildImgArchive (cols,rows)
{
	var archnavdiv = document.getElementById("archnav"),
		imgstorenode = document.getElementById("imgstore"),
	
		tablestoreindex = tablestore.length,
		imgstorecount= imgstorenode.childNodes.length,
		i = 0,
		newtable,
		j,
		emptytable,
		tablecell,
		newspan = newnode("span");
	
	//stripImgSizeAttr (imgstorenode);
	tablestore.push(new Array());
	
	while (i < imgstorecount)
	{
		newtable = newnode("table");
		j = 0;
		emptytable = false;
		while (j < rows)
		{
			if (j === 0 && imgstorecount === 0)
			{
				emptytable = true;
			}
			newtable.appendChild(newnode("tr"));
			tablecell = newnode ("td");
			newtable.lastChild.appendChild(tablecell);
			if (imgstorecount > 0) 
			{
				if (imgstorenode.firstChild.nodeName === "DIV")
				{
					// numberGalleries(imgstorenode.firstChild);
					tablecell.appendChild(imgstorenode.removeChild(imgstorenode.firstChild));
					addNewAttribute(tablecell.lastChild,"class","imgarchdiv");
					addNewAttribute(tablecell,"class","imgarchtd");
				}
				else
				{
					imgstorenode.removeChild(imgstorenode.firstChild);
					newtable.removeChild(newtable.lastChild);
					j--;
				}
			}
			else 
			{
				tablecell.appendChild(newtextnode("\u00a0"));
			}
			imgstorecount--;
			j++;
		}
		newtable.style.display="block";
		newtable.style.cssFloat="left";
		newtable.style.styleFloat="left";
		if (!emptytable) tablestore[tablestoreindex].push(newtable);
	}
	
	addNewAttribute(newspan,"onclick","fliparchive("+tablestoreindex+","+cols+");");
	addNewAttribute(newspan,"class","paginav");
	newspan.style.cssFloat="left";
	//newspan.style.marginRight="79px";
	newspan.style.marginLeft="0px";
	newspan.style.paddingLeft="0px";
	//addNewAttribute(newspan,"onclick","hideSubElement();");
	newspan.appendChild(newtextnode("Articles"));
	archnavdiv.appendChild(newspan);
	fliparchive(tablestoreindex,cols);
}

/* 
function stripImgSizeAttr (node)
{
	var i = 0;
	
	if (node.nodeName == "IMG")
	{
		addNewAttribute(node,"width",null);
		addNewAttribute(node,"height",null);
		addNewAttribute(node,"class","intext");
	}
	
	while (i< node.childNodes.length)
	{
		stripImgSizeAttr(node.childNodes[i]);
		i++;
	}
}
 */

function numberGalleries (node)
{
	var childcount = node.childNodes.length,
		i = 0,
		isgallery = false, titlestore ="";
		
	while (i < childcount)
	{
		
		if (node.childNodes[i].getAttribute("REL") != null && node.childNodes[i].getAttribute("REL").toLowerCase() === "lightbox-smd")
		{
			isgallery = true;
			addNewAttribute(node.childNodes[i],"rel","lightbox-smd" + gallerycount);
		}
		
		
		i++;
	}
	if (isgallery) gallerycount++;
}

function getCoverBaseURL ()
{
	var cutpos = permlinkstore[1].lastIndexOf("/");
	permlinkstore[0] = permlinkstore[1].slice(0,cutpos+1) + "?pg=";
}

function changeLinksDOM (node)
{
	if (node)
	{
		var i = 0,
		href ="";
		
		if (node.nodeName === "A")
		{
			
			href = node.getAttribute("HREF");
			addNewAttribute(node,"href",getCoverUrl (href));		
		}
		
		while (i< node.childNodes.length)
		{
			changeLinksDOM(node.childNodes[i]);
			i++;
		}
	}
}

function changeLinksImgstore (node)
{
	if (node)
	{
		var i = 0, 
		url ="",
		onclick ="";
		
		if (node.nodeName === "DIV" && node.getAttribute("ONCLICK"))
		{
			
			onclick = node.getAttribute("ONCLICK");
			url = onclick.substring(17,onclick.length-1);
			onclick = "parent.location='"+getCoverUrl (url)+"'";
			addNewAttribute(node,"onclick",onclick);		
		}
		
		while (i< node.childNodes.length)
		{
			changeLinksImgstore(node.childNodes[i]);
			i++;
		}
	}
}

function changeLinksTagstore()
{
	var i = 0,j,tagstoresublength,tagstorelength = tagstore.length;
	while (i < tagstorelength)
	{
		tagstore[i][0]=tagstore[i][0].replace(/\s/g,"_-_");
		j = 2;
		tagstoresublength = tagstore[i].length;
		while (j < tagstoresublength)
		{
			tagstore[i][j] = getCoverUrl (tagstore[i][j]);
			j+=2;
		}
		
		i++;
	}
	
}

// function setPrevNextCover()
// {
	// var nextnode = document.getElementById("next-art"),
	    // nextpicnode = document.getElementById("nextcover"),
		// prevnode = document.getElementById("previous-art"),
		// prevpicnode = document.getElementById("prevcover");
		
	// nextpicnode.style.backgroundImage ="url("+getImageUrl (getUrl (nextnode))+")";
	// prevpicnode.style.backgroundImage ="url("+getImageUrl (getUrl (prevnode))+")";
	
// }

// function getUrl (node)
// {
	// if (node)
	// {
		// var i = 0,
		// href ="";
		
		// if (node.nodeName === "A")
		// {
			
			// return node.getAttribute("HREF");
		// }
		
		// while (i< node.childNodes.length)
		// {
			// getUrl(node.childNodes[i]);
			// i++;
		// }
	// }
	// return "";
// }

// function getImageUrl (url)
// {
	// var imgstorenode = document.getElementById("imgstore"),
		// imgstorecount= imgstorenode.childNodes.length,
		// i = 0,
		// tempnode;
	
	// while (i < imgstorecount)
	// {
		// tempnode = imgstorenode.childNodes[i].firstChild;
		// if (tempnode.nodeName === "A")
		// {
			// if (tempnode.getAttribute("HREF") === url)
			// return imgstorenode.childNodes[i].lastChild.getAttribute("SRC");
		// }
		
		// i++;
	// }
	// return "";
// }

function setCoverLinks(contentnode)
{
	getCoverBaseURL ();
	changeLinksDOM (document.getElementById("contentnode"));
	//changeLinksDOM (document.getElementById("previous-art"));
	//changeLinksDOM (document.getElementById("previous-art2"));
	//changeLinksDOM (document.getElementById("next-art"));
	//changeLinksDOM (document.getElementById("next-art2"));
	changeLinksDOM (document.getElementById("contributors"));
	changeLinksDOM (document.getElementById("contributors_store"));
	changeLinksDOM (document.getElementById("imgstore"));
	changeLinksImgstore (document.getElementById("imgstore"));
	changeLinksTagstore();
}

function getArticleIndex(url)
{
	var ret = -1,
		i = 1,
		permlinkstorelength = permlinkstore.length;
		
	while (i < permlinkstorelength)
	{
		if (permlinkstore[i] === url)
		{
			ret = i;
			break;
		}
		i++;
	}
	
	return ret;
}

function getCoverUrl (oldurl)
{
	var ret = oldurl,
		index = 0;
	
	index = getArticleIndex(oldurl);
	
	if (index > 0)
	{
		ret = permlinkstore[0] + index;
	}
	
	return ret;
}

function initMagicButton(id)
{
	var curindex ,articlecount=permlinkstore.length-1,rand,cururl = document.location.href,cururllength = cururl.length;
	
	if (cursiteurl)
	{
		curindex = getArticleIndex(cursiteurl);
		
	}
	else
	{
		curindex = 0;
	}
	rand=curindex;
	if (cururl.charAt(cururllength-1) != "/")
	{
		cururl += "/";
		cururllength += 1;
	}
	cururl = cururl.slice(cururllength-5,cururllength-1);
	
	if (cururl === ".com")
	{
		addNewAttribute(document.getElementById(id),"onclick","parent.location='"+permlinkstore[0] + 2+"'");
	}
	else
	{
		while (rand===curindex)
		{
			rand = (Math.floor(Math.random()*articlecount)) + 1;
		}
		
		addNewAttribute(document.getElementById(id),"onclick","parent.location='"+permlinkstore[0] + rand+"'");
	}
	
	
}

function reDesign (contentdiv,contentcols,archdiv,tagcols,tagrows,imgcols,imgrows)
{
	var loadscrnode = document.getElementById("entryload"),
		headernode = document.getElementById("article-header"),
		contentnode,
		time1,
		time2,
		time3,
		time4,
		time5,
		time6;
	
	
	
	if (profiling)
	{
		time1 = new timer("Complete");
		time1.startTimer();
	}
	
	contentnode = document.getElementById(contentdiv);
	if (contentnode)
	{
		//contentnode.style.display="none";
		if (profiling)
		{
			time2 = new timer("stripImgSizeAttr");
			time2.startTimer();
		}
		//stripImgSizeAttr (contentnode);
		if (profiling)
		{
			time2.stopTimer();
			profilingstore.push(new Array(time2.name,time2.stopwatchtime));
		}
	}
	
	if (!disableCoverLinks)
	{
		if (profiling)
		{
			time3 = new timer("setCoverLinks");
			time3.startTimer();
		}
		if (debug) alert("redesign:setCoverlinks");
		setCoverLinks(contentnode);
		if (debug) alert("redesign:setCoverlinks finished");
		if (profiling)
		{
			time3.stopTimer();
			profilingstore.push(new Array(time3.name,time3.stopwatchtime));
		}
	}
	
	if (profiling)
	{
		time4 = new timer("buildArchive2");
		time4.startTimer();
	}
	if (debug) alert("redesign:buildArchive2");
	buildArchive2(tagcols,tagrows,archdiv);
	if (debug) alert("redesign:buildArchive2 finished");
	if (profiling)
	{
		time4.stopTimer();
		profilingstore.push(new Array(time4.name,time4.stopwatchtime));
	}
	
	if (profiling)
	{
		time5 = new timer("buildImgArchive");
		time5.startTimer();
	}
	if (debug) alert("redesign:buildImgArchive");
	buildImgArchive(imgcols,imgrows);
	if (debug) alert("redesign:buildImgArchive finished");
	if (profiling)
	{
		time5.stopTimer();
		profilingstore.push(new Array(time5.name,time5.stopwatchtime));
	}
		
	if (contentnode)
	{
		if (profiling)
		{
			time6 = new timer("reformat");
			time6.startTimer();
		}
		if (debug) alert("redesign:reformat");
		reformat(contentdiv,contentcols);
		if (debug) alert("redesign:reformat finished");
		if (profiling)
		{
			time6.stopTimer();
			profilingstore.push(new Array(time6.name,time6.stopwatchtime));
		}
	}
	
	if (profiling)
	{
		time1.stopTimer();
		profilingstore.push(new Array(time1.name,time1.stopwatchtime));
		dumpProfiling();
	}
	if (loadscrnode) loadscrnode.style.display="none";
	if (headernode) headernode.style.visibility="visible";
}

function timer (name)
{
	this.stopwatchtime = 0;
	this.timerun = false;
	this.name = name;
	this.startTimer = startTimer;
	this.stopTimer = stopTimer;
}

function startTimer()
{
	this.stopwatchtime = new Date().getTime();
	this.timerrun = true;
}

function stopTimer()
{
	this.stopwatchtime = new Date().getTime() - this.stopwatchtime;
	this.timerrun = false;
}

function dumpProfiling()
{
	var i = 0,
		profilingstorelength = profilingstore.length,
		out = "";
	
	while (i < profilingstorelength)
	{
		out += profilingstore[i][0] + ": " + profilingstore[i][1] + "ms";
		i++;
		if (i < profilingstorelength) out += "\n";
	}
	if (silentprofiling)
	{
		out = "\n"+"Javascript Profiling:\n"+out+"\n"
		//var bodynode = document.getElementById("body");
		document.body.appendChild(newtextnode("\n"));
		document.body.appendChild(document.createComment(out));
		document.body.appendChild(newtextnode("\n"));
	}
	else
	{
		alert (out);
	}
}

// End of columns2_click.js

