var currentListFile = '';
var lastOpenedId = 0;

function play(url, collectionId, filename, folder, filetype, currentRate, currentView) {

	Ext.Ajax.request({
		url: '../../insertCollectionDigitalOpen/' + collectionId + '/' + filename,
		params: {
			task: 'insertCollectionDigitalOpen'
		},
		callback: function(a,b,c) {
			lastOpenedId = c.responseText;
			
			currentListFile = document.getElementById('listFiles').innerHTML;
			var playCanvas = '<a href="#" onclick="unplay();">&laquo; Kembali</a><br /><br /><iframe frameborder="0" style="border: 1px solid silver; width:680px; height:600px;" src="' + url +'/digitalviewer/index.php?collectionId='+lastOpenedId+'&filename='+folder+'&filetype='+filetype+'&currentRate='+currentRate+'&currentView='+currentView+'"></iframe>';
			document.getElementById('listFiles').innerHTML = playCanvas;
			
		}
	});
}

function unplay() {
	Ext.Ajax.request({
		url: '../../updateCollectionDigitalOpen/' + lastOpenedId,
		params: {
			task: 'updateCollectionDigitalOpen'
		},
		callback: function() {
			//window.location.reload();
			document.getElementById('listFiles').innerHTML = currentListFile;
		}
	});
}