var fileCallback;

function FileDescription(id, name, path, ticket){
	this.id = id;
	this.name = name;
	this.path = path;
	this.ticket = ticket;
}

function fileAccept(fileDesc){
	if (fileCallback && fileDesc){
		fileCallback(fileDesc);
	}
}

function filePreviewFullScreen(publicLocation){
	if (publicLocation){
		document.location = publicLocation;
	}
}

function showFileSelect(type, caption, callback){
	fileCallback = callback;
	showPopWin('?component=file&filePage=popupSelect&fileId=' + type, caption, 700, 400, fileAccept, false);
}

function showFilePreview(fileId, caption){
	showPopWin('?component=file&filePage=popupPreview&fileId=' + fileId, caption, 600, 500, filePreviewFullScreen, false);
}

function hideFileSelectAccept(fileId, fileName, fileLocation, publicTicket){
	window.top.hidePopWin(true, new FileDescription(fileId, fileName, fileLocation, publicTicket));
}

function hideFileSelectCancel(){
	window.top.hidePopWin();
}

function hideFilePreview(){
	window.top.hidePopWin();
}

function hideFilePreviewFullScreen(publicLocation){
	window.top.hidePopWin(true, publicLocation);
}
