﻿window.addEvent('domready', function() {
    var mainpage = $('mainpage_center_upper_2');
    if ($defined(mainpage)) {
        var mainpage_des = $$('.description');
        mainpage_des.each(function(element) {
            var quotes = new Element('div', {
                'class': 'quotes',
                'html': 'quotation'
            }).inject(element);
        });
    }

    var topheader = $('top');
    if ($defined(top)) {
        topheader.addEvent('click', function() {
            //put whatever you want to happen on click in here
            window.location = 'http://cphrecords.shop2download.com/cgi-bin/WebObjects/TShop.woa/wa/';
        });
    }

    var sampleTrackBtn = $$('.sample a[onclick]');
    if (sampleTrackBtn.length > 0) {
        sampleTrackBtn.set('onclick', '');
        sampleTrackBtn.addEvent('click', function(newWindow) {
            newWindow = window.open(this.href, 'NewWindow', 'width=400, height=350, resizable=no, scrollbars=no, location=no, toolbar=no');
            newWindow.focus();
            return false;
        });
    }


    var displayShow;
    var cate1Div = $('musikStjerner');
    if ($defined(cate1Div)) {
        var aLinks = $('musikStjerner').getElements('a');
        for (var i = 0; i < aLinks.length; i++) {
            if (aLinks[i].href == top.window.location.href) {
                aLinks[i].addClass('current-page');
                displayShow = 0;
            }
        }
    }


    var displayShow;
    var prodWrapVar = $('productView');
    if ($defined(prodWrapVar)) {


        var newInfoVar = new Element('div', {
            //here you set all the element parameters
            'id': 'infoWrap',
            'class': 'element2',
            'styles': {
                //here you set all the style parameters
                'width': '240px',
                'height': 'auto',
                'background-color': 'white',
                'float': 'right',
                'margin-top': '5px'
            }
        });

        var sampleDiv = $('productView').getFirst('div.sample');
        var infoold = $('productView').getFirst('dl.info');
        var pfrolesold = $('productView').getFirst('dl.pf-roles');

        newInfoVar.inject(sampleDiv, 'after');
        pfrolesold.inject(newInfoVar, 'top');
        infoold.inject(newInfoVar, 'top');

        var temp4 = new Element('div', {
            //here you set all the element parameters
            'id': 'headertest',
            'class': 'toggler2',
            'styles': {
                //here you set all the style parameters
                'width': '244px',
                'height': '21px',
                'background-color': 'white',
                'float': 'left',
                'background-image': 'url(/tshop/copenhagenrecords/pointeropen.gif)',
                'background-repeat': 'no-repeat',
                'background-position': 'right',
                'font-family': 'Arial',
                'font-size': '10px',
                'font-weight': 'bold',
                'color': '#a7a6a7',
                'cursor': 'pointer',
                'padding-left': '5px'
            }
        });
        temp4.inject(newInfoVar, 'before');

        //create our Accordion instance
        var myAccordion = new Accordion('div.toggler2', 'div.element2', {
            display: (displayShow),
            alwaysHide: true,
            opacity: true,
            onActive: function(toggler, element) {
                toggler.setStyle('background-image', 'url(/tshop/copenhagenrecords/pointerclose.gif)');
                toggler.setStyle('background-position', 'right');
                toggler.setStyle('background-repeat', 'no-repeat');
                toggler.setStyle('cursor', 'pointer');

            },
            onBackground: function(toggler, element) {
                toggler.setStyle('background-image', 'url(/tshop/copenhagenrecords/pointeropen.gif)');
                toggler.setStyle('background-position', 'right');
                toggler.setStyle('background-repeat', 'no-repeat');
                toggler.setStyle('cursor', 'pointer');
            }
        });




        var newElementVar = new Element('div', {
            'id': 'formatWrap',
            'styles': {
                'width': '240px',
                'height': 'auto',
                'background-color': 'white',
                'float': 'right',
                'margin-top': '10px'
            }
        });





        var formatselectdiv = new Element('div', {
            //here you set all the element parameters
            'id': 'formatselect',
            'styles': {
                //here you set all the style parameters
                'width': '100%',
                'height': 'auto',
                'background-color': '#ececec',
                'float': 'left',
                'paddin-left': '5px',
                'margin-bottom': '3px',
                'background': '#ececec url(/tshop/copenhagenrecords/bgbuyalbum.jpg) no-repeat scroll left top',
                'paddin-top': '20px',
                'margin-top': '13px',
                'display': 'block',
                'position': 'relative'

            }

        });

        var newSelectVar = new Element('select', {
            //here you set all the element parameters
            'id': 'formatWrap',
            'styles': {
                //here you set all the style parameters
                'width': '250px',
                'margin-top': '20px',
                'margin-left': '3px',
                'margin-bottom': '5px',
                'float': 'left'
            }
        });


        formatselectdiv.inject($('productView'), 'after');
        newSelectVar.inject(formatselectdiv, 'top');
        newElementVar.inject(prodWrapVar, 'bottom');

        var newFormatButton = new Element('a', {
            //here you set all the element parameters
            'id': 'formatInfo',
            'href': '/cgi-bin/WebObjects/TShop.woa/wa/PSHelp/entry?entry=formats'
        });

        newFormatButton.addEvent('click', function() {
        newWindow = window.open(this.href, 'NewWindow', 'width=400,height=400,resizable=no,scrollbars=yes, status=no,location=no,toolbar=no,');
        newWindow.focus(); 
        return false;
        });
        newFormatButton.inject(newElementVar, 'top');
        
        var newFormatImg = new Element('img', {
            //here you set all the element parameters
            'id': 'formatInfoimg',
            'width':'108',
            'height': '11',
            'src': '/tshop/copenhagenrecords/button_formatguide.gif',
            'styles': {
            'border': 'none'
            }
        });

        newFormatImg.inject(newFormatButton, 'top');
        
        
        
        

        var showFormat = new Element('div', {
            //here you set all the element parameters
            'id': 'showFormat',
            'styles': {
                //here you set all the style parameters
                'width': '240px',
                'height': '122px',
                'border': 'thin #dddddd dashed',
                'float': 'right',
                'margin': '5px 5px 5px 5px',
                'display': 'none'
            }
        });



        dummy = new Element('option', {
            //here you set all the element parameters
            'id': 'dummy',
            'value': '0',
            'text': 'Vælg format'
        });

        dummy.inject(newSelectVar, 'top');



        var old;
        newSelectVar.addEvent('change', function() {
            if (old != null) {
                old.setStyle('display', 'none');
            }
            if (newSelectVar.options[newSelectVar.selectedIndex].value != 0) {
                showFormat.setStyle('display', 'block');
                var formaetSel = $('downformat' + newSelectVar.options[newSelectVar.selectedIndex].value);
                formaetSel.setStyle('display', 'block');
                old = formaetSel;
            } else {
                showFormat.setStyle('display', 'none');
            }
        });
        showFormat.inject(formatselectdiv, 'bottom');

        var format = $$('dl.productContext');
        var count = 0;

        

        format.forEach(function(item) {
            // count++;
            var formatname = item.getFirst('dd').getElement('a').innerHTML;
            item.set('id', 'downformat' + formatname);

/*
            temp = new Element('div', {
                //here you set all the element parameters
                'id': 'header' + formatname + 'toggler',
                'text': formatname,
                'class': 'toggler',
                'styles': {
                    //here you set all the style parameters
                    'width': '235px',
                    'height': '21px',
                    'background-color': 'white',
                    'float': 'left',
                    'background-image': 'url(/tshop/copenhagenrecords/pointeropen.gif)',
                    'background-repeat': 'no-repeat',
                    'background-position': 'right',
                    'font-family': 'Arial',
                    'font-size': '10px',
                    'font-weight': 'bold',
                    'color': '#a7a6a7',
                    'cursor': 'pointer',
                    'padding-left': '5px'
                }
            });

            temp.inject(newElementVar, 'top');

            temp2 = new Element('div', {
                //here you set all the element parameters
                'id': 'header' + formatname,
                'class': 'element',
                'styles': {
                    //here you set all the style parameters
                    'width': '240px',
                    'height': '110px',
                    'background-color': 'white',
                    'float': 'left',
                    'padding-left': '5px'
                }


            });
            temp2.inject(temp, 'after');


            var bot = new Element('div', {
                //here you set all the element parameters
                'id': 'accheader',
                'styles': {
                    //here you set all the style parameters
                    'width': '240px',
                    'height': '7px',
                    'background-color': 'green',
                    'float': 'left',
                    'background-image': 'url(/tshop/copenhagenrecords/accorditionbot.jpg)',
                    'background-repeat': 'no-repeat',
                    'margin-bottom': '3px'
                }

            });
            bot.inject(temp2, 'bottom');

*/





            item.setStyle('display', 'none');
            item.inject(showFormat, 'bottom');
            formatTemp = new Element('option', {
                //here you set all the element parameters
                'id': 'format' + formatname,
                'value': formatname,
                'text': formatname
            });

            formatTemp.inject(newSelectVar, 'bottom');
	switch(formatname.substr((formatname.length)-6,2))
	{
	case "24":
	newSelectVar.options[0].grab(formatTemp, 'after');
	//$('formatWrap' + count).options[0] = formatTemp;
	//formatTemp.inject(newSelectVar,'top');
	break;
	default:
	newSelectVar.grab(formatTemp, 'bottom');
	//formatTemp.inject($('formatWrap' + count), 'bottom');
	break;
	};

        });
/*
        header = new Element('div', {
            //here you set all the element parameters
            'id': 'accheader',
            'styles': {
                //here you set all the style parameters
                'width': '240px',
                'height': '21px',
                'background-color': 'green',
                'float': 'left',
                'background-image': 'url(/tshop/copenhagenrecords/accorditionheader.jpg)',
                'background-repeat': 'no-repeat',
                'margin-bottom': '3px'
            }

        });
        header.inject(newElementVar, 'top');

        //create our Accordion instance
        var myAccordion = new Accordion('div.toggler', 'div.element', {
            display: (displayShow),
            alwaysHide: true,
            opacity: true,
            onActive: function(toggler, element) {
                toggler.setStyle('background-image', 'url(/tshop/copenhagenrecords/pointerclose.gif)');
                toggler.setStyle('background-position', 'right');
                toggler.setStyle('background-repeat', 'no-repeat');
                toggler.setStyle('cursor', 'pointer');

            },
            onBackground: function(toggler, element) {
                toggler.setStyle('background-image', 'url(/tshop/copenhagenrecords/pointeropen.gif)');
                toggler.setStyle('background-position', 'right');
                toggler.setStyle('background-repeat', 'no-repeat');
                toggler.setStyle('cursor', 'pointer');
            }
        });*/




        //Tableedit !!!! :( :( :( :( :( :( :( :( :( :(

        var trs = $$('table.productsTable tbody tr');
        //var trs = table.getElements('tr');
        //alert(trs)
        var count = 1;
        var count2 = 0;
        var optionName = 1;
        var currentclass = '';

        trs.forEach(function(tr) {
            count2++;
            currentclass = tr.getProperty('class');

            if (currentclass == 'pf-data-contributions') {
                count2 = 0;
                count++;
            } else {
                tr.set('id', 'tr' + count + '' + count2);
                formatnametemp = tr.getElement('td.format').innerHTML;
                tr.getElement('td.format').setStyle('display', 'none');
                if (count2 == 1) {
                    var newSelectTestVar = new Element('select', {
                        //here you set all the element parameters
                        'id': 'formatWrap' + count,
                        'styles': {
                            //here you set all the style parameters
                            'width': '135px',
                            'float': 'left'
                        }
                    });

                    dummy = new Element('option', {
                        //here you set all the element parameters
                        //'id': 'dummy',
                        'value': '0',
                        'text': 'Vælg format'
                    });

                    newTd = new Element('td', {
                });

                newTd.inject(tr, 'bottom');

                dummy.inject(newSelectTestVar, 'top');

                var hmmvirkenokikk;

                newSelectTestVar.onchange = function() {
                    if (hmmvirkenokikk != null) {
                        hmmvirkenokikk.setStyle('display', 'none');
                    }
                    if (newSelectTestVar.options[newSelectTestVar.selectedIndex].value != 0) {
                        var formaetSel = $('td' + newSelectTestVar.options[newSelectTestVar.selectedIndex].value);
                        //alert(formaetSel.getProperty('style'));
                        formaetSel.setStyles({
                        'display': 'block'
                        });
        
                        //alert(formaetSel.getProperty('style'));
                        //formaetSel.style.display = 'block';
                        //formaetSel.set('style', 'display:table-cell');
                        //alert(formaetSel.getProperty('style') + ' h ' + formaetSel.getProperty('class'));
                        hmmvirkenokikk = formaetSel;
                    } else {
                        hmmvirkenokikk.setStyle('display', 'none');
                    }

                };
                
                
                /*
                newSelectTestVar.addEvent('change', function() {
                    if (hmmvirkenokikk != null) {
                        hmmvirkenokikk.setStyle('display', 'none');
                    }
                    if (newSelectTestVar.options[newSelectTestVar.selectedIndex].value != 0) {
                        var formaetSel = $('td' + newSelectTestVar.options[newSelectTestVar.selectedIndex].value);
                        //alert(formaetSel.getProperty('style'));
                        formaetSel.setStyle('display', 'block');
                        //alert(formaetSel.getProperty('style'));
                        //formaetSel.style.display = 'block';
                        //formaetSel.set('style', 'display:table-cell');
                        //alert(formaetSel.getProperty('style') + ' h ' + formaetSel.getProperty('class'));
                        hmmvirkenokikk = formaetSel;
                    } else {
                        hmmvirkenokikk.setStyle('display', 'none');
                    }

                });*/
                newSelectTestVar.inject(newTd, 'bottom');
            } //end if(count2==1)



            //Create new tds for formatinfo

            newTdMaster = new Element('td', {
            'id': 'td' + count + '' + count2,
                'styles': {
                    //here you set all the style parameters
                    //'width': '68px',
                    'display': 'none'
                }
            });
            newTdMaster.setAttribute('rowspan', '3');
            
            newTdMaster.inject($('tr' + count + '' + 1), 'bottom');
     
            newDivWrap = new Element('div', {
            'styles': {
                //here you set all the style parameters
                'margin-left': '2px',
                'width':'62px'
            }
            });
            newDivWrap.inject(newTdMaster, 'top');

            newDivWrapBuy = new Element('div', {
            'styles': {
                //here you set all the style parameters
                'width': 'auto',
                'float': 'right'
            }
            });
            //newDivWrapBuy.innerHTML = tr.getElement('td.buy').innerHTML;
            newDivWrapBuy.grab(tr.getElement('td.buy').getFirst('form'),'top');
            newDivWrapBuy.inject(newDivWrap,'top');

            newDivWrapPrice = new Element('div', {
            'styles': {
                //here you set all the style parameters
                'width': 'auto',
                'float':'right',
                'font-size':'11px',
                'font-weight': 'bold',
                'font-family': 'arial',
                'width': '28px'
            }
            });
            newDivWrapPrice.innerHTML = tr.getElement('td.price').innerHTML;
            newDivWrapPrice.inject(newDivWrap, 'top');

            newDivWrapCurensy = new Element('div', {
            'styles': {
            'float': 'left',
            'font-size': '11px',
            'font-weight': 'bold',
            'font-family': 'arial',
            'width': '28px',
            'margin-left':'3px'
            }
            });
            newDivWrapCurensy.innerHTML = tr.getElement('td.currency').innerHTML;
            newDivWrapCurensy.inject(newDivWrap, 'top');
            /*
            newTable = new Element('table', {
                //here you set all the element parameters
                'border': '1',
                'styles': {
                    //here you set all the style parameters
                    'width': '100%',
                    'background-color': 'blue',
                    'line-height': '30px',
                    'position':'relative',
                    'z-index':'3'
                }
            });

            newTable.inject(newDivWrap, 'top');
            
            newTr = new Element('tr', {
            });

            newTr.inject(newTable, 'top');

            newTr2 = new Element('tr', {
            'colSpan': '2'
            });
            newTr2.inject(newTable, 'bottom');
            */
            tr.getElement('td.currency').setStyle('display','none');
            tr.getElement('td.price').setStyle('display', 'none');
            tr.getElement('td.buy').setStyle('display', 'none');
            

            formatTemp = new Element('option', {
            //here you set all the element parameters
            //'id': 'format' + formatnametemp,
            'value': count + '' + count2,
            'text': formatnametemp
            });
	
	//alert(formatnametemp.substr((formatnametemp.length)-6,2));
	switch(formatnametemp.substr((formatnametemp.length)-6,2))
	{
	case "24":
	$('formatWrap' + count).options[0].grab(formatTemp, 'after');
	//$('formatWrap' + count).options[0] = formatTemp;
	//formatTemp.inject($('formatWrap' + count),'top');
	break;
	default:
	$('formatWrap' + count).grab(formatTemp, 'bottom');
	//formatTemp.inject($('formatWrap' + count), 'bottom');
	break;
	};
        

        //tr.getElement('td.currency').inject(newTdMaster.getElement('table').getFirst('tr'), 'bottom');
        //tr.getElement('td.price').inject(newTdMaster.getElement('table').getFirst('tr'), 'bottom');
        //tr.getElement('td.buy').set('colSpan', '2');
	//tr.getElement('td.buy').inject(newTdMaster.getElement('table').getLast('tr'), 'bottom');

	
	

        

    } //end if row is artistrow
}); //end foreach        
}



var Menu = $('menu');
var upper1 = $('mainpage_center_upper_1');
var upper2 = $('mainpage_center_upper_2');
var Mstjerner = $('musikStjerner');
var bannerDiv1 = new Element('div', {
    //here you set all the element parameters
    'id': 'banner1',
    'styles': {
        //here you set all the style parameters
        'width': '150px',
        'height': '80px',
        'background-image': 'url(/tshop/copenhagenrecords/bannerleft.jpg)',
        'margin-top': '5px'

    }
});
//bannerDiv1.inject(Mstjerner, 'before');

var bannerDiv2 = new Element('div', {
    //here you set all the element parameters
    'id': 'banner1',
    'styles': {
        //here you set all the style parameters
        'width': '150px',
        'height': '80px',
        'background-image': 'url(/tshop/copenhagenrecords/bannerleft1.jpg)',
        'margin-top': '5px'
    }
});
//bannerDiv2.inject(bannerDiv1, 'after');

var bannerDiv3 = new Element('div', {
    //here you set all the element parameters
    'id': 'banner1',
    'styles': {
        //here you set all the style parameters
        'width': '150px',
        'height': '199px',
        'background-image': 'url(/tshop/copenhagenrecords/bannerleft2.jpg)',
        'margin-top': '5px'
    }
});

//bannerDiv3.inject(bannerDiv2, 'after');


var bannerDiv4 = new Element('div', {
    //here you set all the element parameters
    'id': 'banner1',
    'styles': {
        //here you set all the style parameters
        'width': '150px',
        'height': '80px',
        'background-image': 'url(/tshop/copenhagenrecords/bannerleft4.jpg)',
        'margin-top': '5px',
        'margin-bottom': '5px'
    }
});
//bannerDiv4.inject(Mstjerner, 'after');

var rightlist = $('mainpage_right_1');
if ($defined(rightlist)) {
    var bannerright1 = new Element('div', {
        //here you set all the element parameters
        'id': 'bannerright1',
        'styles': {
            //here you set all the style parameters
            'width': '246px',
            'height': '246px',
            //'background-image': 'url(/tshop/copenhagenrecords/bannerright.jpg)',
            //'background-position': '2px 2px',
            'background-color': 'white',
            //'background-repeat': 'no-repeat',
            'padding-left': '2px',
            'padding-top': '2px',
            'margin-bottom': '5px',
            'border': 'solid 1px #b5b5b6'
        }
    });
    bannerright1.inject(rightlist, 'after');
    var playerBannerContent1 = "<a href='/cgi-bin/WebObjects/TShop.woa/wa/PSShop/MusicCollection?id=1780742147' target='_self'><img src='/tshop/copenhagenrecords/bannerright.jpg' border='0' alt='' /></a";
    $('bannerright1').set('html', playerBannerContent1);
}


//}


if ($defined(upper2)) {

    //v1.7
    // Flash Player Version Detection
    // Detect Client Browser type
    // Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
    var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

    function ControlVersion() {
        var version;
        var axo;
        var e;

        // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

        try {
            // version will be set for 7.X or greater players
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
            version = axo.GetVariable("$version");
        } catch (e) {
        }

        if (!version) {
            try {
                // version will be set for 6.X players only
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

                // installed player is some revision of 6.0
                // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
                // so we have to be careful. 

                // default to the first public version
                version = "WIN 6,0,21,0";

                // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
                axo.AllowScriptAccess = "always";

                // safe to call for 6.0r47 or greater
                version = axo.GetVariable("$version");

            } catch (e) {
            }
        }

        if (!version) {
            try {
                // version will be set for 4.X or 5.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                version = axo.GetVariable("$version");
            } catch (e) {
            }
        }

        if (!version) {
            try {
                // version will be set for 3.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                version = "WIN 3,0,18,0";
            } catch (e) {
            }
        }

        if (!version) {
            try {
                // version will be set for 2.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                version = "WIN 2,0,0,11";
            } catch (e) {
                version = -1;
            }
        }

        return version;
    }

    // JavaScript helper required to detect Flash Player PlugIn version information
    function GetSwfVer() {
        // NS/Opera version >= 3 check for Flash plugin in plugin array
        var flashVer = -1;

        if (navigator.plugins != null && navigator.plugins.length > 0) {
            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                var descArray = flashDescription.split(" ");
                var tempArrayMajor = descArray[2].split(".");
                var versionMajor = tempArrayMajor[0];
                var versionMinor = tempArrayMajor[1];
                var versionRevision = descArray[3];
                if (versionRevision == "") {
                    versionRevision = descArray[4];
                }
                if (versionRevision[0] == "d") {
                    versionRevision = versionRevision.substring(1);
                } else if (versionRevision[0] == "r") {
                    versionRevision = versionRevision.substring(1);
                    if (versionRevision.indexOf("d") > 0) {
                        versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                    }
                }
                var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
            }
        }
        // MSN/WebTV 2.6 supports Flash 4
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
        // WebTV 2.5 supports Flash 3
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        // older WebTV supports Flash 2
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
        else if (isIE && isWin && !isOpera) {
            flashVer = ControlVersion();
        }
        return flashVer;
    }

    // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
    function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
        versionStr = GetSwfVer();
        if (versionStr == -1) {
            return false;
        } else if (versionStr != 0) {
            if (isIE && isWin && !isOpera) {
                // Given "WIN 2,0,0,11"
                tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
                tempString = tempArray[1]; 		// "2,0,0,11"
                versionArray = tempString.split(","); // ['2', '0', '0', '11']
            } else {
                versionArray = versionStr.split(".");
            }
            var versionMajor = versionArray[0];
            var versionMinor = versionArray[1];
            var versionRevision = versionArray[2];

            // is the major.revision >= requested major.revision AND the minor version >= requested minor
            if (versionMajor > parseFloat(reqMajorVer)) {
                return true;
            } else if (versionMajor == parseFloat(reqMajorVer)) {
                if (versionMinor > parseFloat(reqMinorVer))
                    return true;
                else if (versionMinor == parseFloat(reqMinorVer)) {
                    if (versionRevision >= parseFloat(reqRevision))
                        return true;
                }
            }
            return false;
        }
    }

    function AC_AddExtension(src, ext) {
        if (src.indexOf('?') != -1)
            return src.replace(/\?/, ext + '?');
        else
            return src + ext;
    }

    function AC_Generateobj(objAttrs, params, embedAttrs) {
        var str = '';
        if (isIE && isWin && !isOpera) {
            str += '<object ';
            for (var i in objAttrs) {
                str += i + '="' + objAttrs[i] + '" ';
            }
            str += '>';
            for (var i in params) {
                str += '<param name="' + i + '" value="' + params[i] + '" /> ';
            }
            str += '</object>';
        }
        else {
            str += '<embed ';
            for (var i in embedAttrs) {
                str += i + '="' + embedAttrs[i] + '" ';
            }
            str += '> </embed>';
        }

        document.write(str);
    }

    function AC_FL_RunContent() {
        var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
        AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
    }

    function AC_SW_RunContent() {
        var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
        AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
    }

    function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
        var ret = new Object();
        ret.embedAttrs = new Object();
        ret.params = new Object();
        ret.objAttrs = new Object();
        for (var i = 0; i < args.length; i = i + 2) {
            var currArg = args[i].toLowerCase();
            switch (currArg) {
                case "classid":
                    break;
                case "pluginspage":
                    ret.embedAttrs[args[i]] = args[i + 1];
                    break;
                case "src":
                case "movie":
                    args[i + 1] = AC_AddExtension(args[i + 1], ext);
                    ret.embedAttrs["src"] = args[i + 1];
                    ret.params[srcParamName] = args[i + 1];
                    break;
                case "onafterupdate":
                case "onbeforeupdate":
                case "onblur":
                case "oncellchange":
                case "onclick":
                case "ondblclick":
                case "ondrag":
                case "ondragend":
                case "ondragenter":
                case "ondragleave":
                case "ondragover":
                case "ondrop":
                case "onfinish":
                case "onfocus":
                case "onhelp":
                case "onmousedown":
                case "onmouseup":
                case "onmouseover":
                case "onmousemove":
                case "onmouseout":
                case "onkeypress":
                case "onkeydown":
                case "onkeyup":
                case "onload":
                case "onlosecapture":
                case "onpropertychange":
                case "onreadystatechange":
                case "onrowsdelete":
                case "onrowenter":
                case "onrowexit":
                case "onrowsinserted":
                case "onstart":
                case "onscroll":
                case "onbeforeeditfocus":
                case "onactivate":
                case "onbeforedeactivate":
                case "ondeactivate":
                case "type":
                case "codebase":
                case "id":
                    ret.objAttrs[args[i]] = args[i + 1];
                    break;
                case "width":
                case "height":
                case "align":
                case "vspace":
                case "hspace":
                case "class":
                case "title":
                case "accesskey":
                case "name":
                case "tabindex":
                    ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
                    break;
                default:
                    ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
            }
        }
        ret.objAttrs["classid"] = classid;
        if (mimeType) ret.embedAttrs["type"] = mimeType;
        return ret;
    }






    var bannerDiv5 = new Element('div', {
        //here you set all the element parameters
        'id': 'banner1',
        'styles': {
            //here you set all the style parameters
            'width': '514px',
            'height': '211px',
            'background-image': 'url(/tshop/copenhagenrecords/banner1.jpg)',
            'margin-bottom': '5px'
        }
    });
    //bannerDiv5.inject(upper1, 'before');

    var bannecenter = new Element('div', {
        //here you set all the element parameters
        'id': 'bannerCenterting',
        'styles': {
            //here you set all the style parameters
            'width': '507px',
            'height': '88px',
            // 'background-image': 'url(/tshop/copenhagenrecords/spleenunited.jpg)',
            //'background-position': '2px 2px',
            //'background-color': 'white',
            //'background-repeat': 'no-repeat',
            'margin-bottom': '5px',
            'margin-top': '5px',
            'padding-left': '2px',
            'padding-top': '2px',
            'border': 'solid 1px #b5b5b6'
        }
    });
    bannecenter.inject(upper2, 'after');

    var playerBannerContent = "<a href='/cgi-bin/WebObjects/TShop.woa/wa/PSShop/MusicCollection?id=1780733924' target='_self'><img src='/tshop/copenhagenrecords/spleenunited.jpg' border='0' alt='' /></a";
    $('bannerCenterting').set('html', playerBannerContent);













    var bannerDiv7 = new Element('div', {
        //here you set all the element parameters
        'id': 'banner1',
        'styles': {
            //here you set all the style parameters
            'width': '511px',
            'height': '300px',
            'margin-top': '5px',
            'margin-bottom': '5px',
            'outline': 'none'
            //  'background-color': '#000000'
        }
    });
    bannerDiv7.inject(upper1, 'before');

    /*
    var flash2 = new Element('object', {
    //here you set all the element parameters
    'classid': 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
    'codebase': 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
    'width': '511',
    'height': '300',
    'id': 'iTunesAlbumArt'
    });
    flash2.inject(bannerDiv7, 'after');

    var param1 = new Element('param', {
    //here you set all the element parameters
    'name': 'allowScriptAccess',
    'value': 'sameDomain'
    });
    var param2 = new Element('param', {
    //here you set all the element parameters
    'name': 'allowFullScreen',
    'value': 'false'
    });
    var param3 = new Element('param', {
    //here you set all the element parameters
    'name': 'movie',
    'value': 'iTunesAlbumArt.swf'
    });
    var param4 = new Element('param', {
    //here you set all the element parameters
    'name': 'quality',
    'value': 'high'
    });
    var param5 = new Element('param', {
    //here you set all the element parameters
    'name': 'bgcolor',
    'value': '#000000'

    });
    var embed = new Element('embed', {
    //here you set all the element parameters
    'src': '/tshop/copenhagenrecords/iTunesAlbumArt.swf',
    'quality': 'high',
    'bgcolor': '#000000',
    'width': '511',
    'height': '300',
    'name': 'iTunesAlbumArt',
    'allowScriptAccess': 'sameDomain',
    'allowFullScreen': 'false',
    'type': 'application/x-shockwave-flash'
    });
    param1.inject(flash2, 'top');
    param2.inject(flash2, 'top');
    param3.inject(flash2, 'top');
    param4.inject(flash2, 'top');
    param5.inject(flash2, 'top');
    embed.inject(flash2, 'top');
    flash2.inject(bannerDiv7, 'top');
    */

    var obj = new Swiff('/tshop/copenhagenrecords/iTunesAlbumArt.swf', {
        id: 'iTunesAlbumArt',
        width: 511,
        height: 300,
        bgcolor: '#000000',
        name: 'iTunesAlbumArt',
        params: {
            bgcolor: '#000000',
            allowScriptAccess: 'sameDomain',
            allowFullScreen: 'false',
            quality: 'high',
            outline: 'false'
        },
        vars: {

    },
    callBacks: {
    //   load: myOnloadFunc
}
});

