//global object
var pres = new Object;
//config views, must be in this array in order of tab appearance
//that's necessary so zindex can be calculated
pres.views = ['first','second', 'third', 'fourth', 'fifth', 'sixth'];
pres.viewsLen = pres.views.length;
//default config view 
//*** THIS DOESN'T HIGHLIGHT THE TAB, ONLY HIDE THE OTHER <PRE>s
pres.thisView = 'first';
//if the script is supported 
if(um.d)
{
	//rules array
	pres.rules = [];
	var j = 0;
	//apply absolute positioning to tabs
	pres.rules[j++] = 'a.codeTab{position:absolute;left:0;top:-24px;cursor:pointer;}';
	//"this" tab styling
	//um.baseSRC is called from udmcustom.
	pres.rules[j++] = 'a.thisTab,a.thisTab:hover,a.thisTab:focus,a.thisTab:active{z-index:10 !important;border-width:0 0 1px 0;border-bottom:1px solid #fff;background:url('+ um.baseSRC +'code-tab.gif) #fff no-repeat;}';
	pres.rules[j++] = 'a.thisTab span{z-index:10 !important;border-width:0 0 1px 0;border-bottom:1px solid #fff;background:url('+ um.baseSRC +'code-tab.gif) transparent no-repeat -100px 0;}';

	//for each view
	for(var i=0; i<pres.viewsLen; i++)
	{
		//hide all except default <div>
		if(pres.views[i] != pres.thisView)
		{
			pres.rules[j++] = 'div.' + pres.views[i] + 'Config{display:none;}';
			pres.rules[j++] = 'div.' + pres.views[i] + 'Config div.tabContainer{display:block;}';
		}
		//apply increasing left position to form a row 
		//progressively descending z-index so each tab goes beneath the previous one
		pres.rules[j++] = 'a.' + pres.views[i] + 'Tab {z-index:' + (9 - i) + ';left:' + ((i * 160)) + 'px;}';
		if(pres.views[i] == 'third') {
			pres.rules[j++] = 'a.thirdTab{left:319px;}';
		} else if(pres.views[i] == 'fourth') {
			pres.rules[j++] = 'a.fourthTab{left:479px;}';
		} else if(pres.views[i] == 'fifth') {
			pres.rules[j++] = 'a.fifthTab{left:639px;}';
		}
		
	}	
	//create style node
	pres.attrs = {'type':'text/css','media':'screen,projection'};
	pres.styleNode = um.createElement('html:style',pres.attrs);
	//append to head
	document.getElementsByTagName('head')[0].appendChild(pres.styleNode);
	//apply rules with DOM 2 CSS
	if(um.ss)
	{
		//if the stylesheets collection length=0
		//then creating or appending the stylesheet didn't work
		//this happens in netscape 6.1, and probably other early moz builds, 
		//if there are no other stylesheets already on the page (** why??)
		//so if it does, set um.ss to false so that it uses document.write instead
		//of course that means if this happens in the XML DOM
		//none of the CSS will be written in that browser at all
		if(document.styleSheets.length==0)
		{
			um.ss=false;
		}
		//otherwise
		else
		{
			//retrieve the stylesheet object we just created
			pres.stylesheet = document.styleSheets.item(document.styleSheets.length-1);
			//for each rule
			for(i=0; i<pres.rules.length; i++)
			{
			//insert rule
				pres.stylesheet.insertRule(pres.rules[i],pres.stylesheet.cssRules.length);
			}
		}
	}
	//document.write doesn't work in XHTML, and O7 doesn't support document.styleSheets
	//so apply rules for Opera 7.3 by creating text nodes inside a <style> element
	//we can't use this method exclusively because it doesn't work in older moz builds
	else if(um.o73)
	{
		//for each rule
		for(i=0; i<pres.rules.length; i++)
		{
			//insert rule as text node
			pres.styleNode.appendChild(document.createTextNode(pres.rules[i]));
		}
	}
	//apply rules with document.write
	if(!um.ss)
	{
		//compile rule string
		pres.styStr='';
		for(i=0; i<pres.rules.length; i++)
		{
			//add rule to string
			pres.styStr+=pres.rules[i];
		}
		//write rules
		document.write('<style type="text/css" media="screen,projection">'+pres.styStr+'</style>');
	}

}

//config tab handler

function configTab(tabObj,preRef)
{
	//get collection of pre elements within this container
	pres.eles = tabObj.parentNode.getElementsByTagName('div');
	pres.elesLen = pres.eles.length;
	//for each one
	for(i=0; i<pres.elesLen; i++)
	{
		//if it has the right config classname
		if(pres.eles[i].className && pres.eles[i].className.indexOf(preRef + 'Config')!=-1)
		{
			//display it
			pres.eles[i].style.display = 'block';
		}
		//otherwise
		else
		{
			//hide it
			pres.eles[i].style.display = 'none';
		}
		if (pres.eles[i].className == 'tabContainer') {
			pres.eles[i].style.display = 'block';
		}
	}
	//get spans within container
	pres.spans = tabObj.parentNode.getElementsByTagName('a');
	pres.spansLen = pres.spans.length;

	//for each one
	for(i=0; i<pres.spansLen; i++)
	{
		//if it has the right config classname
		if(pres.spans[i].className && pres.spans[i].className.indexOf(preRef + 'Tab')!=-1)
		{
			//give it the rollover classname
			pres.spans[i].className += ' thisTab';
		}
		//otherwise
		else
		{
			//remove the rollover classname
			pres.spans[i].className = pres.spans[i].className.replace(/ thisTab/g,'');
		}
	}
};