var Webcam={version:"1.0.0",protocol:location.protocol.match(/https/i)?"https":"http",swfURL:"",loaded:!1,live:!1,userMedia:!0,params:{width:0,height:0,dest_width:0,dest_height:0,image_format:"jpeg",jpeg_quality:90,force_flash:!1},hooks:{load:null,live:null,uploadcomplete:null,uploadprogress:null,error:function(n){alert("Webcam.js Error: "+n)}},init:function(){navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL;this.userMedia=this.userMedia&&!!navigator.getUserMedia&&!!window.URL;navigator.userAgent.match(/Firefox\D+(\d+)/)&&parseInt(RegExp.$1,10)<21&&(this.userMedia=null)},attach:function(n){var t,i,r,u,f,e;if(typeof n=="string"&&(n=document.getElementById(n)||document.querySelector(n)),!n)return this.dispatch("error","Could not locate DOM element to attach to.");this.container=n;this.params.width||(this.params.width=n.offsetWidth);this.params.height||(this.params.height=n.offsetHeight);this.params.dest_width||(this.params.dest_width=this.params.width);this.params.dest_height||(this.params.dest_height=this.params.height);this.params.force_flash&&(this.userMedia=null);this.userMedia?(t=document.createElement("video"),t.setAttribute("autoplay","autoplay"),t.style.width=""+this.params.dest_width+"px",t.style.height=""+this.params.dest_height+"px",i=this.params.width/this.params.dest_width,r=this.params.height/this.params.dest_height,(i!=1||r!=1)&&(n.style.overflow="visible",t.style.webkitTransformOrigin="0px 0px",t.style.mozTransformOrigin="0px 0px",t.style.msTransformOrigin="0px 0px",t.style.oTransformOrigin="0px 0px",t.style.transformOrigin="0px 0px",t.style.webkitTransform="scaleX("+i+") scaleY("+r+")",t.style.mozTransform="scaleX("+i+") scaleY("+r+")",t.style.msTransform="scaleX("+i+") scaleY("+r+")",t.style.oTransform="scaleX("+i+") scaleY("+r+")",t.style.transform="scaleX("+i+") scaleY("+r+")"),n.appendChild(t),this.video=t,u=document.createElement("canvas"),u.width=this.params.dest_width,u.height=this.params.dest_height,f=u.getContext("2d"),this.context=f,this.canvas=u,e=this,navigator.getUserMedia({audio:!1,video:!0},function(n){t.src=window.URL.createObjectURL(n)||n;Webcam.stream=n;Webcam.loaded=!0;Webcam.live=!0;Webcam.dispatch("load");Webcam.dispatch("live")},function(){return e.dispatch("error","Could not access webcam.")})):n.innerHTML=this.getSWFHTML()},reset:function(){if(this.userMedia){try{this.stream.stop()}catch(n){}delete this.stream;delete this.canvas;delete this.context;delete this.video}this.container.innerHTML="";delete this.container;this.loaded=!1;this.live=!1},set:function(){if(arguments.length==1)for(var n in arguments[0])this.params[n]=arguments[0][n];else this.params[arguments[0]]=arguments[1]},on:function(n,t){if(n=n.replace(/^on/i,"").toLowerCase(),typeof this.hooks[n]=="undefined")throw"Event type not supported: "+n;this.hooks[n]=t},dispatch:function(){var n=arguments[0].replace(/^on/i,"").toLowerCase(),t=Array.prototype.slice.call(arguments,1);return this.hooks[n]?(typeof this.hooks[n]=="function"?this.hooks[n].apply(this,t):typeof this.hooks[n]=="array"?this.hooks[n][0][this.hooks[n][1]].apply(this.hooks[n][0],t):window[this.hooks[n]]&&window[this.hooks[n]].apply(window,t),!0):!1},setSWFLocation:function(n){this.swfURL=n},getSWFHTML:function(){var i,u,t,f,r,n,e;if(location.protocol.match(/file/))return'
Sorry, the Webcam.js Flash fallback does not work from local disk. Please upload it to a web server first.<\/h1>';if(!this.swfURL){for(i="",u=document.getElementsByTagName("script"),t=0,f=u.length;t