obj.inject(bannerDiv7, 'top');



/*AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '511',
'height', '300',
'src', 'iTunesAlbumArt',
'quality', 'high',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'iTunesAlbumArt',
'bgcolor', '#000000',
'name', 'iTunesAlbumArt',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'iTunesAlbumArt',
'salign', ''
); //end AC code*/

}
/*
PFPortal.app.addEvent('offeringsLoaded', function(offerings) {
$$('.detailed.movie').forEach(function(item) {
var offerings = item.getElement('.pf-offerings');
var firstChildOfferings = offerings.getElement(':first-child');
var firstheader = offerings.getElement('h2');
if (firstChildOfferings = firstheader) {
offerings.getElements('h3').addClass('offering_toggler');
offerings.getElements('dl').addClass('offering_element');

var leftAccordion = new Accordion('h3.offering_toggler', '.offering_element', {
display: 1,
opacity: true,
onActive: function(toggler, element) {
toggler.setStyle('background-image', 'url(/tshop/bilka/movie_title_bg_down.gif)');
toggler.setStyle('background-repeat', 'no-repeat');
toggler.setStyle('color', '#ffffff');
},
onBackground: function(toggler, element) {
toggler.setStyle('background-image', 'url(/tshop/bilka/movie_title_bg_up.gif)');
toggler.setStyle('background-repeat', 'no-repeat');
toggler.setStyle('color', '#ffffff');
}
});
}
});
});
*/
var links = $$('a[rel=invoice]').get('href');
if (links.length > 0) {
   new Request.JSON({
    'url' : links [0],
    'onSuccess' : function (invoice) {
	    var htmlTemp = '<script language="JavaScript" type="text/javascript">'+
	    '<!-- var google_conversion_id = 1029675479; var google_conversion_language = "da"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; var google_conversion_label = "mE-WCLe1mQEQ17P-6gM"; var google_conversion_value = 0; //-->'+
	    '</script><script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"></script><noscript><img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/1029675479/?label=mE-WCLe1mQEQ17P-6gM&amp;guid=ON&amp;script=0"/></noscript>';
	    var hiddenCode = new Element('div', {id: 'hiddenCode'}).inject($('assets'), 'after');
	    hiddenCode.set('html', htmlTemp);
	
		invoice.formattedTotalPrice = invoice.total / 100.0;
		var orderID = invoice.identifier;
		var Total = invoice.formattedTotalPrice;
		try{
		    var pageTracker = _gat._getTracker("UA-2570311-25");
			pageTracker._trackPageview();
		    pageTracker._addTrans(
			     orderID,
			     "",
			     Total,
			     "",
			     "",
			     "",
			     "",
			     ""
			);
				
			pageTracker._trackTrans();
		   } catch(err) {}
    }
   }).get();	
}


});
