var notified=0;
function insertPlayer(targurl)
{
flowplayer("player", "http://www.avc-cvut.cz/flowp/flowplayer-3.0.3.swf", {
  clip: {
    url: targurl,
    provider: 'h264streaming'
  },
//  log: {
//    level: 'debug'
//  },
  plugins: {
    h264streaming: {
      url: 'http://www.avc-cvut.cz/flowp/flowplayer.h264streaming-3.0.5.swf'
    },
    controls: {  
      url: 'http://www.avc-cvut.cz/flowp/flowplayer.controls-3.0.3.swf',  
 
      // which buttons are visible and which not ?  
      play:true,       
      fullscreen:true,  
//      bufferLength:20,
//      autoBuffering:false,
     // scrubber is a well known nickname to the timeline/playhead combination  
      scrubber: true          
    }               
  }
});

}

  function togglePlayerDiv(divid,someid,backid)
{
    if(document.getElementById(divid).style.display == 'none'){
       document.getElementById(divid).style.display = 'block';
	if (notified==0) {
        notifyPlay(someid,backid);
	notified=1;
	}
    }else{
       document.getElementById(divid).style.display = 'none';
    }
  }


function xmlhttpPost(strURL,valid,backid) {

url = strURL;
        // AJAX code for Mozilla, Safari, Opera etc.
     if (window.XMLHttpRequest) {
                  xmlhttp = new XMLHttpRequest();
            //      xmlhttp.onreadystatechange = xmlhttpChange;
                  xmlhttp.open("GET", url+"?id="+valid+"&backid="+backid, true);
                  xmlhttp.send( null );
	}
        // AJAX code for IE
         else if (window.ActiveXObject)  {
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                        if (xmlhttp)
                        {
                                xmlhttp.onreadystatechange = xmlhttpChange;
                                 xmlhttp.open("GET", url+"?id="+valid+"&backid="+backid, true); 
                                xmlhttp.send();
                        }
          }
  
}

function notifyPlay(someid,backid) {
    xmlhttpPost("http://www.avc-cvut.cz/apiplug/playcount.php",someid,backid);
} 