goodVersion = true;
// Begin Browser and DHTML detect	
var BrowserVersion = parseFloat(navigator.appVersion.substring(0, 4));

var BrowserType = "Unknown";
var isMSIE = false;
var isNS = false;
if (navigator.appVersion.indexOf("MSIE") != -1) {
	BrowserType = "MSIE";
	isMSIE = true;
} else if (navigator.appVersion.indexOf("Firefox") != -1) {
	BrowserType = "MSIE";
	DHTMLversion = "MSIE";
	isFirefox = true;
} else if (navigator.userAgent.indexOf("Mozilla", 0) > -1) {
	BrowserType = "NS";
	isNS = true;
}

var OSType = "Unknown";
var isWin = false;
var isMac = false;
if (navigator.userAgent.indexOf("Win", 0) > -1) {
	OSType = "Win";
	isWin = true;
} else if (navigator.userAgent.indexOf("Macintosh", 0) > -1) {
	OSType = "Mac";
	isMac = true;
}
	
var DHTMLversion = "Disabled";
if (BrowserVersion >= 4) {
	if (BrowserType == "MSIE") {
		if (OSType == "Mac") {
			// Disable buggy Mac MSIE DHTML
			DHTMLversion = "Disabled";
		} else {
			DHTMLversion = "MSIE";
		}
	} else if (BrowserType == "NS") {
		if (BrowserVersion >= 6) {
			// Disable buggy NS6 DHTML
			DHTMLversion = "Disabled";
		} else {
			DHTMLversion = "NS";
		}
	}
}
// End Browser and DHTML detect	


function showHide(ID, isReturn) {
	/* Just passing the ID will determine the current state and change it to the opposite visibility state */
	
	if(!isReturn) {
		var isReturn = 0;
	}
	//alert(isReturn);
	DHTMLversion = "MSIE";
	if (DHTMLversion != "Disabled") {
		// hack so that is doc.layers not defined, then use MSIE
		
	
		if (DHTMLversion == "MSIE" || DHTMLversion == "NS6") {
			
			//var currentState = document.all[ID].style.visibility;
			var currentState = document.getElementById(ID).style.visibility
		} else {
			var currentState = document.layers[ID].style.visibility;
		}
	}
	
	state = 1
	if (currentState == "visible") {
		state = 0;
	} else {
		state = 1;
		
	}
	
	// alert("The current state of: " + ID + " is: " + currentState);
	var newState = false;
	
	if (DHTMLversion != "Disabled") {
		
		
		if (DHTMLversion == "MSIE" || DHTMLversion == "NS6") {
			//var myObject = document.all[ID].style
			var myObject = document.getElementById(ID).style
		} else {
			var myObject = document.layers[ID]
		}
		if ((state == 1) || (state == true)) {
			
			myObject.visibility = "visible";
			myObject.position = "static";
			newState = true;
			//myObject.top = 100
			//myObject.left = 100
		} else {
			myObject.visibility = "hidden";
			myObject.position = "absolute";
			//myObject.top = 100
			//myObject.left = 100
		}
	}
	
	if (isReturn == 1) {
		return newState;
	}
	
}


function swapImage(imgTag, imgName)
{
	document.images[imgTag].src="/images/"+imgName;
}


	function swapImageArt(imgTag, imgName)
{
	document.images[imgTag].src="/images/"+imgName;
}

function popUpWindow(URL, width, height, wname) {
	//alert(wname);
	
	//if (!wname) {
		wname = "PopUpWindow";
	//}
	popwin = window.open(URL, wname, "'toolbar=no,location=no,directories=no,status=no,left=500,menubar=no,scrollbars=no,resizable=no,width=" + width +",height=" + height)
	popwin.opener = self
	popwin.focus()
}

function popUpWindowResize(URL, width, height, name) {
	if (!name) {
		name = "PopUpWindow";
	}
	popwin = window.open(URL, name, "'toolbar=no,location=no,directories=no,status=no,left=500,menubar=no,scrollbars=yes,resizable=yes,width=" + width +",height=" + height)
	popwin.opener = self;
	popwin.focus();
}

function returnSeparateDate(ddMMyyyy,frmName,fldYear,fldMonth,fldDay)
{
	var dd = ddMMyyyy.substring(0,2)
	var mm = ddMMyyyy.substring(2,4)
	var yy = ddMMyyyy.substring(4,8)
	var fldYY = eval("window.opener.document." + frmName + "."+ fldYear)
	var fldMM = eval("window.opener.document." + frmName + "."+ fldMonth)
	var fldDD = eval("window.opener.document." + frmName + "."+ fldDay)
	fldYY.value = parseInt(yy,10)
	fldMM.value = parseInt(mm,10)
	fldDD.value = parseInt(dd,10)
	window.close()
}	

function clearSearch(formField) {
	//  Only clear the field if it is equal to Site Search
	if (formField.value == "Site Search") {
		document.searchForm.searchString.value = "";
	}	
}

