////Ajax to update player page
function updateAll(filename, playlistMode){
	//alert('Update All '+filename+' '+playlistMode);
	updateInfo(filename);
	updateMoreArtist(filename);
	updateActionStats(filename);
	updateComments(filename);
	if(playlistMode == 'ondemand'){
		updateSuggestions(filename);
	}
	//updateVideocode(filename);
	updateTagform(filename);
	updateCommentForm(filename);
	updatePlaylistForm(filename);
	updateTitle(filename);
	lightwindowInit();
}

function updateInfo(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			infoUpdate(t);
		},
		onSuccess: function(t) {
			//infoUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=info&filename='+filename, opt);
}

function infoUpdate(t) {
	var videoinfo = document.getElementById('videoinfo');
	videoinfo.innerHTML = t.responseText;
}

function updateVideocode(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			videocodeUpdate(t);
		},
		onSuccess: function(t) {
			//videocodeUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=videocode&filename='+filename, opt);

}

function videocodeUpdate(t){
	var videocode = document.getElementById('videocode');
	videocode.innerHTML = t.responseText;
	//alert(t.responseText);
}
  

function updateSuggestions(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			suggestionsUpdate(t);
		},
		onSuccess: function(t) {
			//suggestionsUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=suggested_videos&filename='+filename, opt);
}

function suggestionsUpdate(t){
	var suggestions = document.getElementById('suggestions');
	suggestions.innerHTML = t.responseText;
}

function updateMoreArtist(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		//onComplete: function(t){ 
			//moreArtistUpdate(t);
		//},
		onSuccess: function(t) {
			moreArtistUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=more_artist&filename='+filename, opt);
}

function moreArtistUpdate(t){
	var more_artist_title = document.getElementById('moreartisttitle');
	more_artist_title.style.display = "block";
	var more_artist = document.getElementById('more_artist');
	more_artist.innerHTML = t.responseText;
	if(t.responseText == ' '){
		more_artist_title.style.display = "none";
	}
}

function updateActionStats(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			actionStatsUpdate(t);
		},
		onSuccess: function(t) {
			//actionStatsUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=statsandactions&filename='+filename, opt);
}

function actionStatsUpdate(t){
	var statsandactions = document.getElementById('statsandactions');
	statsandactions.innerHTML = t.responseText;
}

function updateTagform(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			tagFormUpdate(t);
		},
		onSuccess: function(t) {
			//tagFormUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=tagform&filename='+filename, opt);
}

function tagFormUpdate(t){
	var tagform = document.getElementById('tagform');
	tagform.innerHTML = t.responseText;
}

function updateComments(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			commentsUpdate(t);
		},		
		onSuccess: function(t) {
			//commentsUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=comments&filename='+filename, opt);
}

function commentsUpdate(t){
	var comments = document.getElementById('comment_block');
	comments.innerHTML = t.responseText;
}

function updateCommentForm(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			commentFormUpdate(t);
		},		
		onSuccess: function(t) {
			//commentFormUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=commentform&filename='+filename, opt);
}

function commentFormUpdate(t){
	var commentform = document.getElementById('commentform2');
	commentform.innerHTML = t.responseText;

}

function updatePlaylistForm(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			playlistFormUpdate(t);
		},		
		onSuccess: function(t) {
			//commentFormUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=playlistform&filename='+filename, opt);
}

function playlistFormUpdate(t){
	var playercon1 = document.getElementById('playercon1');
	playercon1.innerHTML = t.responseText;
}

function updateTitle(filename){
	var opt = {
		// Use POST
		method: 'get',
		// Send this lovely data
		// Handle successful response
		onComplete: function(t){ 
			titleUpdate(t);
		},		
		onSuccess: function(t) {
			//commentFormUpdate(t);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/player_ajax.php?action=title&filename='+filename, opt);
}

function titleUpdate(t){
	var title = document.getElementById('title');
	title.innerHTML = t.responseText;
}

