$(document).ready(function(){if(!navigator.javaEnabled()){$("#javacheck").html('<p>Java is NOT enabled. Please <a href="http://www.java.com/en/download/">click here for free Java download.</a></p>');}});var LUPJS_STATE_UNINITIALIZED=0;var LUPJS_STATE_READY=1;var LUPJS_STATE_RECORDING=2;var LUPJS_STATE_STOPPING=3;var LUPJS_STATE_SENDABLE=4;var LUPJS_STATE_UPLOADING=5;var LUPJS_State=LUPJS_STATE_UNINITIALIZED;var LUPJS_PhraseArray=new Array();var LUPJS_PhraseId=new Array();var LUPJS_RecordingId=new Array();var LUPJS_UID="";var LUPJS_PhraseIndex=-1;var lcode=$("#l").val();function skipPhrase(){$.getJSON("/contribute/sktasks?t=21&l="+lcode+"&eid="+LUPJS_PhraseId[LUPJS_PhraseIndex],function(a){var b=a.status;if(b!=0){return b;}});}function LUPJS_DisplayNextPhrase(){if(LUPJS_PhraseIndex==(LUPJS_PhraseArray.length-1)){$("#phrasebox > p").text("Loading...");$("#phrasebox > p").fadeIn();var a=new Date().getTime();$.getJSON("/contribute/sktasks?t=20&l="+lcode+"&tsx="+a,function(b){LUPJS_UID=b.uid;$.each(b.rows,function(c,d){LUPJS_RecordingId.push(d[0]);LUPJS_PhraseId.push(d[1]);LUPJS_PhraseArray.push(d[2]);});LUPJS_PhraseIndex=LUPJS_PhraseIndex+1;$("#phrasebox>p").fadeOut("fast",function(){$("#phrasebox > p").text(LUPJS_PhraseArray[LUPJS_PhraseIndex]);$("#phrasebox > p").fadeIn();$("#phrase_id").text(LUPJS_PhraseId[LUPJS_PhraseIndex]);$("#phrase").text(LUPJS_PhraseArray[LUPJS_PhraseIndex]);});document.recordingControl.recordStopButton.value="RECORD";});}}function LUPJS_AppletReady(){$(document).ready(function(){sleep(1000);});LUPJS_SetState(LUPJS_STATE_READY);LUPJS_DisplayNextPhrase();}function LUPJS_SetState(a){LUPJS_State=a;document.recordingControl.uploadButton.disabled=true;switch(a){case LUPJS_STATE_UNINITIALIZED:$("#js_statebox").text("NOT READY");document.recordingControl.recordStopButton.disabled=true;document.recordingControl.playButton.disabled=true;break;case LUPJS_STATE_READY:$("#js_statebox").text("READY");document.recordingControl.recordStopButton.disabled=false;document.recordingControl.playButton.disabled=true;document.recordingControl.recordStopButton.value="RECORD";break;case LUPJS_STATE_RECORDING:$("#js_statebox").text("RECORDING");document.recordingControl.recordStopButton.disabled=false;document.recordingControl.playButton.disabled=true;document.recordingControl.recordStopButton.value="STOP";break;case LUPJS_STATE_STOPPING:$("#js_statebox").text("STOP");break;case LUPJS_STATE_SENDABLE:$("#js_statebox").text("READY TO SEND");document.recordingControl.uploadButton.disabled=false;document.recordingControl.recordStopButton.disabled=false;document.recordingControl.playButton.disabled=false;document.recordingControl.recordStopButton.value="RE-RECORD";break;case LUPJS_STATE_UPLOADING:$("#js_statebox").text("SENDING");break;default:$("#js_statebox").text("NOT READY");break;}}window.onbeforeunload=ConfirmPageExit;function ConfirmPageExit(){if(!document.VoiceRecorder.isActive()){return(void 0);}else{var a=document.VoiceRecorder.isPlayable();if(a){return"WARNING - If you leave this page without uploading your recording then you will LOSE your recording.";}else{return(void 0);}}}function LUPJS_UploadCompleted(){LUPJS_SetState(LUPJS_STATE_READY);LUPJS_DisplayNextPhrase();}function touchLoadLiveConnect(){if(!document.VoiceRecorder.isActive()){setTimeout("touchLoadLiveConnect()",100);}}function LUPJS_RecordMessage(){if(!document.VoiceRecorder.isActive()){alert("Applet is not yet ready!");}else{var a=document.VoiceRecorder.isStopped();if(!a){alert("You are already recording!");return;}document.VoiceRecorder.record();}}function LUPJS_StopRecording(){if(!document.VoiceRecorder.isActive()){alert("Applet is not yet ready!");}else{LUPJS_SetState(LUPJS_STATE_STOPPING);document.VoiceRecorder.stopAudio();sleep(1);LUPJS_PlayMessage();}}function LUPJS_RecordOrStop(){if(LUPJS_State==LUPJS_STATE_RECORDING){LUPJS_StopRecording();}else{LUPJS_RecordMessage();}}function LUPJS_PlayMessage(){if(!document.VoiceRecorder.isActive()){alert("Applet is not yet ready!");}else{var a=document.VoiceRecorder.isPlayable();if(a){document.VoiceRecorder.play();}else{alert("No recording!");}}}function LUPJS_UploadMessage(){if(!document.VoiceRecorder.isActive()){alert("Applet is not yet ready!");}else{var c=document.VoiceRecorder.isStopped();var b=document.VoiceRecorder.isPlayable();var a=c&&b;if(!a){alert("You must record a voice message before sending!");return;}document.VoiceRecorder.setUploadCompletionScript("LUPJS_UploadCompleted();");LUPJS_SetState(LUPJS_STATE_UPLOADING);document.VoiceRecorder.addNameValuePair("rec_id",LUPJS_RecordingId[LUPJS_PhraseIndex]);document.VoiceRecorder.addNameValuePair("phrase_id",LUPJS_PhraseId[LUPJS_PhraseIndex]);document.VoiceRecorder.addNameValuePair("phrase",LUPJS_PhraseArray[LUPJS_PhraseIndex]);document.VoiceRecorder.addNameValuePair("uid",LUPJS_UID);document.VoiceRecorder.sendRecordedMessage();}}function LUPJS_StateChanged(a,b){if((a=="recording")&&(b=="stopped")){if(LUPJS_State!=LUPJS_STATE_STOPPING){alert("Sorry. You ran out of time.");}LUPJS_SetState(LUPJS_STATE_SENDABLE);}else{if(b=="recording"){LUPJS_SetState(LUPJS_STATE_RECORDING);}}}function LUPJS_TimeChanged(b,a){$("#timebox").text(b.toFixed(1)+" / "+a.toFixed(1));}function sleep(a){var c=new Date().getTime();for(var b=0;b<10000000;b++){if((new Date().getTime()-c)>a){break;}}}
