var arrCanvasBG;

function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
	} else { 
		window.onload = function() { 
			oldonload(); 
			func(); 
		}
	} 
}

initGlobalNav = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("navigationRoot");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
				if (node.childNodes.length > 0) {
					for (j=0; j<node.childNodes.length; j++) {
						thisChildNode = node.childNodes[j];
						if (thisChildNode.nodeName=="UL") {
							for (k=0; k<thisChildNode.childNodes.length; k++) {
								thisSubChildNode = thisChildNode.childNodes[k];
								if (thisSubChildNode.nodeName=="LI" && thisSubChildNode.childNodes.length > 0) {
												thisSubChildNode.onmouseover=function() {
													this.className+=" over";
													if (document.getElementById("pageSize1") != undefined) {
														document.getElementById("pageSize1").style.visibility = "hidden";
													}
												}
												thisSubChildNode.onmouseout=function() {
													this.className=this.className.replace(" over", "");
													if (document.getElementById("pageSize1") != undefined) {
														document.getElementById("pageSize1").style.visibility = "visible";
													}
												}
								}
							}
						}
					}
				}
			}
		}
	}
}

loadCanvasBG = function() {
	if (arrCanvasBG != undefined) {
		if (arrCanvasBG.length > 0) {
			document.getElementById("canvas").style.backgroundImage = "url(" +  arrCanvasBG[Math.floor(Math.random()*arrCanvasBG.length)] + ")";
		}
	}
}

addLoadEvent(initGlobalNav); 
addLoadEvent(loadCanvasBG);

function toggleCymbalFinder() {
	if (document.getElementById("cymbalFinderContents").style.display == "block") {
		document.getElementById("cymbalFinderContents").style.display = "none";
		document.getElementById("btn_expCymbalFinderImage").src = "../images/btn_expresscymbalfinder_off.gif";
	} else {
		document.getElementById("cymbalFinderContents").style.display = "block";
		document.getElementById("btn_expCymbalFinderImage").src = "../images/btn_expresscymbalfinder_on.gif";
	}
}

function setSearchTab(whichTab,tabContainerID,tabContentID,tabNavImage) {
	if (whichTab == 1) {
		document.getElementById(tabContainerID).style.backgroundImage = "url(../images/" + tabNavImage + "_1.gif)";
		document.getElementById(tabContentID+"_2").style.display = "none";
		document.getElementById(tabContentID+"_1").style.display = "block";
	} else {
		document.getElementById(tabContainerID).style.backgroundImage = "url(../images/" + tabNavImage + "_2.gif)";
		document.getElementById(tabContentID+"_1").style.display = "none";
		document.getElementById(tabContentID+"_2").style.display = "block";
	}
}


var intCurrentPhoto = 0;
var intCurrentVideo = 0;

function displayPhotoInPhotoViewer(whichPhoto,whichPhotoContainer) {
	setTimeout("document.getElementById('" + whichPhotoContainer + "').src = arrPhotos[" + whichPhoto + "][0]",1);
	document.getElementById(whichPhotoContainer).alt = arrPhotos[whichPhoto][1];
	if (document.getElementById("btn_enlargePhoto") != undefined) {
		if (arrPhotos[intCurrentPhoto][2] != "") {
			document.getElementById("btn_enlargePhoto").style.display = "block";
		} else {
			document.getElementById("btn_enlargePhoto").style.display = "none";
		}
	}
}

function setCurrentPhoto(whichPhoto,whichPhotoContainer) {
	//reset the current 'li' item
	if (document.getElementById("av_" + intCurrentPhoto)) {
		document.getElementById("av_" + intCurrentPhoto).className = "";
	}
	//set the img to the new photo
	intCurrentPhoto = whichPhoto;
	displayPhotoInPhotoViewer(whichPhoto,whichPhotoContainer);
	//set the current 'li' class to 'active'
	if (document.getElementById("av_" + intCurrentPhoto)) {
		document.getElementById("av_" + intCurrentPhoto).className = "active";
	}
	if (document.getElementById("photoCounter")) {
		document.getElementById("photoCounter").innerHTML = intCurrentPhoto + 1 + " of " + arrPhotos.length;
	}
	if (document.getElementById("photoCaption")) {
		document.getElementById("photoCaption").innerHTML = arrPhotos[whichPhoto][1];
	}
}

