var baseserverurl="http://www.uploadthingy.com";var loadimage="<img src=http://49video.resources.s3.amazonaws.com/loading.gif width=16 height=16>";function replaceString(D,E){var C="";var B=0;while((il=D.indexOf("<$",B))!=-1){var F=D.indexOf("$>",B);var A=D.substring(il+2,F);if(E[A]){C+=D.substring(B,il)+E[A]}B=F+2}C+=D.substring(B);return C}function setHTML(B,A){if(!document.getElementById(B)){return}document.getElementById(B).innerHTML=A}function d(A){A=unescape(A);return A.replace(/\+/g," ")}function doBRs(A){A=A.replace(/\n/g,"");return A.replace(/<br>/g,"\n")}function $(A){return document.getElementById(A)}function cd(){return document.createElement("div")}function n(A){A=d(A);return A.replace(/ /g,"_")}function empty(A){if(!A){return}while(A.hasChildNodes()){A.removeChild(A.firstChild)}}function trim(A){return A.replace(/^\s+|\s+$/g,"")}var JSC_UPLOADSTATUS=0,JSC_FILELIST=1,JSC_GETSERVERUPLOAD=10,JSC_UPLOADPING=104;var currjson,currpw,curruploadpassword=".none.",currdomain,uploadmetadata,purchasedate,createdate,mmd,md;var sorteduploadlist,uploadcompletehtml=null,uploadcompleteredirect=null,uploadcompletefunction=null,savetozip=false,maxsize=null,showmaxsize=true,sendalertsto;var showblinks=true,trial=false;function handleJSON(command,json){currjson=json;if(json.s&&json.s=="badcode"){var m="Ooops. The sitecode supplied with this page will not work with this domain. Please make sure you entered the correct domain when you grabbed the code for this uploadthingy at uploadthingy.com.<br><br>Contact us at hello@uploadthingy.com if you have any questions. We'd love to help out!";setHTML("uploadarea",m);return}if(command==JSC_UPLOADSTATUS){if(json.status=="done"||json.error!=null){clearTimeout(uploadchecktimer);var m="";if(json.error){if(json.error=="server"){m="Ooops. Server error uploading file. <a href=# onclick='authupload();'>Please click here to try again</a>."}else{if(json.error=="authcode"){m="Ooops. Invalid upload authorization. <a href=# onclick='authupload();'>Please click here to try again</a>."}else{if(json.error=="video"){m="Ooops. That was not a valid file. Please try again."}else{if(json.error.indexOf("size")==0){var s1="",s2="";if(json.error.indexOf(";")!=-1){s1=json.error.substring(json.error.indexOf(";")+1,json.error.indexOf(">"))+"bytes";s2=json.error.substring(json.error.indexOf(">")+1)+"bytes"}m="Ooops. The size of the file(s) you are uploading ("+s1+") is larger than the maximum file size allowed "+(showmaxsize?s2:"")+". <a href=# onclick='authupload();'>Please click here to try again.</a>"}else{m="Ooops. Your upload has failed. There must have been a problem with the connection somewhere between your computer and the upload server. <a href=# onclick='authupload();'>Please click here to try again.</a> <br><br>Server error: "+json.error}}}}setHTML("uploadarea",m)}else{var uploadrefcode=json.podcastid.substring(json.podcastid.lastIndexOf("$")+1);var nuc="/widget?c="+sitecode+"&a=newupload";if(uploadmetadata!=null){if(uploadmetadata.name!=null){nuc+="&name="+escape(uploadmetadata.name)}if(uploadmetadata.company!=null){nuc+="&company="+escape(uploadmetadata.company)}if(uploadmetadata.description!=null){nuc+="&description="+escape(uploadmetadata.description)}if(uploadmetadata.contact!=null){nuc+="&contact="+escape(uploadmetadata.contact)}if(uploadmetadata.sendtoemail!=null){nuc+="&sendtoemail="+escape(uploadmetadata.sendtoemail)}if(uploadmetadata.sendtotitle!=null){nuc+="&sendtotitle="+escape(uploadmetadata.sendtotitle)}if(savetozip){nuc+="&savetozip=yes"}if(sendalertsto){nuc+="&sendalertsto="+sendalertsto}for(i=0;i<30;i++){if(uploadmetadata["uploadfile"+i]!=null){var fn=uploadmetadata["uploadfile"+i];if(fn.lastIndexOf("\\")!=-1&&fn.lastIndexOf("\\")<fn.length-2){fn=fn.substring(fn.lastIndexOf("\\")+1)}if(fn.lastIndexOf("/")!=-1&&fn.lastIndexOf("/")<fn.length-2){fn=fn.substring(fn.lastIndexOf("/")+1)}nuc+="&uploadfile"+i+"="+escape(fn)}}nuc+="&refcode="+escape(uploadrefcode)+"&authcode="+uploadcode}else{uploadmetadata=new Array()}sendCommand(baseserverurl,nuc);uploadmetadata.refcode=uploadrefcode;var fcnt=0;if(savetozip){uploadmetadata["fhref"+fcnt]=baseserverurl+"/widget?c="+sitecode+"&el="+uploadrefcode+".zip";uploadmetadata["fname"+fcnt]=uploadrefcode+".zip"}else{for(i=0;i<30;i++){if(uploadmetadata["uploadfile"+i]!=null&&uploadmetadata["uploadfile"+i].length>0){var fn=uploadmetadata["uploadfile"+i];var ext="";var di=fn.lastIndexOf(".");if(di!=null){ext=fn.substring(di)}var dl=baseserverurl+"/widget?c="+sitecode+"&el="+uploadrefcode;if(i==0){dl+=ext}else{dl+="!"+i+ext}uploadmetadata["fhref"+fcnt]=dl;uploadmetadata["fname"+fcnt]=fn;fcnt++}}}var fl="";flcnt=0;while(uploadmetadata["fhref"+flcnt]){fl+="<br><a href="+uploadmetadata["fhref"+flcnt]+">"+uploadmetadata["fname"+flcnt]+"</a>";flcnt++}uploadmetadata.filelinks=fl;if(uploadcompleteredirect!=null){uploadcompleteredirect=replaceString(uploadcompleteredirect,uploadmetadata)}if(uploadcompletehtml!=null){m=replaceString(uploadcompletehtml,uploadmetadata)}else{if(uploadcompletefunction!=null){m=uploadcompletefunction()}else{if(uploadcompleteredirect!=null){m="<a href="+uploadcompleteredirect+">Redirecting</a>... "}else{m="Your upload has successfully completed! Use this code to reference your upload: <b>"+uploadrefcode+"</b>.";if(savetozip){m+="<br><br>Here's a link to a zip file with your uploaded files if you'd like to double check:"}else{if(fcnt>1){m+="<br><br>Here are links to your uploaded files if you'd like to double check:"}else{m+="<br><br>Here's a link to your uploaded file if you'd like to double check:"}}m+=uploadmetadata.filelinks;m+="<br><br><a href='javascript:authupload();'>Click here</a> to return to the upload form."}}}if(m){setHTML("uploadarea",m)}submitting=false}submitting=false}else{var info="";var remainingtime=0;if(json.status=="reading"){info+=json.percentcomplete+"% complete";var elapsed=new Date().getTime()-uploadstart;if(eval(json.totalread)>0){remainingtime=elapsed/eval(json.totalread)*(eval(json.contentlength)-eval(json.totalread));remainingtime=remainingtime/1000;if(remainingtime>60){info+=", remaining time: "+Math.round(remainingtime/60)+" minutes"}else{info+=", remaining time: "+Math.round(remainingtime)+" seconds"}}}else{info+=json.status}clearTimeout(uploadtimer);var wait=1000;if(uploadcnt>50&&remainingtime>20){wait=10000}else{if(uploadcnt>20){wait=5000}else{if(uploadcnt>5){wait=2000}}}uploadtimer=setTimeout("upload('go','"+info+"')",wait)}}else{if(command==JSC_GETSERVERUPLOAD){if(json.s=="ok"||json.s=="trialover"){if(!json.pd&&Date.parse(json.cd)>Date.parse("6/28/2008")&&Math.round((new Date().getTime()-Date.parse(json.cd))/(24*60*60*1000))>8){if(confirm("Ooops. Your trial period has ended or your subscription has been canceled.\n\nClick Ok to redirect to the subscription purchase page at uploadthingy.com. Click Cancel to remain on this page.")){if(window.parent){window.parent.location="http://www.uploadthingy.com/purchase.html"}else{document.location="http://www.uploadthingy.com/purchase.html"}}return}uploadcode=json.c;videoserverurl=json.u;if(videoserverurl.indexOf("https:")==0&&baseserverurl.indexOf("https:")==-1){baseserverurl="https"+baseserverurl.substring(4)}submitting=true;document.getElementById("uploadform").action=json.u+"/cire?uploadcode="+json.c+(maxsize==null?"":"&maxsize="+maxsize);if(document.getElementById("uploadid")){document.getElementById("uploadid").value="widget$"+json.d+"$"+json.c.substring(0,json.c.indexOf("_"))}else{document.getElementById("id").value="widget$"+json.d+"$"+json.c.substring(0,json.c.indexOf("_"))}document.getElementById("authcode").value=uploadcode;document.getElementById("uploadform").submit();uploadcnt=0;uploadstart=new Date().getTime();uploadtimer=setTimeout("upload('go')",1000);uploadchecktimer=setTimeout("uploadCheck()",30000);uploadcntcheck=0}else{if(json.s=="notactive"){setHTML("uploadarea","Ooops. This uploadthingy has been deactivated.")}else{if(json.s=="noauth"){curruploadpassword=prompt("Please enter your upload password: ","");if(curruploadpassword!=null&&curruploadpassword.length>0){sendCommand(baseserverurl,"/widget?c="+sitecode+"&a=authupload&up="+curruploadpassword,null)}else{curruploadpassword=".none."}}else{if(confirm("Ooops. Could not connect to server. Click ok to try again.")){submitting=false;upload("start")}}}}}else{if(command==JSC_UPLOADPING){if(uploadcompleteredirect!=null){if(window.parent){window.parent.location=uploadcompleteredirect}else{document.location=uploadcompleteredirect}}}else{setHTML("uploadarea","Ooops. There was an error: "+json.s+", command="+command+". Please contact us at hello@uploadthingy.com.")}}}}var commandcnt=Math.ceil(Math.random()*10000000),ccbase=new Date().getTime()-1231877000000;var showwaitsave;function sendCommand(A,D,C){if(C){showwaitsave=document.getElementById(C).innerHTML;setHTML(C,"<p>"+loadimage+" &nbsp;Loading...</p>")}var B=document.createElement("script");B.src=A+D+"&cnt="+ccbase+"."+commandcnt;empty(document.getElementById("dataarea"));document.getElementById("dataarea").appendChild(B);commandcnt++}var uploadtimer,uploadcnt,uploadcode,videoserverurl;var uploadchecktimer,uploadcntcheck;var uploadstart,submitting=false;function upload(C,B){if(C=="start"&&!submitting){sendCommand(baseserverurl,"/widget?c="+sitecode+"&a=authupload&up="+curruploadpassword,null);return false}else{++uploadcnt;var A="<p class=49widget_p>Your files are uploading";if(videoserverurl.indexOf("https:")==0){A+=" <b>via a secure SSL encrypted connection</b>"}A+=". Please do not refresh or navigate away from this page until the upload is complete.</p>";A+="<p>"+loadimage+" &nbsp;Uploading... ";if(B){A+=B}A+="</p>";setHTML("uploadarea",A);sendCommand(videoserverurl,"/jsc?uc="+uploadcode,null)}return true}function authupload(){var A=new Array();A.c="xx_xx";A.d="x";var B="<a name=widget_top></a><form method='post' action='";B+="' enctype='multipart/form-data' id='uploadform' name='uploadform' target='uploadtarget' onsubmit=\"if (checkform()) {return upload('start');} else return false;\" >";B+=getUploadForm(A);B+="<input type=hidden name='suploadvideo' value='Upload'>";if(savetozip){B+="<input type=hidden name='savetozip' value='yes'>"}B+="</form><br>";setHTML("uploadarea",B)}var checkerrors=0;function uploadCheck(){if(uploadcntcheck==uploadcnt){if(++checkerrors<5){upload("go","Reconnecting...")}else{if(confirm("Ooops. It seems your upload has failed. Click 'Ok' to start over or 'Cancel' to continue this upload.")){window.location.reload()}else{upload("go","Reconnecting...")}}}uploadcntcheck=uploadcnt;uploadchecktimer=setTimeout("uploadCheck()",30000)};