// -----------------------------------------------------------------------------
// --- MP3 PLAYER Functions
// -----------------------------------------------------------------------------
var strMp3 = "";
var strMp3Status = "init";
var strMp3Id = "";
function initMP3Play(strSWF, w, h) {
        var divCont =  document.getElementById('container');
        if (w<2 && divCont && divCont.style.width && divCont.style.width) {
            w=parseInt( divCont.style.width);
            if (w<1) w=1;
        }
        var soMp3Play = new SWFObject(strSWF, 'jstest', w, h, '8');
        soMp3Play.addParam('allowscriptaccess','sameDomain');
        soMp3Play.addParam('allowfullscreen','false');
        soMp3Play.addVariable('width',w);
        soMp3Play.addVariable('height','1');
        // soMp3Play.addVariable('file', strMp3Url);
        // soMp3Play.addVariable('autostart', 'true');
        soMp3Play.addVariable('javascriptid','jstest');
        soMp3Play.addVariable('enablejs','true');
        soMp3Play.write('container');
    }
    function sendEvent(swf,typ,prm) { 
        thisMovie(swf).sendEvent(typ,prm); 
    };
    function getUpdate(typ,pr1,pr2,swf) { 
    };
    function thisMovie(swf) {
        if(navigator.appName.indexOf("Microsoft") != -1) {
            return window[swf];
        } else {
            return document[swf];
        }
    };
    function loadFile(swf,obj) { 
        thisMovie(swf).loadFile(obj); 
    };  
    

    function ebyMp3Play(x) {
        sendEvent('jstest','playpause');
        strMp3Status='playing';
        strMp3Id = x;
        document.getElementById(x).innerHTML='<img src="'+tradebitURL('')+'/layout-graphics/play-stop.gif" alt="playing" title="playing" width="74" height="19" border="0">';      
    }
    function ebyMp3Stop(x) {
        sendEvent('jstest','stop');
        strMp3Status='stop';
        document.getElementById(strMp3Id).innerHTML='<img src="'+tradebitURL('')+'/layout-graphics/play-start.gif" alt="play" title="play" width="74" height="19" border="0">';      
    }
    function ebyMp3(strFile, x) {
        try {
            var divDebug = document.getElementById("debuglineLog");
	        if (strFile!=strMp3) {
	            if (strMp3Status=='playing') ebyMp3Stop(x);
	            loadFile('jstest', {file: strFile});
	            strMp3 = strFile;
	            ebyMp3Play(x);            
	        } else {
	            if (strMp3Status=='playing') ebyMp3Stop(x);
	            else ebyMp3Play(x);  
	        } 
        } catch (e) {
            if(divDebug) alert(e);
        }
    }
     function ebyMp3ActivateThePlayButtonsOnPage(strCartTxt){
		var arrPlayB = document.getElementsByTagName("img");
		var str="";
		for(var i=arrPlayB.length-1; i>=0; i--) {
		   if (arrPlayB[i].alt=="play button") {
		        var aParent = arrPlayB[i].parentNode;
		        aParent.style.visibility = 'visible';
		        var arrRec = aParent.title.split(",");
		       
		       if (arrRec.length>2 && arrRec.length<6) {
					var idvVid = arrRec[0];
                    var tagId = arrRec[1];
                    var strUrl = arrRec[2];
                    var strShowCart = arrRec.length>3? arrRec[3]: 'y'; // allowed y,n,ck
                    var strPriceTxt = arrRec.length>4? ' '+arrRec[4]: '';
					var strHtml =  "" ;
					if (strUrl.length>0) {
					   strHtml =  "\n<a href=\"javascript:ebyMp3('"+strUrl+"','"+ tagId +"')\"><span id=\""+tagId+"\">"    
								   + aParent.innerHTML
								   + "</span></a>\n";
				    } else {
                       strHtml =  "\n<span id=\""+tagId+"\" style=\"font-size: 14px; color: #020A02;\">"    
                                   + aParent.innerHTML.replace(/<img.*>/gi, '+')
                                   + "</span>\n";				        
				    }
                    //if (str=='') { alert('strCartTxt'+strCartTxt); str='1'; }
					   
			         if (strCartTxt && strShowCart=='y')  {
			             var flyId = ''+i+idvVid;
					       strHtml = "<a href=\"javascript:addToBasket('"+flyId+"','"+idvVid+"')\" id=\"slidingProduct"+flyId+"\" style=\"display: none; position: relative; left: 0px; top: "+(aParent.offsetTop-15)+"px; background-color: #eeeeee;\" title=\"add single item into shopping cart\">["+strCartTxt+strPriceTxt+"]</a>"
					       		   + "<a href=\"javascript:addToBasket('"+flyId+"','"+idvVid+"')\" title=\"add single item into shopping cart"+strPriceTxt+"\"><img src=\"layout-graphics/minicart.gif\" border=\"0\" style=\"margin-bottom:5px;\"></a>"
					       		   + strHtml;
                           aParent.onmouseover = new Function('document.getElementById("slidingProduct'+flyId+'").style.display="inline";' );
                           aParent.onmouseout = new Function('document.getElementById("slidingProduct'+flyId+'").style.display="none"' );
                     } else if (strCartTxt && strShowCart=='ck')  {
			             var flyId = ''+i+idvVid;
					       strHtml = "<a href=\"javascript:addToBasket('"+flyId+"','"+idvVid+"')\" id=\"slidingProduct"+flyId+"\" style=\"display: none; position: relative; left: 0px; top: -5px; background-color: #eeeeee;\" title=\"add single item into shopping cart (7 digital)\">["+strCartTxt+strPriceTxt+"]</a>"
					       		   + "<a href=\"javascript:addToBasket('"+flyId+"','"+idvVid+"')\" style=\"visibility: hidden\" title=\"add single item into shopping cart"+strPriceTxt+"\"><img src=\"layout-graphics/minicart.gif\" border=\"0\" style=\"margin-bottom:5px;\"></a>"
					               + strHtml;
                           aParent.onmouseover = new Function('document.getElementById("slidingProduct'+flyId+'").style.display=(document.body.getAttribute("basket")=="n")?"none":"inline";' );
                           aParent.onmouseout = new Function('document.getElementById("slidingProduct'+flyId+'").style.display="none"' );
                     }      					       
					aParent.innerHTML = strHtml;    					
					aParent.title = '';
		        } 		              
		   } 
		}          
     }