function showPreviousPhoto(whichPhotoContainer) {
	if (intCurrentPhoto == 0) {
		intCurrentPhoto = arrPhotos.length - 1;
	} else {
		intCurrentPhoto--;
	}
	setCurrentPhoto(intCurrentPhoto,whichPhotoContainer)
}

function showNextPhoto(whichPhotoContainer) {
	if (intCurrentPhoto == arrPhotos.length - 1) {
		intCurrentPhoto = 0;
	} else {
		intCurrentPhoto++;
	}
	setCurrentPhoto(intCurrentPhoto,whichPhotoContainer)
}

function enlargeImage() {
	if (arrPhotos[intCurrentPhoto][2] != "") {
		//window.open(arrPhotos[intCurrentPhoto][2]);
		
		var left = ((screen.width - 450)/2);
		var top = ((screen.height - 529)/2);
		var fs = window.open('imagepopup.cfm?img='+ arrPhotos[intCurrentPhoto][2],'myname', 'width=700,height=500,directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,top=' + top + ',left=' + left + '');
		fs.focus();
	}
}

function displayVideoInVideoViewer(whichVideo,whichVideoContainer) {
            strYTSource = arrVideos[whichVideo][0];
            strYTVideoID = strYTSource.substring(31);
            document.getElementById(whichVideoContainer).innerHTML = "<p><object width='270' height='215'><param name='movie' value='http://www.youtube.com/v/" + strYTVideoID + "&rel=0'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/" + strYTVideoID + "&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='270' height='215'></embed></object></p>";
            if (document.getElementById("btnVideoHiRes") != undefined) {
                        if (arrVideos[intCurrentVideo][1] != "") {
                                    document.getElementById("btnVideoHiRes").style.display = "block";
                        } else {
                                    document.getElementById("btnVideoHiRes").style.display = "none";
                        }
            }
}

function setCurrentVideo(whichVideo,whichVideoContainer) {
	//reset the current 'li' item
	if (document.getElementById("v_" + intCurrentVideo)) {
		document.getElementById("v_" + intCurrentVideo).className = "";
	}
	//set the video 'div' content to the new video
	intCurrentVideo = whichVideo;
	displayVideoInVideoViewer(whichVideo,whichVideoContainer);
	//set the current 'li' class to 'active'
	if (document.getElementById("v_" + intCurrentVideo)) {
		document.getElementById("v_" + intCurrentVideo).className = "active";
	}
	if (document.getElementById("videoTitle")) {
		document.getElementById("videoTitle").innerHTML = arrVideos[intCurrentVideo][2];
	}
}

function enlargeVideo() {
	if (arrVideos[intCurrentVideo][1] != "") {
		window.open(arrVideos[intCurrentVideo][1]);
	}
}

function toggleFAQAnswer(whichID) {
	var strSection = whichID.substr(0,whichID.indexOf("_"));
	var strQuestion = whichID.substr(whichID.lastIndexOf("_")+1);
	if (document.getElementById(strSection + "_a_" + strQuestion).style.display == "none") {
		document.getElementById(strSection + "_a_" + strQuestion).style.display = "block";
	} else {
		document.getElementById(strSection + "_a_" + strQuestion).style.display = "none";
	}
}

