axt = {
    version : "0.031",
    base_style : "single",
    container : null,
    logo : null,
    body : null,
    basket : null,
    headerBasket : null,
    player : null,
    callback : null,
    width: 200,
    height: 200,
    cover : null,
    tracks : false,//
    x: "http://www.levykauppax.fi",//
    _t : null,
    _f : null,
    _needs_scrolling : false,
    _available_tracks : [],
    _selected_tracks : [],
    _footerHTML : null,
    _searches : [],
    _details : null,
    _samples : [],
    _items : [],
    _playing : null,//
    _domain : "http://www.recordshopx.com",//
    _loading : false,
    _boxModelSet : false,
    _boxModel : false,
    _loaded : 0,
    _cache: {},
    
    init : function (id, settings) {
        if (!id) id = "ax-container";
        if (!document.getElementById) return;
        if (!document.getElementById(id)) return;
        //
        this.T = this._f;//
        this.container = document.getElementById(id);
        this.container.className = "ax-loading";
        this.container.style.position = "relative";
        var name = settings.shop ? settings.shop[1] : this.T["x"];
        if (settings.shop) this.x = this.x + "/" + settings.shop[0];
        var h = "<div class=\"ax-header\"><a href=\"" + this.x + "\" id=\"ax-logo\">" + name + "</a>";
        h += "<a href=\"#\" onclick=\"axt.hideBasket(); axt.hideHelp(); return false;\" class=\"ax-close\">" + this.T["back_to_products"] + "</a>";
        h += "<div id=\"ax-header-basket\" onclick=\"axt.showBasket(this);\"></div><a href=\"#\" onclick=\"axt.toggleHelp(this); return false;\" class=\"ax-help\">?</a></div><div class=\"ax-body\"></div><div class=\"ax-footer\"></div><div id=\"ax-basket\"></div><div id=\"ax-help\"></div>";
        this.container.innerHTML = h;
        this._fixLinks();
        var divs = this.container.getElementsByTagName("div");
        this.header = divs[0];
        this.headerBasket = divs[1];
        this.body = divs[2];
        this.footer = divs[3];
        this.helper = divs[5];
        
        var links = this.header.getElementsByTagName("a");
        this.helpLink = links[2];

        this.logo = document.getElementById("ax-logo");
        this.basket = document.getElementById("ax-basket");
        this.loadCss(this._domain + "/css/axt/single.css?" + this.version);
        if (settings) {
            if (settings.title)
                this.title = settings.title;                
            if (settings.width)
                this.width = settings.width;
            if (settings.font)
                this.font = settings.font;
            if (settings.tracks)
                this.tracks = settings.tracks;
            this.container.style.width = this.width + "px";
            var w = this.width - 2;
            if (this._isIE() && !this._isBoxModel()) w = w+2;
            this.body.style.width = w + "px";
            this.header.style.width = w + "px";
            if (settings.height)
                this.height = settings.height;
            this.container.style.height = this.height + "px";
            this.body.style.height = this.height + "px";
            if (settings.style) {
                this.style = settings.style;
            }
        }
    },
    
    _isIE : function () {
        return (document.all && (navigator.userAgent.indexOf('MSIE') != -1))
    },
    
    _isBoxModel : function () {
        if (!this._boxModelSet) {
            var div = document.createElement("div");
        	div.style.width = div.style.paddingLeft = "1px";
    		document.body.appendChild(div);
            this._boxModel = div.offsetWidth === 2;
            document.body.removeChild(div).style.display = "none";
            this._boxModelSet = true;
        }
        return this._boxModel;
    },

    _mouseover_fix : function () {
        if (axt._time_out) {
            window.clearTimeout(axt._time_out);
            axt._time_out = null;
            return false;
        }
    },
    
    showTracks : function () {
        var el = axt.body.getElementsByTagName("ul")[1];
        this.show(el);
        this.moreHeight(el.parentNode.offsetHeight);
        this.updateTracks();
    }, 
    
    hideTracks : function () {
        var el = axt.body.getElementsByTagName("ul")[1];
        axt.hide(el);
        axt.normalHeight();
    },
    
    _mouseout : function () { 
        axt._time_out = window.setTimeout(axt.hideTracks, 300);
    },
    
    _mouseover : function () {
        if (axt._time_out) {
            window.clearTimeout(axt._time_out);
            axt._time_out = null;
        }
        axt.showTracks();
    },
    
    getPlayer : function () {
        if (!this._player) {
            this._player = (window["ax_player"] && typeof window["ax_player"].Play != "undefined") ? window["ax_player"] : document.getElementById("ax_player");
        }
        return this._player;
    },
    
    play : function (url, el) {
        this.getPlayer();
        if (!this._player) return;
        if (this._playing == el) {
            this.pause(el);
            return;
        }
        else if (this._playing) {
            this.pause(this._playing);
        }
        if (this._player.GetVariable("file") != url) {
            this._player.SetVariable("autoStart", "true");
            this._player.SetVariable("file", url);
            this._player.GotoFrame(0);
            this._player.Play();
            this._playing = el;
            el.className =+ "playing";
            //el.innerHTML = this.T['pause'];
        } else {
            this._player._play()
            this._playing = el;
            el.className =+ "playing";
            //el.innerHTML = this.T['pause'];
        }
    },
    
    pause : function (el) {
        if (!this._player) return;
        this._player._pause();
        this._playing = null;
        el.className = el.className.replace(/\s?playing/, "");
        //el.innerHTML = this.T['play'];
    },

    _onstart : function (track) {
        var el = this.getTrackElement(track);
        if (el) el.className = "playing";
        if (el && !this._playing)
            this._playing = el;
    },

    _onpause : function (track) {
        var el = this.getTrackElement(track);
        if (el) el.className = el.className.replace(/\s?playing/, "");
    },
    
    _onfinish : function (track) {
        if (this._samples.length > 1) {
            for (var i=0; i < this._samples.length; i++) {
                var s = this._samples[i];
                if (s == track && i == (this._samples.length - 1)) {
                    i = 0;
                    break;
                }
                else if (s == track){
                    i++;
                    break;
                }
            }
            var el = this.getTrackElement(this._samples[i]);
            this.play(this._samples[i], el);
        }
        if (this._playing) {
            el = this._playing;
            this._playing = null;
            el.className = "";
            //el.innerHTML = this.T['play'];
        }
    },
    
    getTrackElement : function (url) {
        var tracks = this.body.getElementsByTagName("a");
        var el = null;
        for (var i=0; i<tracks.length; i++) {
            if (tracks[i].getAttribute("_url") == url) {
                el = tracks[i];
                break;
            }
        }
        return el;
    },
    _get : function (index, el) {
        if (el) {
            p = el.parentNode.getElementsByTagName("li");
            for (var i = 0; i < p.length; i++) {
                p[i].className = "";
            }
            el.className = "ax-current";
        }
        this.get(this._searches[index]);
        this._player = null;
        if (el.parentNode.parentNode.className == "ax-footer") {
            var f = this.footer.firstChild;
            this.slideLeft(f, 10000, (this._footer_start_left-2)-(index*30));
        }
    },
    
    // SEARCH
    get : function (search, callback) {
        if (!document.getElementById) return;
        var base = this._domain + "/api/products/?";
        this._details = this._player = null;
        if (search.length && search.length > 1 && this._searches.length == 0) {
            this.container.className = "ax-multi";
            this._searches = search;
            this._current = 0;
            search = this._searches[0];
        }
        else if (search.length && search.length == 1) {
            search = search[0];
        }
        if (this._searches.length > 1) {
            this.body.style.height = (this.height-36)+"px";
        }
        var params = [];
        if (search["cover"])
            this.cover = search["cover"];
        if (search["artist"])
            params.push("artist=" + search['artist']);
        if (search["product"])
            params.push("product=" + search['product']);
        if (search["type"])
            params.push("type=" + search['type']);
        if (callback)
            this.callback = callback;
        params.push("callback=axt.loaded");
        params.push(this.version);
        
        this.load(base + params.join("&"));
    },
    
    showBasket : function () {
        var spans = this.body.getElementsByTagName("span");
        if (spans[0].className == "opened")
            this.toggleTracks(spans[0], "up");
        this.update();
    },
    
    hideBasket : function () {
        this.hide(this.basket);
        if (!this._items.length) {
            this.headerBasket.innerHTML = "";
            this.hide(this.headerBasket);
            this.show(this.helpLink);
        }
        this.header.className = "ax-header";
    },
    
    update : function () {
        var base = this._domain + "/api/basket/?add="; 
        var total = 0;
        var ids = []
        
        for (var i=0; i < this._items.length; i++) {
            total += (this._items[i][2] * this._items[i][1]);
            ids.push([this._items[i][0], this._items[i][3]]);
        }
        total = this.formatPrice(total/100);
        var return_url = document.location.href;
        if (window.parent != window) {
            try {
                return_url = window.parent.document.location.href;
            } catch (e) {}
        }
        var prods = [];
        for (var i=0; i<ids.length; i++) {
            prods.push(ids[i][1] ? ids[i][0] +":"+ ids[i][1] : ids[i][0]);
        }
        var html = [];
        html.push("<div><h3>" + this.T['selected_products'] + "</h3><ul>");
        if (this._items.length) {
            for (var i=0; i < this._items.length; i++) {
                html.push("<li><span class=\"ax-title\">" + this._items[i][4] + "</span><a href=\"#\" onclick=\"axt.remove("+ this._items[i][0] + ", "+ this._items[i][3] +"); return false;\" title=\""+ this.T["remove"]+ "\">X</a><span>" + this.formatPrice(this._items[i][2]/100) + "&euro;</span></li>");
            }
        }
        else {
            html.push("<li>" + this.T["no_selected_products"] + "</li>");            
        }
        html.push("</ul><p class=\"ax-total\">" + this.T['total'] + ": " + total + "&euro;</p>")
        html.push("<p><strong><a href=\"" + base + prods.join(',') + "&return=" + return_url + "\">&raquo; " + this.T['checkout'] + "</a></strong></p>");
        html.push("<p class=\"ax-note\">" + this.T['powered'] + "</p></div>");
        this.basket.innerHTML = html.join("");
        this._fixLinks(this.basket);
        this.hide(this.helpLink);
        this.header.className += " ax-opened";
        var hh = this.header.offsetHeight;
        this.basket.style.top = hh + "px";
        w = this.width - 4
        if (this._isIE() && !this._isBoxModel()) w = w+2;
        this.basket.style.width = w + "px";
        this.show(this.basket);
        this.basket.style.height = "auto";
        this.normalHeight();
        this.moreHeight(this.basket.offsetHeight-1, this.basket);
    },
    
    selectTrack : function (el) {
        if (el.className == "ax-select") {
            el.className = "ax-select ax-selected";
        } else {
            el.className = "ax-select";
        }
    },
    
    updatePrice : function (id) {
        var total = 0;
        var s = this.T['no_products'];
        
        for (var i=0; i < this._items.length; i++) {
            total += (this._items[i][2] * this._items[i][1]);
        }
        total = this.formatPrice(total/100);
        var l = this._items.length;
        if (l) {
            s = l + " " + ((l == 1) ? this.T['product_selected'] : this.T['products_selected']);
            s += " (" + total + " &euro;" + ")";
        }
        this.headerBasket.innerHTML = s;
        this.hide(this.helpLink);
        this.show(this.headerBasket);
    },
    
    updateTracks : function () {
        var links = this.body.getElementsByTagName("a");
        for (var i=0; i < links.length; i++) {
            if (links[i].className.indexOf("ax-selected") > -1)
                links[i].className = "ax-select";
        }
        for (var i=0; i < this._items.length; i++) {
            if (this._items[i][0] && this._items[i][3]) {
                var t = document.getElementById("ax-title-" + this._items[i][0] + ":" + this._items[i][3]);
                this.selectTrack(t.parentNode.getElementsByTagName("a")[1]);
            }
        }
    },
    
    remove : function (id, track) {
        for (var i=0; i < this._items.length; i++) {
            if (track && this._items[i][1] && this._items[i][0] == id && this._items[i][3] == track) {
                this._items.splice(i, 1);
            } else if (this._items[i][0] == id && !this._items[i][3] && !track){
                this._items.splice(i, 1);
            }
        }
        this.updatePrice();
        this.update();
    },
    
    add : function (id, track, show, el) {
        var found = false;
        for (var i=0; i < this._items.length; i++) {
            if (track && this._items[i][0] == id && this._items[i][3] == track) {
                found = true;
            }
            else if (!track && this._items[i][0] == id) {
                found = true;
            }                
        }
        if (!found) {
            var s = null
            var find = track ? id+":"+track : id;
            s = document.getElementById("ax-price-" + find).innerHTML;                
            var price = s ? this.getPrice(s) : 0;
            t = document.getElementById("ax-title-" + find).innerHTML;                
            this._items.push([id, 1, price, track, t]);
        }
        this.updatePrice();
        if (show) {
            this.hideTracks();
            this.update();
        }
        if (el) this.selectTrack(el);
    },
    
    getPrice : function (s) {
        return parseFloat(s.split(' ')[0].replace(',', '.'))*100;
    },
    
    formatPrice : function (f) {
        s = String(f).replace('.', ',');
        if (s.split(",").length < 2) 
            return s + ",00";
        else if (s.split(",")[1].length < 2) 
            return s + "0";
        else
            return s;
    },
    
    toggleTracks : function (p, dir) {
        if (!this._details)
            this._details = p.parentNode.parentNode;
        el = this._details.getElementsByTagName("ul")[0];
        
        if (p.className != "opened" || dir == "down") {
            //this.header.style.display = "none";
            p.className = "opened";
            this.slideDown(el, 1000);
        }
        else if (!dir || dir != "down") {
            //this.header.style.display = "block";
            p.className = "";
            this.slideUp(el, 1000);
        }
    },
    toggleHelp : function (el) {
        if (this.header.className == "ax-header")
            this.showHelp(el);
        else
            this.hideHelp(el);
    }, 
    
    showHelp : function (el) {
        this.helper.innerHTML = "<div><p>" + this.T['help_text'] + " </p><p><strong><a href=\"\" onclick=\"axt.hideHelp(); return false\">" + this.T["continue_shopping"] + "</a></strong></p></div>";
        this.header.className += " ax-opened";
        this.moreHeight(this.helper.offsetHeight, this.helper);
        var h = this.header.offsetHeight;
        this.helper.style.top = h + "px";
        var w = this.width - 4;
        if (this._isIE() && !this._isBoxModel()) w = w+2;
        this.helper.style.width = w + "px";
        this.show(el);
        this.show(this.helper);
    }, 
    
    hideHelp : function (el) {
        this.header.className = "ax-header";
        this.header.style.height = "auto";
        this.hide(this.helper);
    }, 
    
    show : function (el) {
        el.style.display = "block";
    },

    hide : function (el) {
        el.style.display = "none";
    },
    

    footerScroll : function (dir, el) {
        if(el.className.search("ax-disabled") > -1) return;
        var el = this.footer.firstChild;
        var l = el.offsetLeft-2;
        if (dir == "left")
            this.slideLeft(el, 100, l+30);
        if (dir == "right")
            this.slideLeft(el, 100, l-30);
    },

    normalHeight : function () {
        if (this.header.className.indexOf("ax-tracks-opened") > -1)
            this.header.className = "ax-header";
        var footer = this._searches.length ? 35 : 0;
        if (this.height < this.container.offsetHeight) {
            this.container.style.height = this.height + "px";
            this.body.style.height = (this.height - footer) + "px";
        }
    },
    
    moreHeight : function (endHeight, stretch) {
        var _header = this.header.offsetHeight;
        var header = stretch ? _header : 1;
        var footer = 0;
        var extra = this._searches.length ? 28 : 2;
        
        if (this._isIE() && !this._isBoxModel())
            extra -= 1;
        
        if (this._searches.length && !stretch)
            footer = 35;
        var h = this.height - (header + footer);

        if (this.header.className.indexOf("ax-tracks-opened") == -1 && !stretch && (h - (_header+1) < endHeight))
            this.header.className += " ax-tracks-opened";

        if (h < endHeight) {
            this.container.style.height = (header + footer) + endHeight + "px";
            this.body.style.height = header + endHeight + "px";
        } else if (stretch) {
            stretch.style.height = (this.height - (header + extra)) + "px";
        }
    },
    
    slideLeft : function (el, time, amount) {
        if(this._timer) {
            window.clearInterval(this._timer);
            this._timer = null;
        }
        this._slide(el, "left", amount);
	}, 
	
	slideRight : function (el, time, amount) {},
	
    slideDown : function (el, time) {
        if(this._timer) {
            window.clearInterval(this._timer);
            this._timer = null;
        }
        this._slide(el, "down");
	}, 
	
	slideUp : function (el, time) {
        if(this._timer) {
            window.clearInterval(this._timer);
            this._timer = null;
        }
        this._slide(el, "up")
	},
	
	_updatePrevNext : function (init) {
	    var el = this.footer.firstChild;
	    var lis = el.getElementsByTagName("li");
	    var all = 0;
	    for (var i=0; i < lis.length; i++)
	        all += lis[i].offsetWidth;
	    if (all < this.footer.offsetWidth) {
	        if (this.footer.className == "ax-footer")
	            this.footer.className += " ax-disabled";
	        return;
        }
	    var w = -all;
	    var max_length = 0;
	    if (!this._prev) {
	        var divs = this.footer.getElementsByTagName("div");
	        this._prev = divs[divs.length-2];
	        this._next = divs[divs.length-1];
	    }
	    if (el.offsetLeft > 0 && el.offsetLeft < 10) {
	        this._prev.className += " ax-disabled";
	    } else {
            this._prev.className = "ax-prev";
        }
 	    if (el.offsetLeft < (w))
	        this._next.className += " ax-disabled";
	    else
            this._next.className = "ax-next";
        if (init) {
            this._footer_start_left = (this.footer.offsetWidth/2) - 17;
            this.footer.firstChild.style.left = this._footer_start_left + "px";
        }
	},
	
	_slide : function (el, dir, amount) {
	    var t = 100;
	    if (dir == 'down' || dir == 'up') {
            this._endHeight = parseInt(el.style.height);
            var details = parseInt(this._details.offsetHeight);
            if (isNaN(this._endHeight)) {
                el.style.visibility = "hidden";
                el.style.display = "block";
                el.style.height = "auto";
                this._endHeight = parseInt(el.offsetHeight);
                el.style.visibility = "visible";
            }
            if (dir == 'down') {
                var maxHeight = this.height - (parseInt(this.header.offsetHeight) + details + 2);
                
                if (this._endHeight > maxHeight) {
                    this.container.style.height = (this.height + (this._endHeight-maxHeight)) + "px";
                    this.body.style.height = (this.height + (this._endHeight-maxHeight)) + "px";
                }
            } else {
                this.container.style.height = this.height + "px";
                this.body.style.height = this.height + "px";
            }
        } else {
            this._fromLeft = parseInt(el.offsetLeft)-4;
            this._endLeft = amount;
            el.style.left = this._fromLeft + "px";
            t = 250;
        }
        this._startTime = new Date().getTime();

        if (dir == "down"){
            el.style.height = "1px";
        }
        
        el.style.display = "block";
        this._timer = window.setInterval(function () { axt._slider(el, dir, t)}, 25);
	},
	
	_slider : function (el, dir, time) {
        var elapsed = new Date().getTime() - this._startTime;
        
        if (dir == "left" || dir == "right") {
            if (elapsed > time) {
                window.clearInterval(this._timer);
                this._timer = null;
                el.style.left = this._endLeft + "px";
                this._updatePrevNext();
            }
            else {
                var c = (this._fromLeft > this._endLeft) ? (this._fromLeft-this._endLeft) : (this._endLeft-this._fromLeft);
                var d = Math.round(this.curve(elapsed / time) * c);
                if (this._fromLeft > this._endLeft) {
                    d = this._fromLeft-d;
                }
                else {
                    d = this._fromLeft+d;
                }
                el.style.left = d + "px";
            }            
        }
        else {
            if (elapsed > time) {
                window.clearInterval(this._timer);
                this._timer = null;
                if(dir == "up")
                    el.style.display = "none";
                el.style.height = this._endHeight + "px";
            }
            else {
                var d = Math.round(this.curve(elapsed / time) * this._endHeight);
                if(dir == "up")
                    d = this._endHeight - d;
                el.style.height = d + "px";
            }
        }
	},
	
	curve : function (i) {
	    return (1-Math.cos(i*Math.PI)) / 2;
	},
	
    loadCss: function(url) {
        css = document.createElement("link");
        css.rel = "stylesheet";
        css.type = "text/css";
        css.href = url;
        document.getElementsByTagName('head')[0].appendChild(css);
    },
    
    _get_cache_key : function (url) {
        for (var i=0; i < this._searches.length; i++) {
            if (this._searches[i] == url)
                break;
        }
        return i
    },
    
    load : function (url) {
        this._loading_url = url;
        if (this._cache[url]) {
            this.loaded(this._cache[url]);
            return;
        }
        this.container.className += " ax-loading";
        script = document.createElement("script");
        script.setAttribute("type", "text/javascript");
        script.setAttribute("src", url);
        document.getElementsByTagName('head')[0].appendChild(script);
    },
    
    loaded : function (data) {
        if (!this._cache[this._loading_url]) {
            this._cache[this._loading_url] = data;
            this._loading_url = null;
        }
        this.container.className = this.container.className.replace(/\s?ax-loading\s?/, "");
        if (data.products && (this._searches.length > 1 && (this._loaded < 1) || this._loaded == this._searches.length)) {
            this.body.innerHTML = this.createHTML(data);
            this._fixLinks(this.body);
            if (this._searches.length > 1 && (this._loaded < 1)) {
                this._footerHTML = this._createProductHTML(data["products"][0], data["artist"], true);
                this._footerHTML = this._footerHTML.replace(" onclick", " class=\"ax-current\" onclick")
            }
        } else if (this._footerHTML){
            this._footerHTML += this._createProductHTML(data["products"][0], data["artist"], true);
        }
        
        if (data.product) {
            var current_item = document.getElementById("ax-" + data.product.id);
            var details = current_item.getElementsByTagName("div")[0];
            current_item.className = "ax-current";
            details.innerHTML = this.createHTML(data);
            this._fixLinks(details);
        }
        
        if (this._searches.length > 1 && this._loaded < this._searches.length) {
            this._loaded++;
            if (this._loaded < this._searches.length)
                this.get(this._searches[this._loaded]);
        }
        
        if (this._loaded == this._searches.length && this._footerHTML) {
            var w = (this._isIE() && !this._isBoxModel()) ? this.body.offsetWidth : this.body.offsetWidth - 2;
            this.footer.style.width = w + "px";
            this.footer.innerHTML = this.createFooterHTML(this._footerHTML);
            this._updatePrevNext(true);
            this._footerHTML = null;
        }
        if (this.callback) {
            this.callback();
            this.callback = null;
        }
    },
    
    _tag : function (tag, root) {
        if (!root) root = this.container;
        return root.getElementsByTagName(tag);
    },
    
    _fixLinks : function (root) {
        if (!root) root = this.container;
        var links = root.getElementsByTagName("a");
        for (var i=0; i < links.length; i++)
            links[i].target = "_top";        
    },
    
    _flash : function (url) {
        var _fix = " onmouseover=\"axt._mouseover_fix();\"";
        var _flash_embed = "<embed id=\"ax_player\" width=\"16\" height=\"16\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" wmode=\"transparent\" src=\"" + this._domain + "/images/player.swf?file=" + url + "&" + this.version + "\"" + _fix + "/>";
        var _flash_object = "<object id=\"ax_player\" width=\"16\" height=\"16\" type=\"application/x-shockwave-flash\"" + _fix + "><param name=\"movie\" value=\"" + this._domain + "/images/player.swf?file=" +  url + "&" + this.version + "\"/><param name=\"allowscriptaccess\" value=\"always\"/><param name=\"wmode\" value=\"transparent\"/></object>";
        return (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) ? _flash_embed : _flash_object;
    },
    
    createFooterHTML : function (data) {
        html = "<ul class=\"ax-products\">" + data + "</ul><div class=\"ax-prev\" onclick=\"axt.footerScroll('left', this);\"></div><div class=\"ax-next\" onclick=\"axt.footerScroll('right', this);\"></div>";
        return html;
    },
    
    _createProductHTML : function (p, artist, footer) {
        var html = [];
        var cover = this._domain + p.cover;
        if (!footer) {
            if (this.cover)
                cover = this.cover;
            else if (this.width > 200 && parseInt(p.id) > 70000)
                cover = cover.replace("thumb", "big");
            else if (this.width > 200)
                cover = cover.replace("thumb", "full");
            else if (this.width > 100)
                cover = cover.replace("thumb", "normal");
        }
        style = (p.length > 1) ? "class=\"ax-multiple\" " : "";
        if (footer) {
            html.push("<li id=\"ax-" + p.id + "\" " + style + " onclick=\"axt._get(" + this._loaded + ", this)\">");
            html.push("<img src=\"" + cover + "\" alt=\"\">");
        }
        else {
            html.push("<li id=\"ax-" + p.id + "\" " + style + "style=\"background: transparent url(" + cover + ") no-repeat 50% 100%;\">");
        }
        var mouse = "";
        if (!footer)
            mouse = " onmouseover=\"axt._mouseover();\" onmouseout=\"axt._mouseout();\""
        html.push("<div class=\"ax-details\"" + mouse + ">");
        style = "";
        if (this.font) style = " style=\"font-size:" + parseInt(this.font)+ "px \"";
        html.push("<h3 class=\"ax-product\"" + style +"><span onclick=\"axt.toggleTracks(this);\" id=\"ax-title-" + p.id + "\">" + artist.name + ": " + p.title + "</span></h3>");
        if (p.tracks && p.tracks.length) {
            html.push("<ul class=\"ax-tracks\">");
            this._available_tracks = [];
            this._samples = [];
            t = p.tracks;
            for (var e=0; e < t.length; e++) {
                if (t[e].price && this.tracks)
                    var alt = (e % 2 == 0) ? " class=\"ax-alternate ax-selectable\"" : " class=\"ax-selectable\"";
                else
                    var alt = (e % 2 == 0) ? " class=\"ax-alternate\"" : "";

                if (t[e].sample)
                    this._samples.push(t[e].sample);

                html.push("<li" + alt + ">");
                if (t[e].sample)
                    html.push("<a href=\"#\" _url=\"" + t[e].sample + "\" id=\"ax-title-"+ p.id +":" + (e+1) + "\" onclick=\"axt.play('" + t[e].sample + "', this); return false;\" title=\"" + t[e].title + " | "+ this.T["duration"] + " " + t[e].duration  + "\">");
                else
                    html.push("<span class=\"ax-title\" id=\"ax-title-"+ p.id +":" + (e+1) + "\" title=\"" + t[e].title + " | "+ this.T["duration"] + " " + t[e].duration + "\">");
                html.push(t[e].title);
                
                if (t[e].sample)
                    html.push("</a>");
                else
                    html.push("</span>");

                if (t[e].price && this.tracks) {
                    html.push("<a href=\"#\" class=\"ax-select\" onclick=\"axt.add('" + p.id + "'," + (e+1) + ", false, this); return false;\" title=\""+ this.T["select_track"] + " (" + t[e].price + ")"+ "\"><span>" + this.T['buy'] + "</span><span class=\"ax-price\" id=\"ax-price-"+ p.id+":"+(e+1)+"\">" + t[e].price + "</span></a>");
                    this._available_tracks.push([p.id, (e+1), t[e].price]);
                    //this.selectTrack(p.id, (e+1));
                }
                html.push("</li>");
            }
            html.push("</ul>");
        }
        if (p.release_in)
            html.push("<div class=\"ax-info ax-unreleased\"><p>");
        else 
            html.push("<div class=\"ax-info\"><p>");

        html.push("<span class=\"ax-type\">" + p.type + "</span>");
    
        if (p.restriction)
            html.push("<span class=\"ax-restriction\">" + p.restriction + "</span>");
        if (p.release_in) {
            html.push("<span class=\"ax-released\">" + this.T['released_in_1'] + p.release_in + this.T['released_in_2'] + "</span></p>");
        } else {
            html.push("<span id=\"ax-price-"+ p.id+"\" class=\"ax-price\">" + p.price + "</span> ");
            html.push("<a href=\"#\" class=\"ax-buy\" onclick=\"axt.add('" + p.id + "', null, true); return false;\">" + this.T['buy'] + "</a></p>");
        }
        
        if (this._samples.length)
            html.push(this._flash(this._samples[0]));
        html.push("</div>");
        html.push("</div>");
        html.push("</li>");
        return html.join("");
    },
    
    createHTML : function (data, footer) {
        var html = [];
        
        if (data.products) {
            p = data.products;
            html.push("<ul class=\"ax-products\">");
            for (var i=0; i < p.length; i++) {                
                html.push(this._createProductHTML(p[i], data.artist, footer))
            }
            html.push("</ul>");
            this.logo.href = this.x + data.artist.url;
        }
        return html.join("");
    },
    _f : {
        buy : "Osta",
        all : "Kaikki",
        play : "Kuuntele",
        pause : "Sammuta",
        products : "tuotteet",
        total : "Yhteens&auml;",
        checkout : "Siirry kassalle",
        select_track : "Valitse kappale",
        selected_products : "Valitut tuotteet",
        back_to_products :  "Takaisin",
        no_selected_products : "Ei valittuja tuotteita",
        help_text : "T&auml;m&auml; on Levykauppa &Auml;x:n palvelu, josta voit ostaa artistin musiikkia hyv&auml;laatuisina MP3:na (320 kbit/s). Maksu suoritetaan Levykauppa &Auml;x:n sivuilla. Kappaleet saat ladattua heti maksutapahtuman j&auml;lkeen.",
        no_products : "Ei tuotteita",
        remove : "Poista tuote",
        products_selected : "tuotetta",
        product_selected : "tuote",
        released_in_1 : "Viel&auml; ",
        released_in_2 : "",
        or_continue : "tai jatka ostoksia",
        continue_shopping : "Jatka ostoksia",
        duration : "Kesto",
        x : "Levykauppa &Auml;x",
        cds : "CD:t Levykauppa &Auml;x:st&auml;",
        added : "Tuote lis&auml;tty ostoskassiin",
        powered : "Maksu suoritetaan Levykauppa &Auml;x:n sivuilla"
    }, 
    _e : {
        buy : "Buy",
        all : "All",
        play : "Play",
        pause : "Pause",
        products : "products",
        total : "Total",
        checkout : "Proceed to Checkout",
        select_track : "Select track",
        selected_products : "Selected products",
        back_to_products :  "Back",
        no_selected_products : "No selected products",
        help_text : "This is a service provided by Record Shop X where you can buy good quality MP3's (320 kbit/s). Payment is done at Record Shop X website. You can download tracks immediately when the payment is received.",
        no_products : "No products",
        remove : "Remove product",        
        products_selected : "products",
        product_selected : "product",
        released_in_1 : "In ",
        released_in_2 : "",
        or_continue : "or continue shopping",        
        continue_shopping : "Continue shopping",        
        duration : "Duration",
        x : "Record Shop X",
        cds : "CDs from Record Shop X",
        added : "Product added to your shopping cart",
        powered : "The payment is done on Levykauppa &Auml;x web site"
    }
};

