// Browser detect

var ie4 = (document.all && !document.getElementById) ? true:false;
var ns4 = (document.layers) ? true:false;
var dom2 = (document.getElementById) ? true:false;


// Image rollovers

var offstate = new Array();
var onstate = new Array();

function rollon(whichimage) {
	document.images[whichimage].src = onstate[whichimage].src;
}

function rolloff(whichimage) {
	document.images[whichimage].src = offstate[whichimage].src;
}


offstate['square'] = new Image();
offstate['square'].src = linkbase + 'images/common/spacer.gif';

onstate['square'] = new Image();
onstate['square'].src = linkbase + 'images/common/ltgraysquare.gif';

offstate['textsquare'] = new Image();
offstate['textsquare'].src = linkbase + 'images/common/spacer.gif';

onstate['textsquare'] = new Image();
onstate['textsquare'].src = linkbase + 'images/common/graysquare_text.gif';


function onsquare(whichsquare) {
	document.images['subnavsquare' + whichsquare].src = onstate['square'].src;
}

function offsquare(whichsquare) {
	document.images['subnavsquare' + whichsquare].src = offstate['square'].src;
}

function ontextsquare(whichsquare) {
	document.images['textsquare' + whichsquare].src = onstate['textsquare'].src;
}

function offtextsquare(whichsquare) {
	document.images['textsquare' + whichsquare].src = offstate['textsquare'].src;
}



// Special feature functions

offstate['featurebox'] = new Image();
offstate['featurebox'].src = linkbase + 'images/common/featurebox_off.gif';

onstate['featurebox'] = new Image();
onstate['featurebox'].src = linkbase + 'images/common/featurebox_on.gif';

var activefeature = 0;

function activatefeature(whichfeature) {
	deactivatefeature(activefeature);
	activefeature = whichfeature;
	
	eval('document.images.featurebox' + whichfeature + '.src = onstate["featurebox"].src');
	eval('showlayer("specialfeature' + whichfeature + '")');
}

function deactivatefeature(whichfeature) {
	eval('document.images.featurebox' + whichfeature + '.src = offstate["featurebox"].src');
	eval('hidelayer("specialfeature' + whichfeature + '")');
}


// Layer visibility functions

function showlayer(id) {
	if (document.all) document.all[id].style.visibility = 'visible';
	else if (ns4) document.layers[id].visibility = 'show';
	else if (dom2) document.getElementById(id).style.visibility = 'visible';
}

function hidelayer(id) {
	if (document.all) document.all[id].style.visibility = 'hidden';
	else if (ns4) document.layers[id].visibility = 'hide';
	else if (dom2) document.getElementById(id).style.visibility = 'hidden';
}


// Pop up functions

function popwin(loc,winname,w,h,scroll,resize) {
	eval('var newwin = window.open("' + loc + '","' + winname + '","width=' + w + ',height=' + h + ',top=0,left=0,location=no,scrollbars=' + scroll + ',menubar=no,toolbar=no,resizable=' + resize + '")');
}

function popwinmenu(loc,winname,w,h,scroll,resize) {
	eval('var newwin = window.open("' + loc + '","' + winname + '","width=' + w + ',height=' + h + ',top=0,left=0,location=no,scrollbars=' + scroll + ',menubar=yes,toolbar=no,resizable=' + resize + '")');
}

function openinmain(whichpage) {
	window.opener.location = whichpage;
}

function writestylesheet() {
	var agent = new String(navigator.userAgent);
	agent = agent.toLowerCase();
	if (ns4 && agent.indexOf("win") != -1) {
		document.write('<link rel="stylesheet" type="text/css" href="' + linkbase + 'styles_ns4.css">');
	} else {
		document.write('<link rel="stylesheet" type="text/css" href="' + linkbase + 'styles.css">');
	}
}

writestylesheet();