var video_embed = new Array();
var image_count = 0;
var current_video = 0;
var current_image = 0;

function initChamp()
{
	scrollImages(0);
	if(video_embed.length==1)
	{
		//dim arrows	
	}
}

function initVideos()
{
	for(var i=0; i<arguments.length; i++)
	{
		video_embed.push(arguments[i]);
	}
}

function scrollVideos($delta)
{
	current_video += $delta;
	if(current_video<0)
	{
		current_video=video_embed.length-1;
	}
	if(current_video==video_embed.length)
	{
		current_video=0;
	}
	document.getElementById('video-container').innerHTML = video_embed[current_video];
}

function initImages(c)
{
	image_count = c;
}

function scrollImages($delta)
{
	current_image += $delta;
	if(current_image<0)
	{
		current_image -= $delta;
		return void(0);
	}
	if(current_image>image_count-3)
	{
		current_image -= $delta;
		return void(0);
	}
	
	var html_out = '';
	for(var itr=0; itr<image_count; itr++)
	{
		document.getElementById('champ-thumb-'+itr).style.display = 'none';
	}
	for(itr=0; itr<3; itr++)
	{
		document.getElementById('champ-thumb-'+((current_image+itr)%image_count)).style.display = 'inline';
	}
	
	if(current_image>0)
	{
		document.getElementById('image-back').style.visibility = 'visible';
	}
	else
	{
		document.getElementById('image-back').style.visibility = 'hidden';
	}
	if(current_image<image_count-3)
	{
		document.getElementById('image-next').style.visibility = 'visible';
	}
	else
	{
		document.getElementById('image-next').style.visibility = 'hidden';
	}
}

function champVote(championid, vote)
{
	document.getElementById('champ-rating').innerHTML = '<br /><br />calculating rank...';
	var xmlHttp = initAjaxObj();
	
	xmlHttp.open("POST","/modules/champion-vote/index.php",true);
	var post_vars = 'c='+championid+'&v='+vote;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", post_vars.length);
	xmlHttp.setRequestHeader("Connection", "close");
	
	xmlHttp.onreadystatechange=function() 
	{
		if(xmlHttp.readyState==4) 
		{
			document.getElementById('champ-rating').innerHTML = xmlHttp.responseText;
		}
	};
	
	xmlHttp.send(post_vars);
}