
function videoMarker(id){this.seconds=0;this.videoID=null;this.startTime=null;this.counterEnabled=false;this.reportThreshold=5;this.remote=null;this.reported=false;this.currtime=null;this.player='';this.playerURL="";this.onStart=function(){}
this.onTreshold=function(){}
this.setOnstart=function(callback){this.onStart=callback;}
this.setOnTreshold=function(callback){this.onTreshold=callback;}
if(typeof(videoMarker.instances)=='undefined'){videoMarker.instances=new Array();}
this.videoID=id;videoMarker.instances[id]=this;this.changeMarker=function(id){this.processMarker();this.seconds=0;this.videoID=id;this.startTime=null;this.counterEnabled=false;this.reportThreshold=5;this.remote=null;this.reported=false;this.currtime=null;this.player='';this.playerURL="";this.onStart=function(){}
this.onTreshold=function(){}}
this.startCount=function(){if(typeof(this.onStart)=='function'){this.onStart(this.videoID);}
this.timerEnabled=true;this.startTime=(new Date()).getTime();this.playerURL=this.player.getClip().url;}
this.stopCount=function(){if(this.timerEnabled){this.seconds+=(((new Date()).getTime()-this.startTime)/1000);}
if(typeof(this.onTreshold)=='function'&&this.seconds>=this.reportThreshold){this.onTreshold(this.videoID);}
this.timerEnabled=false;}
this.processMarker=function(){this.stopCount();if(!this.reported&&this.seconds>=this.reportThreshold){this.remote=new Image(1,1);this.remote.src="http://emarketed.net/tools/markview.php?id="+this.videoID+"&time="+this.seconds+"&video="+this.playerURL;this.reported=true;}}
this.showMarker=function(){alert("Currently at: "+(((new Date()).getTime()-this.startTime)/1000)+" Seconds");}}
videoMarker.exit=function(){if(typeof(videoMarker.instances)!='undefined'){for(var i in videoMarker.instances){if(typeof(videoMarker.instances[i].processMarker)=='function'){videoMarker.instances[i].processMarker();}}}}
