// JavaScript Document
            function getFlashObject(movieName) {
                if (window.document[movieName]) {
                    return window.document[movieName];
                }
                if (navigator.appName.indexOf("Microsoft Internet") == -1) {
                    if (document.embeds && document.embeds[movieName])
                        return document.embeds[movieName]; 
                } else {
                    return document.getElementById(movieName);
                }
            }
			
      function onImgError(source) {
      source.src = pixurl;
      source.onerror = "";
      return true;
      }

      
      
      function play(index) {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsPlay", index);
			}
			function pause() {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsPause", "");
			}
			function stop() {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsStop", "");
			}
			function next() {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsNext", "");
			}
			function previous() {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsPrevious", "");
			}
			function mute() {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsVolume", "0");
			}
			function volume(n) {
                var flash = getFlashObject("monFlash");
				flash.SetVariable("player:jsVolume", n);
			}
			var myListener = new Object();
			myListener.onNext = function(url)
			
			{
				console.log(url);
        vidInfo (url);
			}
			
	   function mediaPlay (vmedia){
	   var vcode = vmedia['vcode'];
     play (vcode);
     mediaInfo (vmedia);
     }
    
    function vidInfo(url) {
        var marker = url.lastIndexOf("/") 
        var vtitle = url.slice(marker+1, -4);
        var vimg = '';
        vimg += '<img class="vinfo" src="' + mediaurl + '_thumbs/' + vtitle + '.jpg" alt="' + vtitle + '" title="' + vtitle + '" onerror="onImgError(this)" />';
        var txt = '';
		    txt += '<li><b>Title: </b>' + vtitle + '</li>';        
        if (downloads && vmode && showpro) {
        txt += '<li><a href="' + url + '"> Download </a></li>';
        }
    	 
		var tmpimg = document.getElementById("itmsImg");
		if (tmpimg) { tmpimg.innerHTML = vimg; }
    
    var tmp = document.getElementById("itmsDat");
		if (tmp) { tmp.innerHTML = txt; }
    }
    
  
    function mediaInfo(vmedia) {
	  
     var vcode = vmedia['vcode'];
	   var vtitle = vmedia ['vtitle'];
     var vurl = vmedia['vurl'];
     var vdetails = vmedia['vdetails'];
     var vtags = vmedia ['vtags'];
     var vidid = vmedia ['vidid'];
     var vpix = vmedia ['vpix'];
     var vlink = vmedia ['vlink'];
     var vtype = vmedia ['vtype'];
    
    if (vmedia) {
     var vimg = '';
     vimg += '<img class="vinfo" src="' + vpix + '" alt="' + vtitle + '" title="' + vtitle + '" />';
	   
     var txt = '';
 		 txt += '<li><b>Title: </b>' + vtitle + '</li>';
     if (vdetails){
     txt += '<li><b>Details: </b>' + vdetails + '</li>';
     }
     if (vtags){
     txt += '<li><b>Tags: </b>' + vtags + '</li>';
     }
     if (vidid && showpro){
     txt += '<li><a href="' + siteurl + '/index.php?option=com_videoflow&task=addtolist&id=' + vidid + '&media=' + vtype + '&Itemid=' + vitemid + '&title=' + vtitle +'">Add to My ' + sitename + ' Playlist</a></li>';
	   txt += '<li><a href="' + siteurl + '/index.php?option=com_videoflow&task=removefromlist&id=' + vidid + '&media=' + vtype + '&Itemid=' + vitemid + '&title=' + vtitle +'">Remove from My ' + sitename + ' Playlist</a></li>';
     if (canvasurl){
		 txt += '<li><a href="' + canvasurl + '&task=addfavs&id=' + vidid + '&ftype=' + vtype + '&ftitle=' + vtitle + '&pix=' + vpix + '" onclick="targetBlank(this.href);return false;"> Add to My Facebook Playlist</a></li>';
     }
     }
     if (vidid){
     txt += '<li><a href="' + siteurl + '/index.php?option=com_videoflow&task=email&id=' + vidid + '&Itemid=' + vitemid + '&title=' + vtitle + '&pix=' + vpix + '&no_html=1" onclick="targetBlankpop(this.href);return false;"> Email to a Friend</a></li>';
     }             
     if (downloads && showpro && vmode){
     txt += '<li><a href="' + vurl + '"> Download </a></li>';
		 }
 	   var linktxt = '';
     linktxt += '<h2>Media Link</h2> <div id = "linktext"> <textarea rows="3" cols="30" readonly ="readonly">' + vlink + '</textarea>';

		var tmpimg = document.getElementById("itmsImg");
		if (tmpimg) { tmpimg.innerHTML = vimg; }
    
    var tmp = document.getElementById("itmsDat");
		if (tmp) { tmp.innerHTML = txt; }
		
		if (vidid){
		var tmplink = document.getElementById("linkbox");
		if (tmplink) { tmplink.innerHTML = linktxt; }
    }
	 } 	
  }

  function targetBlank (url) {
    blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
  }
  
  function targetBlankpop (url) {
    blankWin = window.open(url,'_blank','menubar=no,toolbar=no,location=yes,directories=no,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
  }			