size="medium";
currentPage = 0;
shotsPerPage = 12;
imgredir= root + "_images/community/fanart/"
nothumb = revorder = false
nowViewing = 0;

i = 0;
shotList = new Array();
for(i=0; i<502; i++)
{
	addNum = (i<10) ? "00" : ((i<100) ? "0" : "");
	shotList[i] = root+"_images/"+fanart_imgloc+"/screens/ss"+addNum+(i+1)+".jpg";
}
		

var fanart_startimage = null;
cpg = (document.location.href) ? document.location.href : document.location;

if(cpg.indexOf("#")>0)
{
	parr = cpg.split('#');
	fanart_startimage = parr[1]
}


function printPages()
{
	numPages = Math.ceil(shotList.length/shotsPerPage); 
	outString = "";
	for(i = 0; i < shotsPerPage; i++)
	{
		if(!revorder) n = shotList.length-(shotsPerPage*currentPage+i)-1;
		else { n = (shotsPerPage*currentPage+i); }
		if(shotList[n])
		{	altag = ""
		    if(shotListData[nowViewing])
		    { altag = shotListData[n].replace(/<b class='title'>/,"");
			  altag = altag.replace(/<b class = 'title'>/,""); 
			  altag = altag.replace(/<\/b><br>/," ");
		      endpos = altag.indexOf("<br>")
			  altag = altag.slice(0,endpos); }
			if(nothumb)thumbnail = shotList[n]
			else {thumbnail = shotList[n].replace(".jpg","-thumb.jpg");}
			outString += "<div><div><a href='javascript:omegaLightBox("+n+")'><img alt='"+altag+"' src='"+thumbnail+"'></a></div></div>";
		}
	}
	document.getElementById("galleryPictures").innerHTML = outString;
	document.getElementById("pageNum").innerHTML = "" + Number(currentPage+1) + " " + pageOf + " " + numPages + ""; 
}

function galleryPrev()
{
	if(currentPage > 0) { currentPage--; }
	else { currentPage = numPages-1; }
	printPages();
}

function galleryNext()
{
	if(currentPage < numPages-1) { currentPage++; }
	else { currentPage = 0; }
	printPages();
}



if (window.XMLHttpRequest) { var xmldata = new XMLHttpRequest(); }
else { var xmldata = new ActiveXObject("MSXML2.XMLHTTP.3.0"); }

xmldata.onreadystatechange = function() { 
	if(xmldata.readyState == 4)
	{ 
		if(xmldata.responseXML != null) addEntries(xmldata.responseXML);
  	else { /* alert("Data Failure"); */ }
	}
}

xmldata.open("GET", root+"_content/"+loc+"/fanart.xml", true);
xmldata.send(null);
var size = size||"medium"

function addEntries(dataref)
{
  shotListData = new Array();
  shotList = new Array();
  data = dataref.getElementsByTagName('add');
  for(xi=9; xi<=data.length; xi++)
  {
		if(data[xi])
		{
			pval = data[xi].getAttribute("value")
			shotListData.push(pval); 
			shotList[xi-8] = root+"_images/community/fanart/"+fanart_imgloc+"/screens/" + data[xi].getAttribute("key").replace(/\\/g,"/");
	  	}
  }
	shotList.shift();
	currentPage = 0;
	shotsPerPage = sizenumber()

	if(fanart_startimage){

	/*shotsPerPage = shts;  size = (shotsPerPage==20)?"large":(shotsPerPage==12)?"medium":"small";
	document.getElementById("galleryPictures").className = "pictureGallery " + size; 
	*/ 
	currentPage = Math.floor( ( shotList.length - fanart_startimage - 1) /  shotsPerPage ) 

	addEvent(window,"load",function(){omegaLightBox(fanart_startimage)}); 
	}
	printPages();

}

function sizenumber()
{ return (size=="small")?20:(size=="medium")?12:6; }

function ThumbSize(sze,targ) 
{ currimage = shotsPerPage * currentPage; 
size = sze
$j(targ).addClass("selected");
if(prevtarg) $j(prevtarg).removeClass("selected");
prevtarg = targ
document.getElementById("galleryPictures").className = "pictureGallery " + size;
shotsPerPage = sizenumber()
 currentPage = Math.floor(currimage / shotsPerPage);
printPages();
if(currentPage > numPages){currentPage = numPages-1; printPages();}
}

var sl, sld, fanarthash
function omegaLightBox(num)
{ replacebr = " - "
  fanarthash = true  
 
	if(!sl){  sl = shotList.slice(0).reverse()
			  sld = shotListData.slice(0).reverse() }

  sV.setImageCollection(sl,sl.length-num-1,sld)
}

