// Tlapiho AJAX v 0.0
// http://elemetstudio.wz.cz

function change_video(vid_id){
	var E = $('video_player');
	new Ajax.Updater('video_player', '/change_video.php?vid_id='+vid_id, {asynchronous:true, onLoading:function(request){$('video_player').startWaiting()}, onComplete:function(request){window.setTimeout(E.stopWaiting.bind(E), 1000);}});
}

function new_video(form){
	var E = $('add_video');
	new Ajax.Updater('video_selector', '/add_video.php', {asynchronous:true, parameters: form, onLoading:function(request){$('add_video').startWaiting()}, onComplete:function(request){window.setTimeout(E.stopWaiting.bind(E), 1000);}});
	Element.show('video_selector');
	var E = $('video_player');
	new Ajax.Updater('video_player', '/change_video.php', {asynchronous:true, parameters: form, onLoading:function(request){$('video_player').startWaiting()}, onComplete:function(request){window.setTimeout(E.stopWaiting.bind(E), 1000);}});
	$('new_vid_nadpis').innerHTML;
	$('new_vid_embed_code').innerHTML;
	Element.hide('add_video');
	Element.hide('no_vid_info');
}

function change_tv_video(vid_id){
	$('video_player').startWaiting()
	var E = $('video_player');
	var N = $('next_video');
	Element.hide('next_video');
	new Ajax.Updater('video_player', '/change_video.php?vid_id='+vid_id+'&withheader=true', {asynchronous:true, onComplete:function(request){window.setTimeout(E.stopWaiting.bind(E), 1000);}});	
	new Ajax.Updater('next_video', '/tv_next_vid.php', {asynchronous:true, onComplete:function(request){Effect.toggle('next_video', 'appear', { duration: 2.0 } );}});	
	//Effect.Appear('next_video');
}

function tv_periodical_changer(){
	//Effect.toggle('tv_video', 'appear', { duration: 1.0 } );
	new Ajax.PeriodicalUpdater('tv_video', 'video_periodical.php', {asynchronous:true, frequency:6});
}