var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var mainScreenPos = 0;
var aLeft = 180;
var aMainPos = 1280;
var locId = "dummy";
var locIgnore = (isIE) ? true : false;
var locMusicId = 999;
var CBrun = false;
var DGrun = false;
var cb_window = false;
var dg_window = false;

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return [curleft];
}

function setLI()
{
document.getElementById("maintab").style.left = aMainPos;
document.getElementById("ulau").style.left = aLeft;
document.getElementById("uldn").style.left = aLeft;
document.getElementById("ulsg").style.left = aLeft;
document.getElementById("ulsp").style.left = aLeft;
}


function showMenu(id)
{
	document.getElementById(id).style.visibility = "visible";
	document.getElementById(id).style.display = "block";
	document.getElementById(id).style.zIndex = 9;
}

function hideMenu(id)
{
	document.getElementById(id).style.visibility = "hidden";
	document.getElementById(id).style.display = "none";
	document.getElementById(id).style.zIndex = -2;
}


function showConcert(id, musicId)
{
	if (locId != "dummy" && locIgnore != "NO")  // previous window still open
	{
		shideConcert(locId)
		if (isIE)  // all this because of stupid IE
		{
			locIgnore = true;
		}
	}
	locId = id;
	if (id != "dummy")
	{
		document.getElementById(id).style.display = "inline";
		document.getElementById("concerts").style.zIndex = 2;

		if (musicId != 999)
		{
			playMusic(musicId);
			locMusicId = musicId;
		}
	}

}

function shideConcert(id)
{
	if (!locIgnore)
	{
		closeCB();
		closeDG();
		document.getElementById(id).style.display = "none";
		document.getElementById("concerts").style.zIndex = -2;
		stopMusic(locMusicId);
	}
}

function playCB()
{
	if (locId != "dummy" && locIgnore != "NO")  // previous window still open
	{
		shideConcert(locId)
		if (isIE)  // all this because of stupid IE
		{
			locIgnore = true;
		}
	}
	cb_window = window.open("http://dbss.org/cb_ad.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=654, height=580");
	if (isIE)
	{
		CBrun = true;
	}
}
function closeCB()
{
	if(false == cb_window.closed && CBrun == false)  // Canadian brass window selected to run
	{
  	     cb_window.close ();
	}
	CBrun = false; // this is to stop IE from closing the CB window when it runs the onClick event a second time (as it does when you click on an image area
}

function playDG()
{
	if (locId != "dummy" && locIgnore != "NO")  // previous window still open
	{
		shideConcert(locId)
		if (isIE)  // all this because of stupid IE
		{
			locIgnore = true;
		}
	}
	dg_window = window.open("http://dbss.org/dg_ad.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=450, height=950");
	if (isIE)
	{
		DGrun = true;
	}
}
function closeDG()
{
	if(false == dg_window.closed && DGrun == false)  // Don Giovanni window selected to run
	{
  	     dg_window.close ();
	}
	DGrun = false; // this is to stop IE from closing the DG window when it runs the onClick event a second time (as it does when you click on an image area
}

function playSB()
{
	if (locId != "dummy" && locIgnore != "NO")  // previous window still open
	{
		shideConcert(locId)
		if (isIE)  // all this because of stupid IE
		{
			locIgnore = true;
		}
	}
	sb_window = window.open("http://dbss.org/sb_ad.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=654, height=580");
	if (isIE)
	{
		SBrun = true;
	}
}
function closeSB()
{
	if(false == sb_window.closed && CBrun == false)  // Sleeping Beauty window selected to run
	{
  	     sb_window.close ();
	}
	SBrun = false; // this is to stop IE from closing the CB window when it runs the onClick event a second time (as it does when you click on an image area
}

// setStyleByTag: given an element type, style property and
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.styleSheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

