//This file serves as the javascript library for connect commerce xsl pages.

var oneYearExpDate = new Date ();
oneYearExpDate.setTime(oneYearExpDate.getTime() + (365 * 24 * 3600 * 1000));


        var prefix = 'ItemsInCart';
        var cookieLife = 60000;
        var spacer = '~';
        var counter = 0;
        var defSubs = new Array();
        var subs = new Array();
        var unsubs = new Array();
        var isSonicStage = false;
        var form = 'cuneiform'; //Give the form name here
        var preloadFlag = false;

        function preloadImages() {
            if (document.images) {
                Home_NAV_06_over =
                    newImage("https://musicstore.connect.com/XSL/mb_us/images/search-over.gif");
                preloadFlag = true;
            }
        }

        function SetChecked(val, chkName) {
            dml = document.forms[form];
            len = dml.elements.length;
            var i = 0;
            for (i = 0; i < len; i++) {
                if (dml.elements[i].name == chkName) {
                    dml.elements[i].checked = val;
                }
            }
        }

        function submitForm(frm) {
            frm.pageIndex.value = 1;
            return true;
        }

        function searchNext(frm) {
            frm.pageIndex.value++;
            frm.submit();
        }

        function searchPrev(frm) {
            frm.pageIndex.value--;
            frm.submit();
        }

        function searchGotoPage(pageIdx) {
            document.Entitlements.pageIndex.value = pageIdx;
            document.Entitlements.submit();
        }

	function sortColumn(colName)
	{
		var frm = document.Entitlements;
		if (frm.sortField1.value == colName) {
			if (frm.sortOrder1.value == "asc") {
				frm.sortOrder1.value = "desc";
			}
			else {
				frm.sortOrder1.value = "asc";
			}
		}
		else {
			frm.sortField1.value = colName;
			frm.sortOrder1.value = "asc";
		}
		frm.pageIndex.value = 1;
		frm.submit();
	}

	function sortColumn(colName, backupColName)
	{
		var frm = document.Entitlements;
		if (frm.sortField1.value == colName) {
			if (frm.sortOrder1.value == "asc") {
				frm.sortOrder1.value = "desc";
			}
			else {
				frm.sortOrder1.value = "asc";
			}
		}
		else {
			frm.sortField1.value = colName;
			frm.sortField2.value = backupColName;
			frm.sortOrder1.value = "asc";
		}
		frm.pageIndex.value = 1;
		frm.submit();
	}	

        function checkbox_checker(form) {
            // set var checkbox_choices to zero
            var checkbox_choices = 0;
            var params =
                "terminalID=" + window.external.GetOpenMGTermID();
            var counter = 0;
            // Loop from zero to the one minus the number of checkbox button selections
            for (counter = 0; counter < form.elements.length; counter++) {
                if (form.elements[counter].checked == true) {
                    // alert('checked');
                    params += "&CONTENT_GUID="
                        + form.elements[counter].value;
                    checkbox_choices = checkbox_choices + 1;
                }
            }

            if (checkbox_choices == 0) {
                alert("Please select at least one file to download.");
            } else {
                window.external.SetDeliveryMetafile(
                    form.action,
                    "POST",
                    params,
                    "VISIBLE");
            }

            return false;
        }

        /** Expandable/Collapsable albums **/
        function over(src) {
            if (("SPAN" == src.tagName && "tecNotes" == src.id)
                || "B" == src.tagName) {
                src.style.color = "rgb(255,0,0)";
                src.style.cursor = (document.all) ? "hand" : "pointer";
            }
        }

        function out(src) {
            if (("SPAN" == src.tagName && "tecNotes" == src.id)
                || "B" == src.tagName) {
                src.style.color = "rgb(0,0,0)";
                src.style.cursor = "auto";
            }
        }

        function initIt() {
            divColl = document.all.tags("DIV");
            for (i = 0; i < divColl.length; i++) {
                whichEl = divColl(i);
                whichEl.style.display = "none";
            }
        }

        function expandIt(img, divId) {
            var targetElement = document.all(divId);
            if (targetElement.style.display == "none") {
                targetElement.style.display = "block";
                img.src = "https://musicstore.connect.com/XSL/mb_us/images/expand_03.gif";
            } else {
                targetElement.style.display = "none";
                img.src = "https://musicstore.connect.com/XSL/mb_us/images/expand_03b.gif";
            }
        }

        function getTermID() {
            try {
                var termID = window.external.GetOpenMGTermID();
                if (termID == '') {
                    //alert("could not retrieve terminal ID");
                } else {
                    //alert(termID);
                    document.deviceForm.keyDisplayed.value = termID;
                    document.deviceForm.key.value = termID;
                }
            } catch (e) {
                //alert("error " + e.message);
            }
        }

        function acceptLegal(frm) {
            frm.pp.value = "true";
            frm.tos.value = "true";
            frm.submit();
        }

        function declineLegal(frm) {
            frm.pp.value = "false";
            frm.tos.value = "false";
            frm.submit();
        }

        function loadCoupon() {
            var last_coupon = getCookie('last_coupon');
            if (last_coupon != null) {
                document.couponForm.promocode.value = last_coupon;
            }
        }

        function closePopupForm(action) {
            window.returnValue = action;
            window.close();
        }

        function loginAndReturn() {
            document.location = "Login.flow?REF=" + escape(document.location);
        }

        function getRegisterUrl() {
            document.location =
                "Registration.flow?REF=" + escape(document.location);
        }

        function setNewCookie(cookieName, prodId) {
            //alert('found the cookie');
            var cookieValue = getCookie(cookieName);
            //alert('found the cookie with value '+cookieValue);
            var begin = cookieValue.indexOf(prodId + spacer);
            if (begin == -1)
                exit();
            var end = cookieValue.indexOf(spacer, begin);
            var startText = cookieValue.substring(0, begin);
            var endText = cookieValue.substring((end + 1), cookieValue.length);

            setCookie(
                cookieName,
                startText + endText,
                null,
                '/',
                '.connect.com',
                false);
            //alert('setting the new value to '+startText + endText);
        }

        function deleteCookie(name, path, domain) {
            if (getCookie(name)) {
                document.cookie =
                    name
                        + "="
                        + ((path) ? "; path=" + path : "")
                        + ((domain) ? "; domain=" + domain : "")
                        + "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
            }
        }

        function deleteAllItemCookies() {
            var dc = document.cookie;
            var end = 0;
            var begin = 0;
            var cookieName;
            counter = 0;
            while(dc.indexOf(prefix) >=0) {
                begin = dc.indexOf(prefix) ;
                if (begin == -1) {
                    exit();
                }
                end = dc.indexOf("=", begin);
                if (end == -1)
                    end = dc.length;

                cookieName = unescape(dc.substring(begin, end));
                deleteCookie(cookieName, '/', '.connect.com');
                dc = dc.substring(end,dc.length);
                counter ++;
            }
        }

        function deleteAllAddToCartCookies() {
            if (!readCookie('ExpressCheckoutCookie')) {
                deleteAllItemCookies();
            }
        }

        function getCookie(name) {
            var dc = document.cookie;
            var prefix = name + "=";
            var begin = dc.indexOf("; " + prefix);
            if (begin == -1) {
                begin = dc.indexOf(prefix);
                if (begin != 0)
                    return null;
            } else
                begin += 2;
            var end = document.cookie.indexOf(";", begin);
            if (end == -1)
                end = dc.length;
            return unescape(dc.substring(begin + prefix.length, end));
        }

        function onGlobalPrefPageLoad() {
            var frm = document.EditProfile;
            for (var i = 0; i < frm.elements.length; i++) {
                var elm = frm.elements[i];
                if (elm.name.indexOf("newsletter-") == 0) {
                    // extract the id
                    var id = elm.name.split("-")[1];
                    if (elm.checked) {
                        defSubs.push(id);
                    }
                }
            }

	    if (frm.promotion.checked) unsubscribeAll(frm);
        }

        function onRegisterPageLoad() {
            var frm = document.Register;
            for (var i = 0; i < frm.elements.length; i++) {
                var elm = frm.elements[i];
                if (elm.name.indexOf("newsletter-") == 0) {
                    // extract the id
                    var id = elm.name.split("-")[1];
                    if (elm.checked) {
                        defSubs.push(id);
                    }
                }
            }
        }

			function unsubscribeAll(frm)
			{
				// unsubscribe all newsletters
				for (var i=0; i<defSubs.length; i++) {
					addUniqueElement(unsubs, subs, defSubs[i]);
				}
				// turn off the check boxes
				for (var i=0; i<frm.elements.length; i++) {
					var elm = frm.elements[i];
					if (elm.name.indexOf("newsletter-") == 0) {
						if (elm.checked) {
							var id = elm.name.split("-")[1];
							elm.checked = false;
						}
					}
				}
			}

			function onEmailSuppression(cb)
			{
				if (cb.checked) {
					unsubscribeAll(cb.form);
				}
			}

			function addUniqueElement(lst, toBeRemoved, elm)
			{
				var onList = false;
				for (var i=0; i<lst.length; i++) {
					if (lst[i] == elm) {
						onList = true;
						break;
					}
				}
				if (!onList) {
					lst.push(elm);
				}

				for (var i=0; i<toBeRemoved.length; i++) {
					if (toBeRemoved[i] == elm) {
				   		toBeRemoved.splice(i, 1);
				   		break;
					}
				}
			}

        function onClickNewsletter(cb, id) {

		var onList = false;
				for (var i=0; i<defSubs.length; i++) {
					if (defSubs[i] == id) {
						onList = true;
						break;
					}
				}
		if (cb.checked) {
		// add to the subscription list if not already so
		if (!onList) {
		// add only if subs does not contains it
			addUniqueElement(subs, unsubs, id);
					}
		// turn off the email suppression
			cb.form.promotion.checked = false;
				}
			else {
		// add to the unsubscription list if this is a subscribed newsletter
			if (onList) {
			addUniqueElement(unsubs, subs, id);
					}
				}
			}



        function onFormSubmit(frm) {
            if (frm.expressCheckout.checked) {
                frm.express_checkout.value = "on";
            } else {
                frm.express_checkout.value = "off";
            }
            frm.elements["subscribe"].value = subs;
            frm.elements["signoff"].value = unsubs;

	    frm.promotion.value = frm.promotion.checked ? "true" : "false";
	    frm.emailFriend.value = frm.emailFriend.checked ? "true" : "false";

            return true;
        }



        function onRegisterFormSubmit(frm, newsIds) {

            // setting enable buy-now checkbox
            if (frm.expressCheckout.checked) {
                frm.express_checkout.value = "on";
            } else {
                frm.express_checkout.value = "off";
            }

            // setting newsletters checkboxes
            for (var i = 0; i < newsIds.length; i++) {
                var cbName = 'newsletter-' + newsIds[i];
                if (frm.elements[cbName].checked) {
                    // add to the subscription list
                    subs.push(newsIds[i]);
                }
            }
            frm.elements["subscribe"].value = subs;
            frm.elements["signoff"].value = '';

            return true;
        }

        function setCookie(name, value, expires, path, domain, secure) {
            var theTime = new Date().getTime() + cookieLife;
            expires = new Date(theTime);
            var curCookie =
                name
                    + "="
                    + escape(value)
                    + ((path) ? "; path=" + path : "")
                    + ((domain) ? "; domain=" + domain : "")
                    + ((expires) ? "; expires=" + expires.toUTCString() : "")
                    + ((secure) ? "; secure" : "");
            document.cookie = curCookie;
            //alert('new cookie is '+curCookie);
        }

        function refreshCookie() {

            var dc = document.cookie;

            var end = 0;

            var begin = 0;
            while (dc.indexOf(prefix) >= 0) {
                begin = dc.indexOf(prefix);
                if (begin == -1) {
                    exit();
                }

                end = dc.indexOf("=", begin);
                if (end == -1)
                    end = dc.length;

                var cookieName = unescape(dc.substring(begin, end));
                var cookieValue = getCookie(cookieName);
                setCookie(
                    cookieName,
                    cookieValue,
                    null,
                    '/',
                    '.connect.com',
                    false);
                dc = dc.substring(end, dc.length);
            }
        }

        function removeCartCookies() {

            var dc = document.cookie;
            var end = 0;
            var begin = 0;

            while (dc.indexOf(prefix) >= 0) {
                begin = dc.indexOf(prefix);
                if (begin == -1) {
                    exit();
                }
                end = dc.indexOf("=", begin);
                if (end == -1)
                    end = dc.length;

                var cookieName = unescape(dc.substring(begin, end));
                deleteCookie(cookieName, '/', '.connect.com');
                //alert('cookie '+getCookie(cookieName));
                dc = dc.substring(end, dc.length);
            }
        }

        function readCookie(CookieName) {
            var CookieString = document.cookie;
            var CookieSet = CookieString.split(';');
            var SetSize = CookieSet.length;
            var CookiePieces;
            var ReturnValue = "";
            var x = 0;

            for (x = 0;((x < SetSize) && (ReturnValue == "")); x++) {
                CookiePieces = CookieSet[x].split('=');
                if (CookiePieces[0].substring(0, 1) == ' ') {
                    CookiePieces[0] =
                        CookiePieces[0].substring(1, CookiePieces[0].length);
                }
                if (CookiePieces[0] == CookieName) {
                    ReturnValue = CookiePieces[1];
                }
            }
            return ReturnValue;
        }

        function handleCookieFields() {
            if (readCookie('UserLogedInCookie')) {
                document.searchForm.loggedon.value = "1";
            } else {
                document.searchForm.loggedon.value = "0";
            }

            if (readCookie('ExpressCheckoutCookie')) {
                document.searchForm.buynow.value = "1";
            } else {
                document.searchForm.buynow.value = "0";
            }
        }

        function refreshCookie() {
            var dc = document.cookie;
                var end = 0;
                var begin = 0;
                while (dc.indexOf(prefix) >= 0) {
                begin = dc.indexOf(prefix); if (begin == -1) {
                    exit(); }

                end = dc.indexOf("=", begin); if (end == -1)
                    end = dc.length;
                        var cookieName = unescape(dc.substring(begin, end));
                        var cookieValue = getCookie(cookieName);
                        setCookie(
                            cookieName,
                            cookieValue,
                            null,
                            '/',
                            '.connect.com',
                            false);
                        dc = dc.substring(end, dc.length);
                        }
        }

        var identified =
            "Do not keep me logged in on this computer.  I will need to log in each time I purchase music.";
            var lowBandwidthWarn =
                "Warn me about site performance if I have a slow Internet connection.";
            function getCookieVal(offset) {
            var endstr = document.cookie.indexOf(";", offset);
                //; signifies end of value
            if (endstr == -1)
                endstr = document.cookie.length;
    //if -1 then take it to the end
                return unescape(
            document.cookie.substring(offset, endstr));
        //convert to readable text
                }

        function GetCookie(name) {
            var arg = name + "=";
                var alen = arg.length;
                var clen = document.cookie.length;
                var i = 0;
                while (i < clen) {
                var j = i + alen;
                    if (document.cookie.substring(i, j)
                        == arg) //find position where substring = name
                return getCookieVal(j);
                    //get the cookie val from that pos
                i =
                            document.cookie.indexOf(" ", i) + 1;
                    if (i == 0)
                        break; }
            return null; //nothing found
            }

        function onAccountMainPageLoad() {
            var identifiedCookie = GetCookie("Identified");
                if (null != identifiedCookie)
                identified =
                    "Keep me logged in on this computer.  This will allow me to purchase music without having to type in my password each time.";
                    var lbWarn = GetCookie("LowBandwidthNoWarn");
                    if (null != lbWarn)
                    lowBandwidthWarn =
                        "Don't warn me about site performance if I have a slow Internet connection.";
                        } // Writes identified message based on user account's setting
                    function identifiedMsg() {
            document.write(identified);
                } // Writes lowBandwidthWarn message based on user account's setting
            function lowBandwidthWarnMsg() {
            document.write(lowBandwidthWarn); }

        function loadEmailAddress() {
            var last_login = getCookie('last_login'); if (last_login != null) {
                document.forgetPasswordForm.email.value = last_login; }
        }

        function newImage(arg) {
            if (document.images) {
                rslt = new Image(); rslt.src = arg; return rslt; }
        }
        var preloadFlag = false; 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 MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr;
            for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
                x.src = x.oSrc; }

        function MM_preloadImages() { //v3.0
        var d = document; if (d.images) {
                if (!d.MM_p)
                    d.MM_p = new Array();
                        var i,
                            j = d.MM_p.length,
                            a = MM_preloadImages.arguments;
                        for (i = 0; i < a.length; i++)
                        if (a[i].indexOf("#") != 0) {
                            d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
            }
        }

        function MM_findObj(n, d) { //v4.01
        var p, i, x; if (!d)
                d = document;
                    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
                    d = parent.frames[n.substring(p + 1)].document;
                        n = n.substring(0, p);
                        }
            if (!(x = d[n]) && d.all)
                x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++)
                    x = d.forms[i][n];
                        for (i = 0; !x && d.layers && i < d.layers.length; i++)
                        x = MM_findObj(n, d.layers[i].document);
                            if (!x && d.getElementById)
                            x = d.getElementById(n); return x; }

        function MM_swapImage() {  //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments;
            document.MM_sr = new Array;
            for (i = 0; i < (a.length - 2); i += 3)
                if ((x = MM_findObj(a[i])) != null) {
                    document.MM_sr[j++] = x; if (!x.oSrc)
                        x.oSrc = x.src; x.src = a[i + 2]; }
        }

        function MM_callJS(jsStr) { //v2.0
          return eval(jsStr)
        }

        function MM_openBrWindow(theURL,winName,features) { //v2.0
          window.open(theURL,winName,features);
        }

        function getParameterValue(key) {
            var result = null;
                var search = unescape(window.location.search);
                if (search.length > 1) {
                search = search.substring(1, search.length); }

            var paramArray = search.split('&');
                for (var i = 0; i < paramArray.length; i++) {
                var nextPair = paramArray[i].split('=');
                    if (nextPair.length == 2) {
                    var name = nextPair[0];
                        var value = nextPair[1];
                        if (name == key) {
                        result = value; break; }
                }

            }

            return result; }

        function highlight(objectID) {
            var object = MM_findObj(objectID); if (object != null) {
                object.style.backgroundColor = "FFE57F"; }
        }

        function onDownload(form) {
            var counter;
                var doDownload = 0;
                var params =
                    "terminalID=" + window.external.GetOpenMGTermID();
                for (counter = 0; counter < form.elements.length; counter++) {

                if (form.elements[counter].name == "GUID") {
                    params += "&CONTENT_GUID=" + form.elements[counter].value;
                        doDownload = 1;
                        }
            }
            if (doDownload) {
                window.external.SetDeliveryMetafile(
                    form.action,
                    "POST",
                    params,
                    "VISIBLE");
                    }

            return false;
         }

        function mouseDown(e) {
           var shiftPressed=0;
           if (parseInt(navigator.appVersion)>3) {
               if (navigator.appName=="Netscape")
                   shiftPressed=(e.modifiers-0>3);
               else shiftPressed=event.shiftKey;
               if (shiftPressed) {
                   alert ('Shift-click is disabled.')
                   return false;
               }
           }
           return true;
        }

        function mouseDownVersion() {
           if (parseInt(navigator.appVersion)>3) {
               document.onmousedown = mouseDown;
           if (navigator.appName=="Netscape")
               document.captureEvents(Event.MOUSEDOWN);
           }
        }

        NS4 = (document.layers) ? true : false;

        function checkEnter(form)
        {
            var code = 0;

            if (NS4) {
                code = event.which;
                //alert("Which: " + code);
            }else{
                code = window.event.keyCode;
                //alert("keyCode: " + code);
            }

            if (code==13)
                form.submit();
        }

        // sets the search parameters to be passed to atomz
        // for search results (relevance, sort order, etc.)
        function setFormParams() {
        var d = document.searchForm;

        var noncat = "http://search.connect.com/search/";
        var cat = "http://catsearch.atomz.com/search/";

        t = d.elements['sp-t'].value;

        if (t=="search") {
           d.action = noncat;
           d.elements['sp-x'].value = "track|album|artist";
           d.elements['sp-k'].value = "tracks";
           d.elements['sp-sfvl-field'].value = "";
           }
        else if (t=="search_all") {
           d.action = cat;
           d.elements['sp-x'].value = "";
           d.elements['sp-k'].value = "";
           d.elements['sp-sfvl-field'].value = "";
           }
        else if (t=="labels") {
           d.action = noncat;
           d.elements['sp-x'].value = "label";
           d.elements['sp-k'].value = "labels";
           d.elements['sp-sfvl-field'].value = "initial";
           }
        else if (t=="albums") {
           d.action = noncat;
           d.elements['sp-x'].value = "album|artist";
           d.elements['sp-k'].value = "albums";
           d.elements['sp-sfvl-field'].value = "initial";
           }
        else if (t=="artists") {
           d.action = noncat;
           d.elements['sp-x'].value = "artist";
           d.elements['sp-k'].value = "artists";
           d.elements['sp-sfvl-field'].value = "initial";
           }
        else if (t=="label_browse") {
           d.action = cat;
           d.elements['sp-x'].value = "";
           d.elements['sp-k'].value = "";
           d.elements['sp-sfvl-field'].value = "";
           }
        else if (t=="label_home") {
           d.action = cat;
           d.elements['sp-x'].value = "";
           d.elements['sp-k'].value = "";
           d.elements['sp-sfvl-field'].value = "";
           }

        }

        function submitAtomzSearch() {
            if (readCookie('ExpressCheckoutCookie')) {
                document.searchForm.buynow.value='1';
            }

            document.searchForm.submit();
        }

        function popHelpWindow(url, height, width) {
            var param = 'height=' + height + ', width=' + width + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no';
            window.open(url, 'helpPopup', param);
        }


		function jump_site(){
		    sitevar= document.searchForm.dropdown.selectedIndex;
		    if(sitevar != 0){
				location.href = document.searchForm.dropdown.options[sitevar].value;
			}
		}

        function loadGenreList() {
            GenreArray = new Array(28);
            for (i = 0; i < 28; i++) {
                GenreArray[i] = new Array(2);
            }
            GenreArray[0][0] = "Home";
            GenreArray[0][1] = "http://musicstore.connect.com/index.html?HomePageLink=true";
            GenreArray[1][0] = "Alt Country";
            GenreArray[1][1] = "http://musicstore.connect.com/genre/altcountry.html";
            GenreArray[2][0] = "Alternative";
            GenreArray[2][1] = "http://musicstore.connect.com/genre/alternative.html";
            GenreArray[3][0] = "Blues";
            GenreArray[3][1] = "http://musicstore.connect.com/genre/blues.html";
            GenreArray[4][0] = "Children's";
            GenreArray[4][1] = "http://musicstore.connect.com/genre/childrens.html";
            GenreArray[5][0] = "Classical";
            GenreArray[5][1] = "http://musicstore.connect.com/genre/classical.html";
            GenreArray[6][0] = "Comedy/Spoken Word";
            GenreArray[6][1] = "http://musicstore.connect.com/genre/comedyspokenword.html";
            GenreArray[7][0] = "Country";
            GenreArray[7][1] = "http://musicstore.connect.com/genre/country.html";
            GenreArray[8][0] = "Dance";
            GenreArray[8][1] = "http://musicstore.connect.com/genre/dance.html";
            GenreArray[9][0] = "Electronic";
            GenreArray[9][1] = "http://musicstore.connect.com/genre/electronic.html";
            GenreArray[10][0] = "Hard Rock/Heavy Metal";
            GenreArray[10][1] = "http://musicstore.connect.com/genre/hardrockheavymetal.html";
            GenreArray[11][0] = "Holiday";
            GenreArray[11][1] = "http://musicstore.connect.com/genre/holiday.html";
            GenreArray[12][0] = "Indie Rock";
            GenreArray[12][1] = "http://musicstore.connect.com/genre/indierock.html";
            GenreArray[13][0] = "Inspirational";
            GenreArray[13][1] = "http://musicstore.connect.com/genre/inspirational.html";
            GenreArray[14][0] = "Jazz";
            GenreArray[14][1] = "http://musicstore.connect.com/genre/jazz.html";
            GenreArray[15][0] = "Latin";
            GenreArray[15][1] = "http://musicstore.connect.com/genre/latinmusic.html";
            GenreArray[16][0] = "New Age";
            GenreArray[16][1] = "http://musicstore.connect.com/genre/newage.html";
            GenreArray[17][0] = "Pop";
            GenreArray[17][1] = "http://musicstore.connect.com/genre/pop.html";
            GenreArray[18][0] = "Punk/Hardcore";
            GenreArray[18][1] = "http://musicstore.connect.com/genre/punkhardcore.html";
            GenreArray[19][0] = "R&B";
            GenreArray[19][1] = "http://musicstore.connect.com/genre/rbsoul.html";
            GenreArray[20][0] = "Rap/Hip-Hop";
            GenreArray[20][1] = "http://musicstore.connect.com/genre/rap.html";
            GenreArray[21][0] = "Reggae";
            GenreArray[21][1] = "http://musicstore.connect.com/genre/reggae.html";
            GenreArray[22][0] = "Rock";
            GenreArray[22][1] = "http://musicstore.connect.com/genre/rock.html";
            GenreArray[23][0] = "Singer/Songwriter";
            GenreArray[23][1] = "http://musicstore.connect.com/genre/folk.html";
            GenreArray[24][0] = "Soundtracks";
            GenreArray[24][1] = "http://musicstore.connect.com/genre/soundtracks.html";
            GenreArray[25][0] = "Underground Hip-Hop";
            GenreArray[25][1] = "http://musicstore.connect.com/genre/undergroundhiphop.html";
            GenreArray[26][0] = "Vocal";
            GenreArray[26][1] = "http://musicstore.connect.com/genre/vocal.html";
            GenreArray[27][0] = "World";
            GenreArray[27][1] = "http://musicstore.connect.com/genre/world.html";

            for (i = 0; i < GenreArray.length; i++) {
                genreOption  = new Option();
                genreOption.text=GenreArray[i][0];
                genreOption.value=GenreArray[i][1];
                document.searchForm.dropdown.options[document.searchForm.dropdown.options.length] = genreOption;

                // set dropdown value to current genre if on genre page
                if(GenreArray[i][1] == window.location){
                    document.searchForm.dropdown.options[i+1].selected = true;
                }
            }
        }

function runSmallTests() {
    try {
        var appInfo = window.external.GetSystemInfo("APP_VERSION").split(",");
        if (appInfo[0] == "SonicStage") {
           isSonicStage = true;
           return;
        }
    }
    catch(e) {
		isSonicStage = false;
    }

}

function IESignup() {
	self.location = 'http://musicstore.connect.com/mb_us/mb_us/IESignup.flow';
}

function IESignupName() {
	document.write("Sign-up/Download");
}

function IEDownloadSS() {
	self.location = "http://www.connect.com/download.html";
}

function IEDownloadSSName() {
	document.write("Download SonicStage");
}