function setSetupWidgetTab(whichTab) {
            imgOne = new Image();
            imgTwo = new Image();
            imgThree = new Image();
            imgOne.src = "../images/bg_setupwidget_tabnav_1.gif";
            imgTwo.src = "../images/bg_setupwidget_tabnav_2.gif";
            imgThree.src = "../images/bg_setupwidget_tabnav_3.gif";
            document.getElementById("setupWidgetContent_drums").style.display = "none";
            document.getElementById("setupWidgetContent_cymbals").style.display = "none";
            document.getElementById("setupWidgetContent_notes").style.display = "none";
            switch(whichTab) {
                        case 1:
                                    document.getElementById("setupWidgetNavigation").className = "firstTab";
                                    document.getElementById("setupWidgetContent_drums").style.display = "block";
                                    objT = setTimeout("document.getElementById('setupWidgetNavigation').backgroundImage=imgOne.src",100);
                                    break;
                        case 2:
                                    document.getElementById("setupWidgetNavigation").className = "secondTab";
                                    document.getElementById("setupWidgetContent_cymbals").style.display = "block";
                                    objT = setTimeout("document.getElementById('setupWidgetNavigation').backgroundImage=imgTwo.src",100);
                                    break;
                        case 3:
                                    document.getElementById("setupWidgetNavigation").className = "thirdTab";
                                    document.getElementById("setupWidgetContent_notes").style.display = "block";
                                    objT = setTimeout("document.getElementById('setupWidgetNavigation').backgroundImage=imgThree.src",100);
                                    break;
            }
}

