var tfDailymotionUploadWindow;

function checkIfVideoToUpload(){
	if ($F('videoDailymotionList')=='upload'){
		openDailymotionUploader();
	}
}

function openDailymotionUploader(){
	var LeftPosition = (screen.width) ? (screen.width-450)/2 : 0; 
	tfDailymotionUploadWindow = window.open('/tomos/dailymotion/frame_display.php?tomosPage=uploader','Tomosfactory ::: Dailymotion Uploader','toolbar=0,menubar=0,location=0,scrollbars=1,top=440, left='+LeftPosition+', width=450,height=310, resizable=0');
}

function reloadVideoList(){
	var req = new GetRequest ({url:'/tomos/dailymotion/ajaxRequest.php',func:executeJs});
	req.send(
		'tomosAction=displayTomosOption'
		+'&display=true'
	);

}

function saveDailymotionLogin(){
	var isOk = true;
	if ($F('dailymotionLoginInput') ==''){
		alert('Veuillez saisir votre identifiant Dailymotion');
	} else {
		var req = new GetRequest ({url:'/tomos/dailymotion/ajaxRequest.php',func:executeJs});
		req.send(
			'tomosAction=saveDailymotionLogin'
			+'&dailymotionLoginInput='+encodeURIComponent($F('dailymotionLoginInput'))
		);
		$('dailymotionLoginInput').disabled= true;
		$('okDailymotionButton').disabled= true;
	}

}

function saveModifiedDailymotionVideo(){
	var isOk = true;
		var req = new GetRequest ({url:'/tomos/dailymotion/ajaxRequest.php',func:executeJs});
		req.send(
			'tomosAction=saveModifiedDailymotionVideo'
			+'&tomosId='+encodeURIComponent($F('tomosIdValue'))
			+'&dailymotionVideoId='+encodeURIComponent($F('videoDailymotionList'))
		);
		$('cancelEditDailymotionVideoButton').disabled= true;
		$('saveEditDailymotionVideoButton').disabled= true;
}

function cancelModifiedDailymotionVideo(){
	document.body.innerHTML = currentBody;
	initTomosphereAdmin();
	currentEditedTomos ='';		
	Event.stopObserving(window, 'keypress', escapeEditTomos); 
}

function editDailymotion(tomosId){
	enableResizable(false);
	currentBody = document.body.innerHTML;
	currentTomosEditToolbarContent = document.body.innerHTML;
	myArray = $(tomosId).getElementsByClassName('tfs_editContent');
	myElement = myArray[0];
	myElement.style.backgroundColor = '#FF0000';
	
	myToolElement = $(tomosId).down('.tfs_move');
	myToolElement.hide();	
	myToolElement = $(tomosId).down('.tfs_editTomos');
	if (myToolElement!=undefined){	
		myToolElement.hide();
	}
	myToolElement = $(tomosId).down('.tfs_editContent');
	myToolElement.removeAttribute('onclick');
	
	bringToFront(tomosId);
	
	$(tomosId).style.border="1px solid red";
	currentEditedTomos = tomosId;
	
	Event.observe(window, 'keypress', escapeEditTomos);
	
	var req = new GetRequest ({url:'/tomos/dailymotion/ajaxRequest.php',func:executeJs});
	req.send(
		'tomosAction=editDailymotion'
		+'&tomosId='+encodeURIComponent(tomosId)
	);
}