// JavaScript Document

//<![CDATA[
var currentId = null;
var currentIndex = 0;
var lastId = null;
var lastIndex = 0;
var previousId = null;

var nextId = null;
var artDir = null;
var thumbsDir = null;
var series = null;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function SetBigImage(id,i) {
	 
	//alert(series.imgsrc[i].src);
	
	
	document.getElementById(id).src = artDir +'/large/'+ i;
	
    

}
function SetImage(id) {
		HoverImage(id);
}
function HoverImage(id) {
	var i= id.split('i');
	var index = parseInt(i[1]);	
	//alert(id);
	if (currentId == null ) {
		currentIndex = index;
		currentId = id;
		lastIndex = index;
		lastId = id;
		//alert(id);
		//alert(currentIndex);
		document.getElementById(id).src = artDir + thumbsDir + series.name[currentIndex];
		if (series.title[currentIndex] != null)  {
		document.getElementById('imgTitle').innerHTML = series.title[currentIndex];
	}
	if (series.description != null)
		//alert("first time");
    	document.getElementById('description').innerHTML = series.description[currentIndex];
		return;
	}
	//alert(currentId+" "+currentIndex);
	document.getElementById(currentId).src = artDir+ thumbsWhiteDir +series.name[currentIndex];	// the current one goes white //
	currentIndex = index;
	currentId = id;
	//alert(currentIndex);
	document.getElementById(id).src = artDir + thumbsDir + series.name[currentIndex];	
	document.getElementById('bigImage').src = series.large[currentIndex].src;

	if (series.title[currentIndex] != null)  {
		document.getElementById('imgTitle').innerHTML = series.title[currentIndex];
	}
	if (series.description[currentIndex] != null)
    	document.getElementById('description').innerHTML = series.description[currentIndex];
	
	
    
}
function Next(series, next_page) {
	 
	var nextIndex = -1;
	
	//alert(currentIndex);
	
	if (((currentIndex + 1) %8) == 0 ){
		if (next_page == "none") {
			return;
		} else{
			var e = document.getElementById('next');
		
			e.setAttribute('href', next_page);
		    nextId = 'i10';
		}
	} else {
		//alert("length " +series.name.length);
		if ((currentIndex + 1) >= (series.name.length)) {
			
	 		return;
		}
		nextIndex = currentIndex + 1;
		nextId = 'i' + nextIndex;
		HoverImage(nextId);
	}
	
	
}


function Previous(series, next_page) {
	var nextIndex = -1;
	//alert(currentIndex);
	if (currentIndex == 0) 
		return;
	if (((currentIndex - 1) %8 ) == 7){
		if (next_page == "none")
			return;
		else  {
			var e = document.getElementById('prev');
		
			e.setAttribute('href', next_page);
			nextId = 'i0';
		}
	} else {
	
		nextIndex = currentIndex - 1;
		nextId = 'i' + nextIndex;
		//alert(nextIndex);
		HoverImage(nextId);
	}
	
	
}

function SetActive (tab, menu,menuItem) {
	var tabElem = MM_findObj(tab, document);
	if (tabElem) {
		tabElem.className = "tab-on";
		var anchors = tabElem.getElementsByTagName('a');
		//alert(anchors.length);
		anchors[0].removeAttribute('onmouseout');
	}
	if (menu == null)
		return;
	var menuElem = MM_findObj(menu);
	if (menuElem) {
		menuElem.style.display = "block";
	}
	var elem = MM_findObj(menuItem, document);
	elem.style.color = "#FF3311";
}

function HighlightNav (id){
	var elem = MM_findObj(id);
	elem.className = 'highlightBorder';
	elem.color = "#222222"
	
}



function HighlightNavOff (id){
	var elem = MM_findObj(id);
	elem.className = 'highlightBorderOff';
}

function SetHighlightNav(id) {
	var elem = MM_findObj(id);
	elem.className = 'highlightBorder';
	
}
function OpenSubMenu (id, d ){
	var elem = MM_findObj(id);
	
	elem.style.left = d;
	
	
}

function DisplayStatement(id){
	var elem = MM_findObj(id);
	
	if (elem.style.display == "none")
		elem.style.display = "block";
	
}
function HideStatement(id){
	var elem = MM_findObj(id);
	
	if (elem.style.display == "block")
		elem.style.display = "none";
	
}