function validateForm(whichForm) {
	var boolIsValid = true;
	var strErrorMessage = "";
	if (whichForm.name == "registration") {
		
		
		if (whichForm.tb_member_firstname.value == "") {
			strErrorMessage += "Please enter your first name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_member_lastname.value == "") {
			strErrorMessage += "Please enter your last name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_member_username.value == "") {
			strErrorMessage += "Please enter your username.<br />";
			boolIsValid = false;
		}
		if (!validateUsername(whichForm.tb_member_username.value)) {
			strErrorMessage += "Please make sure that your username contains only alphabetical and numerical characters.<br />";
			boolIsValid = false;
		}
		if (whichForm.dd_member_secretquestion.selectedIndex == 0) {
			strErrorMessage += "Please select a secret question.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_member_secretquestionanswer.value == "") {
			strErrorMessage += "Please enter an answer to your secret question.<br />";
			boolIsValid = false;
		}
		if (!validateEmail(whichForm.tb_member_email.value) || !validateEmail(whichForm.tb_member_emailverification.value)) {
			strErrorMessage += "Please enter a valid email address.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_member_email.value != whichForm.tb_member_emailverification.value) {
			strErrorMessage += "Please make sure that your email addresses match.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_member_password) {
			if (whichForm.tb_member_password.value == "") {
				strErrorMessage += "Please enter your password.<br />";
				boolIsValid = false;
			}
			if (whichForm.tb_member_password.value != whichForm.tb_member_passwordver.value) {
				strErrorMessage += "Please make sure that your passwords match.<br />";
				boolIsValid = false;
			}
		}
		if (whichForm.member_termsprivacyagree) {
			if (!whichForm.member_termsprivacyagree.checked) {
				strErrorMessage += "Please read and agree to the Terms of Use and Privacy Policy.<br />";
				boolIsValid = false;
			}
		}
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
	} else if (whichForm.name == "guitarhero") {
		if (whichForm.tb_guitarhero_firstname.value == "") {
			strErrorMessage += "Please enter your first name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_guitarhero_lastname.value == "") {
			strErrorMessage += "Please enter your last name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_guitarhero_city.value == "") {
			strErrorMessage += "Please enter the name of your city.<br />";
			boolIsValid = false;
		}
		if (whichForm.dd_guitarhero_provstat.selectedIndex == 0) {
			strErrorMessage += "Please select your province or state.<br />";
			boolIsValid = false;
		}
		if (!validateEmail(whichForm.tb_guitarhero_email.value) || !validateEmail(whichForm.tb_guitarhero_emailverification.value)) {
			strErrorMessage += "Please enter a valid email address.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_guitarhero_email.value != whichForm.tb_guitarhero_emailverification.value) {
			strErrorMessage += "Please make sure that your email addresses match.<br />";
			boolIsValid = false;
		}
		if (whichForm.guitarhero_termsprivacyagree) {
			if (!whichForm.guitarhero_termsprivacyagree.checked) {
				strErrorMessage += "Please read and agree to the Terms of Use and Privacy Policy.<br />";
				boolIsValid = false;
			}
		}
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
	} 
	else if (whichForm.name == "send_msg") {
		if (whichForm.recipient.value == "") {
			strErrorMessage += "Please enter recipient's name.<br />";
			boolIsValid = false;
		}
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
		else
		alert('Your message has been sent');
	}
	
	
	else if (whichForm.name == "enewsletter") {
		if (!validateEmail(whichForm.tb_enewsletter_email.value) || !validateEmail(whichForm.tb_enewsletter_emailverification.value)) {
			strErrorMessage += "Please enter a valid email address.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_enewsletter_email.value != whichForm.tb_enewsletter_emailverification.value) {
			strErrorMessage += "Please make sure that your email addresses match.<br />";
			boolIsValid = false;
		}
		/*if (whichForm.enewsletter_termsprivacyagree) {
			if (!whichForm.enewsletter_termsprivacyagree.checked) {
				strErrorMessage += "Please read and agree to the Terms of Use and Privacy Policy.<br />";
				boolIsValid = false;
			}
		}*/
		if(!whichForm.enewsletter_emailupdates.checked && !whichForm.enewsletter_emailnotesoptin.checked && !whichForm.enewsletter_emailbonewsletteroptin.checked) {
			strErrorMessage += "Please select at least one newsletter to receive.<br />";
			boolIsValid = false;
		}
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
	} else if (whichForm.name == "oneofonehundred") {
		if (!validateEmail(whichForm.tb_oneofonehundred_email.value)) {
			strErrorMessage += "Please enter a valid email address.<br />";
			boolIsValid = false;
		}
		/*if (whichForm.enewsletter_termsprivacyagree) {
			if (!whichForm.enewsletter_termsprivacyagree.checked) {
				strErrorMessage += "Please read and agree to the Terms of Use and Privacy Policy.<br />";
				boolIsValid = false;
			}
		}*/
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
	} else if (whichForm.name == "oneofonehundredreserve") {
		if (whichForm.tb_oneonehundred_firstname.value == "") {
			strErrorMessage += "Please enter your first name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_lastname.value == "") {
			strErrorMessage += "Please enter your last name.<br />";
			boolIsValid = false;
		}
		if (!validateEmail(whichForm.tb_oneonehundred_email.value) || !validateEmail(whichForm.tb_oneonehundred_emailconfirm.value)) {
			strErrorMessage += "Please enter a valid email address.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_email.value != whichForm.tb_oneonehundred_emailconfirm.value) {
			strErrorMessage += "Please make sure that your email addresses match.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_phone.value == "") {
			strErrorMessage += "Please enter your phone number.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_mailingstreet.value == "") {
			strErrorMessage += "Please enter your mailing street address.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_mailingcity.value == "") {
			strErrorMessage += "Please enter the name of your city.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_mailingprovst.value == "") {
			strErrorMessage += "Please enter the name of your province/state.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_mailingcountry.value == "") {
			strErrorMessage += "Please enter the name of your country.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_mailingpcode.value == "") {
			strErrorMessage += "Please enter your postal/zip code.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_dealername.value == "") {
			strErrorMessage += "Please enter the name of your preferred SABIAN dealer name.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_dealerphone.value == "") {
			strErrorMessage += "Please enter the phone number of your preferred SABIAN dealer.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_dealercity.value == "") {
			strErrorMessage += "Please enter the city of your preferred SABIAN dealer.<br />";
			boolIsValid = false;
		}
		if (whichForm.tb_oneonehundred_dealercountry.value == "") {
			strErrorMessage += "Please enter the country of your preferred SABIAN dealer.<br />";
			boolIsValid = false;
		}
		if (!whichForm.cb_oneonehundred_agree.checked) {
			strErrorMessage += "Please confirm that you understand that you will be contacted regarding your purchase..<br />";
			boolIsValid = false;
		}
		if (!boolIsValid) {
			document.getElementById("errorMessageContent").innerHTML = "<p>" + strErrorMessage + "</p>";
			document.getElementById("errorMessage").style.display = "block";
			window.scrollTo(0,250);
		}
	}
	return boolIsValid;
}

