/*
IMPORTANT ADVISE
The following code is protected by copyright 
 *  (c) 2009 Davide Rolando
except for the functions that don't contain the notice:
	// Copyright © 2009 Davide Rolando//

Thus you can't use any of the copyright protected code 
without first obtaining written permission. 
Please email  webmaster@subsedit.com to obtain written consent.
*/
	
	var jreq_aim = 'resources_convert/convert_f.php';
	
	function showResponse(originalRequest){
		
		jslog.info("Request: " + originalRequest); //jslog;
		
		var t = eval(originalRequest);
		//alert('t zero : '+t[0]);
		switch(t[0]){
		case 'microdvd':
			reportLog(t[1]);
			//addLog('', false);
			
			jslog.info("FPS " + t[2]); //jslog
			//jslog.info("sessConvert " + t[3]); //jslog
			//jslog.info("Converted " + t[4]); //jslog
			
			document.subtosrt.submit();
			reportLog("Conversion completed !");

			
		break;
		case 'fps':
			reportLog("FPS changed : "+t[1]);
		break;
		case 'prova':
			reportLog("Prova eseguita : "+t[1]);
		break;
		default:
			return false;
		break;
		}
	}
	
	function convert_to_srt(){
		//upload subs
		if($('#microdvd').val().length < 3){
			alert("Empty source");
			return false;
		}
		var valsh = uploadsubs('microdvd', 10000, 'convert');
		
		jslog.debug("Upload " + valsh); //jslog
		
		//convert request
		$.ajax({
			type: "POST",
			url: jreq_aim,
			data: ({
				jreq: 'microdvd',
				what: valsh
			}),
			success: showResponse
		});		
		
		
		
		/*
		req_convert = true;
		addLog('', true);
		reportLog('MicroDVD sub import... wait please');
		//return uploadsub($('microdvd').value,'convert','counter')
		*/
	}
	
	function change_fps(newval){
		$.ajax({
			type: "POST",
			url: jreq_aim,
			data: ({
				jreq: 'fps',
				what: encodeURIComponent(newval)
			}),
			success: showResponse
		});
		//return treq('fps', newval)
	}
	
//corners
$('#header').corner();
$('#container').corner();
$('#footer').corner();
$('#reportLog').corner();

