function changeTabs(div_id)
{
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('link'+i)) {
			document.getElementById('link'+i).style.color = "#000000";
			document.getElementById('link'+i).style.backgroundColor = "#B592C6";
		}
	}

	for (var i = 1; i<=5; i++) {
		if (document.getElementById('enh'+i)) {
			document.getElementById('enh'+i).style.color = "#FFFFFF";
			document.getElementById('enh'+i).style.backgroundColor = "#B592C6";
		}
	}

	document.getElementById(div_id).style.backgroundColor = "#7A79A7";
	document.getElementById(div_id).style.color = "#FFFFFF";
	
	document.getElementById(div_id).style.borderColor="#595791";
	document.getElementById(div_id).style.borderTopStyle="solid";
} 

	function changePage(div_id)
    {
    
    	for (var i = 1; i<=10; i++) {
    		if (document.getElementById('link'+i)) {
    			document.getElementById('link'+i).style.color = "#FFFFFF";
    			document.getElementById('link'+i).style.backgroundColor = "#B592C6";
    		}
    	}
    	
    	document.getElementById(div_id).style.backgroundColor = "#7A79A7";
    	document.getElementById(div_id).style.color = "#FFFFFF";
    	
    	document.getElementById(div_id).style.borderColor="#595791";
    	document.getElementById(div_id).style.borderTopStyle="solid"; 		
    } 

    function changePage2(strPage, div_id)
    {
    
    parent.mainarea.location.href = strPage; 
    for (var i = 1; i<=10; i++) {
    		if (document.getElementById('link'+i)) {
    		document.getElementById('link'+i).style.color = "#FFFFFF";
    		document.getElementById('link'+i).style.backgroundColor = "#F5F5F5";
    		}
    	}
    	for (var i = 1; i<=5; i++) {
    		if (document.getElementById('enh'+i)) {
    		document.getElementById('enh'+i).style.color = "#FFFFFF";
    		document.getElementById('enh'+i).style.backgroundColor = "#F5F5F5";
    		}
    	}
    	document.getElementById(div_id).style.backgroundColor = "#7A79A7";
    	document.getElementById(div_id).style.color = "#FFFFFF";
    	
    	document.getElementById(div_id).style.borderColor="#595791";
    	document.getElementById(div_id).style.borderTopStyle="solid";
    	
    } 


//Script for popup window
popupWins = new Array();
	
function popUP(url, winID) {
	var args='width=600,height=400,menubar=no,resizable=yes,scrollbars=yes';
	/*******************************
	the popupWins array stores an object reference for
	each separate window that is called, based upon
	the name attribute that is supplied as an argument
	*******************************/
	
	if ( typeof( popupWins[winID] ) != "object" ){
		popupWins[winID] = window.open(url,winID,args);
	} else {
		if (!popupWins[winID].closed){
			popupWins[winID].location.href = url;
		} else {
			popupWins[winID] = window.open(url, winID,args);
		}
	}

	popupWins[winID].focus();
}

//  platformMoz:  http://www.mozilla.org/projects/xslt/js-interface.html
//  platformIE:  http://www.perfectxml.com/articles/xml/XSLTInMSXML.asp
//  platformSafari: http://developer.apple.com/internet/safari/faq.html#anchor21 
//                  http://developer.apple.com/internet/webcontent/xmlhttpreq.html

// Note that Opera can render a page if IE can render it; that is, platformIE works for both IE and Opera.
var platformChrome = (navigator.userAgent.indexOf("Safari")!=-1 && navigator.userAgent.indexOf("Chrome")!=-1);
var platformSafari = (!platformChrome && navigator.userAgent.indexOf("Safari")!=-1 && !platformChrome);
var platformMoz = (!platformChrome && !platformSafari && document.implementation && document.implementation.createDocument);
var platformIE = (!platformChrome && !platformMoz && document.getElementById && window.ActiveXObject);
var noXSLT      = (!platformMoz && !platformIE && !platformSafari && !platformChrome);


var msxmlVersion = '3.0';

var urlXML;
var urlXSL;
var docXML;
var docXSL;
var target;
var cache;
var processor;
var i;

var paramNames = new Array('colFilter','compName','showTarget','version','old_version','audience');
var paramValues = new Array('','','','','','');
var nParams = paramNames.length;

if (platformIE)
{
	cache = new ActiveXObject('Msxml2.XSLTemplate.' + msxmlVersion);
}

function Initialize()
{
	// Test
	if (noXSLT)
	{
		return;
	}
	Defaults();
}

function Defaults()
{
	SetTarget('target_content');
}

function SetTarget(id)
{
	target = document.getElementById(id);
}

function SetInput(url)
{
	urlXML = url;
}

function SetStylesheet(url)
{
	urlXSL = url;
}

function SetParam(name, value)
{
	var found = false;

	for (i = 0; i< nParams; i++)
	{
		if (paramNames[i] == name)
		{
			paramValues[i] = value;
			found = true;
		}
	}

	if (!found)
	{
		NoSuchParam(name);
	}
}

function FatalError()
{
	if(urlXML=="") {
		document.write("Sorry, this doesn't work in your browser. This page needs to be viewed in a browser that supports XSLT processing via JavaScript.");
	}
	else {
		window.location = urlXML;
	}
}

function NoSuchParam(name)
{
	document.write("There is no " + name + " parameter");
}

function CreateDocument()
{
	var doc = null;
	
	if (platformMoz || platformSafari)
	{
		doc = document.implementation.createDocument('', '', null);
	}
	else if (platformIE)
	{
		doc = new ActiveXObject('Msxml2.FreeThreadedDOMDocument.' + msxmlVersion);
	}
	return doc;
}

function Transform() 
{
	if (noXSLT)
	{
		FatalError();
		return;
	}

	docXML = CreateDocument();
	docXSL = CreateDocument();
	
	if (platformMoz)
	{
		docXML.addEventListener('load', DoLoadXSL, false);
		docXML.load(urlXML);
	}
	else if (platformIE)
	{
		docXML.async = false;
		docXML.load(urlXML);
		
		docXSL.async = false;
		docXSL.load(urlXSL);
		
		DoTransform();
	}
	else if (platformChrome)
	{
		alert("Sorry but this page is not currently viewable in Chrome.");
	}
	else if (platformSafari)
	{
		alert("Sorry but this page is not currently viewable in Safari.");
	}
}

function DoLoadXSL()
{
	if (platformMoz)
	{
		docXSL.addEventListener('load', DoTransform, false);
		docXSL.load(urlXSL);
	}
}

function DoTransform() 
{
	if (platformMoz)
	{
		processor = new XSLTProcessor();
		processor.importStylesheet(docXSL);
		
		AddParams(processor);
		
		var fragment = processor.transformToFragment(docXML, document);
		
		while (target.hasChildNodes())
			target.removeChild(target.childNodes[0]);
		
		target.appendChild(fragment);
	}
	else if (platformIE)
	{
		cache.stylesheet = docXSL;
		
		processor = cache.createProcessor();
		processor.input = docXML;
		
		AddParams(processor);
		
		processor.transform();
		
		target.innerHTML = processor.output;
	}
}

function AddParams(processor) 
{
	for (i = 0; i< nParams; i++)
		if (paramValues[i] != '')
		AddParam(processor, paramNames[i], paramValues[i]);
}

function AddParam(processor, name, value) 
{
	if (platformMoz)
		processor.setParameter(null, name, value);
	else if (platformIE)
		processor.addParameter(name, value);
}