function validateEmail(strValue) {
	var objRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return objRegExp.test(strValue);
}

function validateUsername(strValue) {
	var objRegExp1 = /[A-Za-z0123456789]/;
	var objRegExp2 = /_/;
	if ((objRegExp1.test(strValue)) && !(objRegExp2.test(strValue))) {
		return true;
	} else {
		return false;
	}
}

function launchWindow(whichContent) {
	//this function is for placement only
	switch(whichContent) {
		case "buyitnow":
			strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=325,width=350";
			objWin = window.open("popup_"+whichContent+".html",whichContent+"Window",strWinParams);
			break;
		case "tellafriend":
			strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=325,width=350";
			objWin = window.open("popup_"+whichContent+".html",whichContent+"Window",strWinParams);
			break;
		case "login":
			strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=380,width=360";
			objWin = window.open("popup_"+whichContent+".html",whichContent+"Window",strWinParams);
			break;
		case "oneofonehundredordering":
			strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=380,width=360";
			objWin = window.open("popup_"+whichContent+".html",whichContent+"Window",strWinParams);
			break;
	}
}

function clearExampleFormElementValue(whichElement, defaultValue) {
	if (whichElement.value == defaultValue) {
		whichElement.value = "";
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function buyitnowWindow(lang,productID) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=460,width=370";
	objWin = window.open("/"+lang+"/popup_buyitnow.cfm?productID="+productID,"buyitnowWindow",strWinParams);
}

function addToWishList(lang,loginstatus,productID) {
	if(loginstatus == 1){
		strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=325,width=350";
		objWin = window.open("/"+lang+"/popup_addToWishList.cfm?productID="+productID,"addWishlistWindow",strWinParams);
	}else{
		launchLoginWindow(lang,'addToWishList',productID);
	}
}

function addAccessoriesToWishList(lang,loginstatus,accessID) {
	if(loginstatus == 1){
		strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=325,width=350";
		objWin = window.open("/"+lang+"/popup_addToWishList.cfm?accessID="+accessID,"addWishlistWindow",strWinParams);
	}else{
		launchLoginWindow(lang,'addAccessoriesToWishList',accessID);
	}
}

function launchLoginWindow(lang,processType,processData) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=380,width=360";
	objWin = window.open("/"+lang+"/popup_login.cfm?processType="+processType+"&processData="+processData,"loginWindow",strWinParams);
}

function tellAFriendGeneral(lang,url) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=325,width=350";
	objWin = window.open("/"+lang+"/popup_tellafriend.cfm?url="+url,"tellafriendWindow",strWinParams);
}

function tellAFriendProduct(lang,productID) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=325,width=350";
	objWin = window.open("/"+lang+"/popup_tellafriend.cfm?productID="+productID,"tellafriendWindow",strWinParams);
}

function tellAFriendAccessories(lang,accessID) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=325,width=350";
	objWin = window.open("/"+lang+"/popup_tellafriend.cfm?accessID="+accessID,"tellafriendWindow",strWinParams);
}

