	var optionNo = 0
	var UserServerFolder = "miha"
	
	function vision()	
	{
		//STOP_RP();
		document.getElementById("loadappbutton").style.display="none";
		document.getElementById("loaded").style.display="block";
		
		alert('app is loaded');
	
		
	}
	
	function fileLoaded()
	{

		
	
	     document.getElementById("audiotimer").value = '';
			document.RPApplet.jsStop();
		    loadlinkslistsai();
		 	 cancelrecording();
		
	}

	function report_RP(s,num)
	{
		alert(s);
	}

	function setRecordLevel(num){}

	function setStatus(str,num)	
	{
		//document.Gui_RP.Status.value = str;
		//document.getElementById("statusmsg").value = str;
		
		if(num==2) {
	    var text='Would you like to save this audio message and get your short url now? <a href="javascript:UPLOAD_RP();">CLICK HERE</a>';
        writit(text,'audioplayer_message');
		}
		
		if(num==10) {
	    var text='Installing java applet MP3 encoding libraries 1.2MB in size, this may take a minute.';
        writit(text,'audioplayer_message');
		}
		
		if(num==11) { 
		fileLoaded();
		
		}
	}

	function setTime(s)	{
		//document.Gui_RP.Timer.value = s;
		//alert('timer initialized:'+ s);
		
	
	document.getElementById("audiotimer").value = s;
	}

	function confirmRecord(s, num)	{
		if(confirm(s))
			RECORD_RP();
		else
			STOP_RP();
	}

	function addName(s)	{
		//var newOpt  = new Option(String(s),String(s));
		//var VILength = document.Gui_RP.VoiceItems.length;
		//document.Gui_RP.VoiceItems.options[VILength] = newOpt;
		
//		document.Gui_RP.FileName.value = "*.mp3";
	}

	function RECORD_RP()	{
	
	    document.getElementById("audiotimer").value="Initializing";
	    document.getElementById("longurlinput").style.display="none";
		document.getElementById("audioappcontainer").style.display="block";
		
		document.getElementById("audioappcontainer").style.zIndex="99990";
		
		document.getElementById("audioappcontainer").style.height="60px";
		document.getElementById("audioappcontainer").style.width="340px";
		
		 //document.getElementById("audiojava").style.height="30px";
         //document.getElementById("audiojava").style.width="300px";
		
		document.getElementById("audiojava").style.visibility="visible";
		
		document.getElementById("recordbutton").style.display="none";
		document.getElementById("playbutton").style.display="none";
		
		
		document.RPApplet.jsStop();
		document.RPApplet.jsRecord();
		
		var text='Your mic is currently recording, when you are done click the <img src="http://ity.im/recorder/stopbutton.png" width=22 height=18> stop button.';
        writit(text,'audioplayer_message');
		
		
		}

<!-- ************* EXAMPLE **************************************************************** -->
	function SETPARAMS()	{
		document.RPApplet.Setparameter(String("url"),document.getElementById('shrinkurlaudio').value);
		
		try {
        document.RPApplet.Setparameter(String("urlkey"),document.getElementById('urlkey').value);
		document.getElementById('urlkey').value='';
		} catch(err) {
		
		}
		
if(document.getElementById('disable_inter').checked) {
		document.RPApplet.Setparameter(String("disable_inter"),'1');
}
if(document.getElementById('enable_reply').checked) {
		document.RPApplet.Setparameter(String("enable_reply"),'1');
}
if(document.getElementById('enable_comments').checked) {
		document.RPApplet.Setparameter(String("enable_comments"),'1');
}


var categoryid = document.getElementById('categorylist').options[document.getElementById('categorylist').selectedIndex].value;
	document.RPApplet.Setparameter(String("category"),categoryid);

		
		
		
		}
