/////////////////////////////////////////////////////////////////////////
//// SLIDE VIDEOS
/////////////////////////////////////////////////////////////////////////

function Goto(id) {
	next = id;
	SetIcon();
	DisplayArrows();
	ShowTrailers();
	document.getElementById(icons+id).className = "icon_on";
}

function ShowTrailers() {
	var i = 1;
	
	while(i <= total) {
		var tmp_id = images+i;
		var icon_id = icons+i;
		document.getElementById(tmp_id).style.display = "none";
		document.getElementById(icon_id).className = "icon_off";
		i++;
	}
	
	var i = 1;
	var tmp_id = next;
	var limit = total - next;
	
	while((i <= limit + 1) && i <= display_limit ) {
		var show_id = images+tmp_id;
		document.getElementById(show_id).style.display = "";
		i++;
		tmp_id++;
	}
	
	if(images == 'v'){
		loadContent(videos[next]);
	}
	else{
		loadContent(adverts[next]);
	}
}

function PlusTrailers(){
	next = next + 1;
	DisplayArrows();
	ShowTrailers();
	SetIcon();
}

function NegativeTrailers(){
	next = next - 1;
	DisplayArrows();
	ShowTrailers();
	SetIcon();
}

function SetIcon() {
	var icon_id = icons+next;
	document.getElementById(icon_id).className = "icon_on";
}

function DisplayArrows(){
	if(next == 1) {
		document.getElementById('previous_arrow').style.display = "none";
	}
	else {
		document.getElementById('previous_arrow').style.display = "";
	}
	if(next == (total)) {
		document.getElementById('next_arrow').style.display = "none";
	}
	else {
		document.getElementById('next_arrow').style.display = "";
	}
}

/////////////////////////////////////////////////////////////////////////
//// AJAX CALL
/////////////////////////////////////////////////////////////////////////

function startLoading() {
	Element.show('video_info');
	Element.hide('video_info');
}

function finishLoading() {
	Element.show('video_info');
	setTimeout("Effect.toggle('video_info');", 1000);
}

function loadContent(id) {
	//startLoading();
	new Ajax.Updater('video_info', ajax_location, {
			method: 'post', 
			parameters: {id: id}	
		}
	);
	//finishLoading();
}