function addArtistToFavorites(lang,loginstatus,artistID) {
	if(loginstatus == 1){
		strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=325,width=350";
		objWin = window.open("/"+lang+"/popup_addArtistToFavorites.cfm?artistID="+artistID,"addToFavoritesWindow",strWinParams);
	}else{
		launchLoginWindow(lang,'addArtistToFavorites',artistID);
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function addItemToCookie(whichCookie, whatValue, whichCheckbox) {
	strThisCookieValue = readCookie(whichCookie);
	if (strThisCookieValue) {
		//count # of '::' tokens in the cookie value
		var matches = strThisCookieValue.match(/::/g);
		var intMatchCount = matches.length;
		if (intMatchCount < 4) {
			createCookie(whichCookie, strThisCookieValue + whatValue + "::", 0);
		} else {
			alert("Sorry, you can only choose up to 4 products to compare at a time.");
			whichCheckbox.checked = false;
		}
	} else {
			createCookie(whichCookie, whatValue + "::", 0);
	}
}

function removeItemFromCookie(whichCookie, whatValue) {
	strThisCookieValue = readCookie(whichCookie);
	if (strThisCookieValue) {
		strThisCookieValue = strThisCookieValue.replace(whatValue+"::","");
		createCookie(whichCookie, strThisCookieValue, 0);
	}
}

function processProductComparison(whichCheckbox) {
	strThisProductID = whichCheckbox.value;
	if (whichCheckbox.checked) {
		//adding the item (if possible) to the cookie
		addItemToCookie("sabianProductCompIds", strThisProductID, whichCheckbox);
	} else {
		//removing the item (if possible) from the cookie
		removeItemFromCookie("sabianProductCompIds", strThisProductID);
	}
}

function showComparisonChart(selSeries,selType,selboonly,selSortBy,currPage,numRec) {
	strThisCookieValue = readCookie("sabianProductCompIds");
	if (strThisCookieValue) {
		strThisCookieValue = strThisCookieValue.substr(0, strThisCookieValue.length - 2);
		var arrIds = strThisCookieValue.split("::");
		var strQS = "";
		for (i=0; i < arrIds.length; i++) {
			strQS = strQS + "&id" + (i + 1) + "=" + arrIds[i];
		}
		strLocation = "/EN/products/productComparison.cfm?type=compare" + strQS + "&selSeries=" + selSeries + "&selType=" + selType + "&selboonly=" + selboonly + "&selSortBy=" + selSortBy + "&currPage=" + currPage + "&numRec=" + numRec;
		//eraseCookie("sabianProductCompIds");
		//alert(strLocation);
		document.location.href = strLocation;
	}
}

function removeProductFromComparisonChart(whichProductID) {
	strThisCookieValue = readCookie("sabianProductCompIds");
	if (strThisCookieValue) {
		removeItemFromCookie("sabianProductCompIds", whichProductID);
		showComparisonChart();
	}
}

function validateCymbalSearch(whichForm) {
	//check that the user has selected a series and/or type
	var boolSeriesChecked = false;
	var boolTypeChecked = false;
	for (i=0; i<whichForm.cf_series.length; i++){
		if (whichForm.cf_series[i].checked) {
			boolSeriesChecked = true;
		}
	}
	for (i=0; i<whichForm.cf_types.length; i++){
		if (whichForm.cf_types[i].checked) {
			boolTypeChecked = true;
		}
	}
	if (boolSeriesChecked || boolTypeChecked) {
		return true;
	} else {
		alert("Please select a Cymbal Series and/or Type to search for.");
		return false;
	}
}

function clearCymbalSearchTypes(whichType) {
	if (whichType == "all") {
		document.getElementById("cb_cf_alltypes").checked = false;
	} else {
		document.getElementById("cb_cf_Splashes").checked = false;
		document.getElementById("cb_cf_Chinese").checked = false;
		document.getElementById("cb_cf_Crashes").checked = false;
		document.getElementById("cb_cf_Percussion").checked = false;
		document.getElementById("cb_cf_Rides").checked = false;
		document.getElementById("cb_cf_Sets").checked = false;
		document.getElementById("cb_cf_Hats").checked = false;
		document.getElementById("cb_cf_BandOrchestral").checked = false;
	}
}

function filterVideos(whatFilter) {
	document.location.href = whatFilter;
}

function showLoggedInUser(whichUserName,whichUserID) {
	//need to pass parameters of some sort for the username & avatar image
	document.getElementById("memberLinks").className = "loggedIn";
	strBandTogetherWidgetContent = "<h6><a href='/EN/community/member.cfm?memberID=" + whichUserID + "'>" + whichUserName + "</a></h6><a href='/EN/community/member.cfm?memberID=" + whichUserID + "' class='btn_myProfile_sm'>My Profile</a><a href='/EN/community/logout.cfm' class='btn_logout_sm'>Logout</a><div class='clearFloats'></div>";
	document.getElementById("memberLinks").innerHTML = strBandTogetherWidgetContent;
}

function launch(page) {
  window.open(page,"TourVideo","toolbar=no,menubar=no,scrollbars=no,location=no,width=428,height=285,top=250,left=250");
}

function showMap(dealerID) {
	var left = ((screen.width - 500)/2);
 	var top = ((screen.height - 400)/2);
	window.open('/EN/dealerlocator/dealerMap.cfm?dealerID=' + dealerID,'map','width=500,height=400,resizable=yes,directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,top=' + top + ',left=' + left);
}

function artistRequestCategory(lang,artistName) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=325,width=350";
	objWin = window.open("/"+lang+"/artists/popup_artistRequestCat.cfm?artistName="+artistName,"artistRequestCatWindow",strWinParams);
}

function validateCookieAgainstResults() {
	//if the cookie exists and has content, iterate through the values and check them against the
	//current search results page checkboxes
	//this function expects a variable called 'strThisPageProductCheckboxes' that contains a '::' delimited list
	//of the search results checkbox IDs e.g. 1757::1758::1759::
	//strThisPageProductCheckboxes = "1757::1758::1759::";
	strThisCookieValue = readCookie("sabianProductCompIds");
	if (strThisCookieValue) {
		strThisPageProductCheckboxes = strThisPageProductCheckboxes.substr(0, strThisPageProductCheckboxes.length - 2);
		var arrIds = strThisPageProductCheckboxes.split("::");
		for (i=0; i < arrIds.length; i++) {
			if (document.getElementById("cb_product" + arrIds[i])) {
				if (strThisCookieValue.indexOf(arrIds[i]) > 0) {
					document.getElementById("cb_product" + arrIds[i]).checked = true;
				} else {
					document.getElementById("cb_product" + arrIds[i]).checked = false;
				}
			}
		}
	}
}

function clearProductCheckboxes() {
	//iterate through the product results checkboxes and uncheck them
	//this function expects a variable called 'strThisPageProductCheckboxes' that contains a '::' delimited list
	//of the search results checkbox IDs e.g. 1757::1758::1759::
	//strThisPageProductCheckboxes = "1757::1758::1759";
	if (strThisPageProductCheckboxes) {
		strThisPageProductCheckboxes = strThisPageProductCheckboxes.substr(0, strThisPageProductCheckboxes.length - 2);
		var arrIds = strThisPageProductCheckboxes.split("::");
		for (i=0; i < arrIds.length; i++) {
			if (document.getElementById("cb_product" + arrIds[i])) {
				document.getElementById("cb_product" + arrIds[i]).checked = false;
			}
		}
	}
}

function boSoundCalcTermsWindow(lang) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=325,width=350";
	objWin = window.open("/EN/popup_soundcalcterms"+lang+".cfm","soundCalcTermsWindow",strWinParams);
}

function deleteDefaultMessage(whichItem, message) {
	if (whichItem) {
		if (document.getElementById(whichItem).innerHTML == message) {
			document.getElementById(whichItem).innerHTML = "";
		}
	}
}

 

function setDefaultMessage(whichItem, message) {
	if (whichItem) {
		if (document.getElementById(whichItem).value == "") {
			document.getElementById(whichItem).innerHTML = message;
			document.getElementById(whichItem).value = message;
		}
	}
}

function showForgotPassword(url) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=350,width=350";
	objWin = window.open(url,"forgotPassword",strWinParams);
}

function addBuddy(lang,buddyName) {
	strWinParams = "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=auto,height=325,width=350";
	objWin = window.open("/"+lang+"/popup_addToBuddies.cfm?buddyName="+buddyName,"addBuddyWindow",strWinParams);
}

