﻿function showAlbum(AlbumID) { location = "album.aspx?id=" + AlbumID }
function add2Cart(ItemID) {
    var cart
    cart = getCookie("cart")
    if (cart == null)
        cart = ItemID + "=1";
    else
        cart = cart + "&" + ItemID + "=1";
            
    setCookie("cart", cart, 7);
    location = "cart.aspx";
}
function writeCartCount() {document.write("item(s)");}
function itemsInCart() {
    var numItems = 0;
    var stuff = getCookie("cart");
    if ('a' + stuff != 'aundefined') {
        arrayOfStrings = stuff.split('&');
        for (var i = 0; i < arrayOfStrings.length; i += 1) {
            tmp = arrayOfStrings[i];
            arrtmp = tmp.split('=');
            numItems += parseInt(arrtmp[1]);
        }
        if ('a' + numItems == "aNaN") {
            numItems = 0;
        }
    }
    return numItems
}
/*function setCookie(name, value, days) {
    var expire = new Date();
    expire.setTime(expire.parse() + (60 * 60 * 24 * days * 1000));
    document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}
*/
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=" + escape("/");
}

function getCookie(Name) {
    var search = Name + "="
    if (document.cookie.length > 0) { // if there are any cookies
        offset = document.cookie.indexOf(search)
        if (offset != -1) { // if cookie exists
            offset += search.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset)
            // set index of end of cookie value
            if (end == -1)
                end = document.cookie.length
            return unescape(document.cookie.substring(offset, end))
        }
    }
}
function doClick(buttonName, e) {
    //the purpose of this function is to allow the enter key to  point to the correct button to click.
    var key;
    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) { //If we find the button click it
            btn.click();
            event.keyCode = 0
        }
    }
}
function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13)
        return false;
    else
        return true;
}

function playTrack(AlbumID, TrackNum) {
    var fp = "../flash/xspf_player_slim.swf?autoplay=true";
    if (TrackNum>0)
        fp = fp + "&song_url=" + "../media/" + AlbumID + "/sample" + TrackNum + ".mp3";
    else
        fp = fp + "&song_url=" + "../media/" + AlbumID + "/albumsample.mp3";
    var so = new SWFObject(fp, "player", 300, 18, "6,0,47,0", "#e6e6e6");
    so.addParam("repeat_playlist", "false");
    so.addParam("scale", "noscale");
    so.addParam("quality", "high");
    so.addParam("salign", "lt");
    so.addParam("allowScriptAccess", "always");
    so.addParam("menu", "false");
    so.write("mediaplayer");
}
function showAlbumTooltip(AlbumID) {}
function hideAlbumTooltip() {}