<!-- ************* EXAMPLE **************************************************************** -->



	function PLAYBACK_RP()	{
	
	if(document.getElementById("audiotimer").value==0 || document.getElementById("audiotimer").value=='') {
	
		var text='You must first record an audio message before you can play it back.';
        writit(text,'audioplayer_message');

	} else {
	
	
	
	    document.getElementById("recordbutton").style.display="none";
		document.getElementById("playbutton").style.display="none";
	
		var text='Your recorded message is playing.';
        writit(text,'audioplayer_message');
	
		document.RPApplet.jsPlayback();
		
		}
	}

	function PAUSE_RP()	{
	
		if(document.getElementById("audiotimer").value==0 || document.getElementById("audiotimer").value=='') {
	
		var text='You must first record an audio message before you can pause it.';
        writit(text,'audioplayer_message');

	} else {
	
		document.RPApplet.jsPause();
		 var text='PAUSED, if you were recording and wish to continue recording click the pause button again.';
        writit(text,'audioplayer_message');
		
		}
	}

	function STOP_RP()	{
	
		if(document.getElementById("audiotimer").value==0 || document.getElementById("audiotimer").value=='') {
	
		var text='You must first record an audio message before you can stop or save it.';
        writit(text,'audioplayer_message');

	} else {
	
	
		document.getElementById("audioappcontainer").style.height="1px";
		document.getElementById("audioappcontainer").style.width="340px";
	
		// document.getElementById("audiojava").style.height="1px";
        // document.getElementById("audiojava").style.width="200px";
	
    	document.getElementById("audiojava").style.visibility="hidden";
	
	    //document.getElementById("audiojava").style.zIndex="-1";
	    //document.getElementById("audioapplet").style.zIndex="-1";
	    //document.getElementById("audioappcontainer").style.zIndex="-1";
	
	
        document.getElementById("longurlinput").style.display="block";
	
	    document.getElementById("recordbutton").style.display="block";
		document.getElementById("playbutton").style.display="block";
		
		
	    var text='Would you like to save this audio message and get your short url now? <a href="javascript:UPLOAD_RP();">CLICK HERE</a>';
        writit(text,'audioplayer_message');
	
		setTimeout('document.RPApplet.jsStop()',500);
		
		}

	}

	
	function upload_RPfile() {
	
		document.RPApplet.jsUpload(String(document.Gui_RP.FileName.value));
	
	}
	
	function UPLOAD_RP()	{
	
	
	if(document.getElementById("audiotimer").value==0 || document.getElementById("audiotimer").value=='') {
	
	displayerror('You must record a voice or audio message before creating a s.ai url');

	} else {
    STOP_RP();
    if(document.getElementById("imagefile").value!='') {
	 
		var e = document.getElementById('shrinkjaxoutputLIST'); 
	    e.innerHTML = "<center><p style='margin-top:50px; font-family:arial,helvetica; font-size:16px; font-weight:bold;'>UPLOADING YOUR IMAGE...</p><img src='http://ity.im/ityimages/ajaxloading.gif'></center>";
        document.getElementById("imageurltype").value="audiourl";
		document.myForm.submit();
	
	} else {

   
	var e = document.getElementById('shrinkjaxoutputLIST'); 
	    e.innerHTML = "<center><p style=' margin-top:50px;  font-family:arial,helvetica; font-size:16px; font-weight:bold;'>CREATING YOUR SHORT URL...</p><img src='http://ity.im/ityimages/ajaxloading.gif'></center>";
	
	SETPARAMS();
	
	//Error checking to return output since the recording software that executes recieve.php cant return anything---
    var ajax = new sack();
    ajax.setVar("url", document.getElementById('shrinkurlaudio').value);
    ajax.execute=true;
	ajax.requestFile = "http://ity.im/shrinkjax-dev/uploadaudio_errorcheck.php";
    ajax.method = 'POST';
	ajax.runAJAX();
	//-------------------------------------------------------------------------------------------
	
	
	setTimeout('upload_RPfile()',1500);

			
		}
	
	}
	
	
	
	}

	function WEBPLAY_RP()	{
	document.RPApplet.jsPlayback(UserServerFolder + "/" + document.Gui_RP.VoiceItems.value);
	}
	
	function image_uploadaudio(imageid) {
	
		var e = document.getElementById('shrinkjaxoutputLIST'); 
	    e.innerHTML = "<center><p style='margin-top:50px; font-family:arial,helvetica; font-size:16px; font-weight:bold;'>CREATING YOUR S.AI SHORT URL...</p><img src='http://ity.im/ityimages/ajaxloading.gif'></center>";
	
	
		SETPARAMS();
		
		//alert(imageid);
	    document.RPApplet.Setparameter(String("imageid"),imageid);
		document.RPApplet.jsUpload(String(document.Gui_RP.FileName.value));

	}
	
	function image_uploadityim(imageid) {
	
		var e = document.getElementById('shrinkjaxoutputLIST'); 
	    e.innerHTML = "<center><p style='margin-top:50px; font-family:arial,helvetica; font-size:16px; font-weight:bold;'>CREATING YOUR ITY.IM SHORT URL...</p><img src='http://ity.im/ityimages/ajaxloading.gif'></center>";
	    shrinkurl(imageid);
		
	}
	