function showMore(rootClassID) {
	var briefClassName = rootClassID + "Less";
	var fullClassName = rootClassID + "More";
	var moreLink = rootClassID + "MoreLink";
	var lessLink = rootClassID + "LessLink";
	less = document.getElementById(briefClassName);
	more = document.getElementById(fullClassName);
	
	lessLink = document.getElementById(lessLink);
	moreLink = document.getElementById(moreLink);
	//alert("fullClassName: " + fullClassName + "\nbriefClassName: " + briefClassName + "\n\nobj: " + less);
	//alert(isBrief);
	//alert(less.style.visibility);
	if (less.style.visibility == 'visible') {
		// Hide the brief and show the full one
		less.style.visibility = "hidden";
		less.style.position = "absolute";
		more.style.visibility = "visible";
		more.style.position = "relative";
		// when showing the brief also hide the less button and show the more button
		moreLink.style.visibility = "hidden";
		moreLink.style.position = "absolute";
		lessLink.style.visibility = "visible";
		lessLink.style.position = "relative";
	} else {
		// Hide the brief and show the full one
		less.style.visibility = "visible";
		less.style.position = "relative";
		more.style.visibility = "hidden";
		more.style.position = "absolute";
		// when hiding the brief also hide the more button and show the less button
		moreLink.style.visibility = "visible";
		moreLink.style.position = "relative";
		lessLink.style.visibility = "hidden";
		lessLink.style.position = "absolute";
	}
}

function toggleSection(sectionID, trackCount) {
	sectionObj = document.getElementById("album" + sectionID);
	
	//alert("crap " + sectionObj.style.visibility);
	if (sectionObj.style.visibility == "visible") {
		// Hide the section		
		
		sectionObj.style.position = "absolute";
		sectionObj.style.visibility = "hidden";
		// call this function in 100ms
		setTimeout("hideSub(" + sectionID + "," + trackCount + ")", 50);
	} else {
		// Show the section 		
		sectionObj.style.position = "relative";
		sectionObj.style.visibility = "visible";
		// call this function in 100ms
		setTimeout("showSub(" + sectionID + "," + trackCount + ")", 50);
	}
	
	
	//sectionObj.style.visibility = "visible";
	//sectionObj.style.position = "relative";
	//alert(sectionID + " is set to " + sectionObj.style.visibility);
}

function showSub(sectionID, trackCount) {
	//alert("sectionId: " + sectionID + "; trackCount: " + trackCount);
	t = trackCount + 1;
	
	//Get the sub objects and show them
	for (x=1; x<t; x++) {
		
		sectionObj = document.getElementById("sub1" + sectionID + x);
		
		//alert("now showing: " + "sub1" + sectionID + x)
		sectionObj.style.visibility = "visible";
	}
	
	
	
	//alert("sub11" + sectionID);
	sectionObj.style.visibility = "visible";
	sectionObj.style.position = "relative";
}

function hideSub(sectionID, trackCount) {

	t = trackCount + 1;
	//Get the sub objects
	for (x=1; x<t; x++) {
		
		sectionObj = document.getElementById("sub1" + sectionID + x);
		
		//alert("now showing: " + "sub1" + sectionID + x)
		sectionObj.style.visibility = "hidden";
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		button_play_sm_list_OFF = new Image();
		button_play_sm_list_OFF.src = "/images/button_play_sm_list_OFF.gif";
		
		button_play_sm_list_ON = new Image();
		button_play_sm_list_ON.src = "/images/button_play_sm_list_ON.gif";
		
		preloadFlag = true;
	}
			//button_about_on = newImage("images/button_about_on.gif");
}
preloadImages();

function changeImages() {
	
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function formatNumber(numberString, formatType) {
	//  Possible format types:
	//  dollar ($4.21)
	//  float2 (1235.00)
	//  float1 (12354.9)
	//  number (12,132,154)
	numberString = new String(numberString);
	
	
	
	//alert("formatNumber: " + numberString + "; indexOf:  " +  numberString.indexOf(".", 0));
	var formattedNumber = parseFloat(numberString);
	
	
	if (formattedNumber != "NaN") {
		
		// round it off to two decimal places
		var tempNumber = formattedNumber * 100;
		tempNumber = Math.round(tempNumber);
		tempNumber = tempNumber / 100;
		
		//  Now set it back
		formattedNumber = tempNumber;
		//alert("tempNumber: " + tempNumber);
		numberString = new String(tempNumber);
	}
	
	
	var decimalPos = numberString.indexOf(".", 0);
	var stringLen = numberString.length;
	var decimalPlaces = stringLen - decimalPos - 1;  // add 1 since position starts at 0
	//alert("decimal found at: " + decimalPos + "; there are " + decimalPlaces + " decimal places");
	
	if (formatType == "float2") {
		
		if (!formattedNumber || formattedNumber == "NaN" || formattedNumber == 0) {
			// returns NaN so set to 0.00
			formattedNumber = "0.00";
		} else {
			
			
			
			
			//  See it if has a decimal.
			if (decimalPos >= 0) {
				// find out how many characters are after the decimal
				if (decimalPlaces == 0) {
					formattedNumber = numberString + "00";
				}
				if (decimalPlaces == 1) {
					formattedNumber = numberString + "0";
				}
				if (decimalPlaces == 2) {
					formattedNumber = numberString;
				}
				
			} else {
				formattedNumber = numberString + ".00";
			}
		}

	}
	
	return formattedNumber;
	//document.testForm.dspVal.value = formattedNumber;
}




