/*
**********************************************
easyALBUM: do not remove copyright information
version 1.1.6 Copyright 2006, Sara Horwath
http://www.illustratorin.de - all rights reserved
**********************************************
*/
var SHI_gallery;
var SHI_anchor;
var SHI_itemNumber;
var SHI_stage;
var SHI_itemTitle;
var SHI_itemDescription;
var SHI_navTop;
var SHI_navPrev;
var SHI_navClose;
var SHI_navNext;
var SHI_zCounter;
var SHI_zImage;
function SHI_Gallery(zElement){
		SHI_gallery=zElement;	
		SHI_anchor = document.getElementById(SHI_gallery).getElementsByTagName("a");
// building the whole thing from scratch starting with the slideshow
// zDIV_slideShow
		var zDiv_wrapper = document.createElement('div');
		document.getElementsByTagName("body")[0].appendChild(zDiv_wrapper);
		zDiv_wrapper.id="zDIV_slideShow";


// zA_previous
		var zA_0 = document.createElement('a');
		var zImg_0 = document.createElement('img');		
		zDiv_wrapper.appendChild(zA_0);
		zA_0.id = "zA_previous";
		zA_0.title = "Previous Slide";
		zA_0.href = "#null";
		zA_0.appendChild(zImg_0);
		zImg_0.src="img/previous.jpg";
		zImg_0.alt="Previous Slide";
//  zA_top
		
		var zA_1 = document.createElement('a');	
		var zImg_1 = document.createElement('img');		
		zDiv_wrapper.appendChild(zA_1);		
		zA_1.id = "zA_top";
		zA_1.title = "top";
		zA_1.href = "#null";
		zA_1.appendChild(zImg_1);
		zImg_1.src="img/top4.jpg";
		zImg_1.alt="top";
// zA_close		
		var zA_2 = document.createElement('a');	
		var zImg_2 = document.createElement('img');		
		zDiv_wrapper.appendChild(zA_2);		
		zA_2.id = "zA_close";
		zA_2.title = "close";
		zA_2.href = "#null";
		zA_2.appendChild(zImg_2);
		zImg_2.src="img/close.jpg";
		zImg_2.alt="close";
// zA_next		
		var zA_3 = document.createElement('a');
		var zImg_3 = document.createElement('img');
		zDiv_wrapper.appendChild(zA_3);	
		zA_3.id = "zA_next";
		zA_3.title = "Next Slide";	
		zA_3.href = "#null";
		zA_3.appendChild(zImg_3);
		zImg_3.src="img/next.jpg";
		zImg_3.alt="Next Slide";
// zA_title		
		var zA_4 = document.createElement('a');
		zDiv_wrapper.appendChild(zA_4);	
		var zTitle = document.createTextNode("Title");
		zA_4.id = "zA_title";
		zA_4.appendChild(zTitle);
// zDIV_counter
		var zDiv_counter = document.createElement('div');
		var SHI_zCounter = document.createTextNode("Keeping track");
		zDiv_wrapper.appendChild(zDiv_counter);
		zDiv_counter.id="zDIV_counter";
		//zDiv_counter.appendChild(SHI_zCounter); auskommentiert am 7.1.2010
// zA_image		
		var zA_6 = document.createElement('a');
		var zImg_6 = document.createElement('img');
		zDiv_wrapper.appendChild(zA_6);	
		zA_6.id = "zA_image";
		zA_6.appendChild(zImg_6);
		zImg_6.id="zIMG";
// zA_description		
		var zA_5 = document.createElement('a');
		var zDescription = document.createTextNode("Description");
		zDiv_wrapper.appendChild(zA_5);
		zA_5.id = "zA_description";	
		zA_5.href = "#";	
		zA_5.appendChild(zDescription);	
// Erzeugung der Links der Vorschaubilder für die Detaildarstellung der Gallery
		for (var x=0,i=SHI_anchor.length;x<i;x++){
			SHI_anchor[x].onclick = badabingbadaboum;
// we create fragment identifier to be used to navigate and keep track of the items and we kick start the whole thing
// die Raute + Zahl ist ausschlaggebend für das funktionieren des großen Bildes auf der Seite!
			SHI_anchor[x].href = SHI_anchor[x].href+"#"+x;
// we create a container to receive the text links
			var zSPAN = document.createElement('span');
			SHI_anchor[x].appendChild(zSPAN);
			var zTextLink = document.createTextNode(SHI_anchor[x].title);
			zSPAN.appendChild(zTextLink);
		}
}	
function goTop() {
	
}

function goPrevious() {
SHI_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
	// hiding the button if we are on first slide 
	if(SHI_itemNumber==1)this.className="transparent";
	SHI_navNext.className="nonOpaque";
	if(SHI_itemNumber==0){return} // we are at the beginning	
		SHI_zImage.src = SHI_anchor[SHI_itemNumber-1].href;
		SHI_zImage.alt = SHI_itemTitle.firstChild.data;		
		SHI_itemTitle.href = SHI_anchor[SHI_itemNumber-1].href;
		SHI_itemTitle.firstChild.data = SHI_anchor[SHI_itemNumber-1].getElementsByTagName("img")[0].alt;
		SHI_itemDescription.firstChild.data = SHI_anchor[SHI_itemNumber-1].title;
	// special care for this one in case there is no long description set		
	if(SHI_anchor[SHI_itemNumber-1].getElementsByTagName("img")[0].longDesc){
		SHI_itemDescription.href = SHI_anchor[SHI_itemNumber-1].getElementsByTagName("img")[0].longDesc;	
	// appendData() breaks IE5 Win
		SHI_itemDescription.firstChild.data=SHI_anchor[SHI_itemNumber-1].title+" [more info/ORDER]";
		SHI_itemDescription.title = "Follow this link for more Information";	
		SHI_itemDescription.className="noHand";
		SHI_itemDescription.style.textDecoration ="underline";
	}else{
		SHI_itemDescription.className="withHand";
		SHI_itemDescription.title="";
		SHI_itemDescription.href="#";
		SHI_itemDescription.style.textDecoration ="none";
		}
// we update the value of the counter in the DIV
//var current = eval(document.getElementById("zA_title").hash.substring(1)) + 1; auskommentiert am 7.1.2010
//SHI_zCounter.firstChild.data = "Item #"+current+" out of "+SHI_anchor.length; auskommentiert am 7.1.2010
}
function goNext() {
SHI_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
// hiding the button if we are on the last slide 
	if(SHI_itemNumber==SHI_anchor.length-2)this.className="transparent";
		SHI_navPrev.className="nonOpaque";
	if(SHI_anchor.length == SHI_itemNumber+1){return} // we are at the end	
		SHI_zImage.src = SHI_anchor[SHI_itemNumber+1].href;
		SHI_zImage.alt = SHI_itemTitle.firstChild.data;		
		SHI_itemTitle.href = SHI_anchor[SHI_itemNumber+1].href;
		SHI_itemTitle.firstChild.data = SHI_anchor[SHI_itemNumber+1].getElementsByTagName("img")[0].alt;
		SHI_itemDescription.firstChild.data = SHI_anchor[SHI_itemNumber+1].title;
// special care for this one in case there is no long description set		
	if(SHI_anchor[SHI_itemNumber+1].getElementsByTagName("img")[0].longDesc){
		SHI_itemDescription.href = SHI_anchor[SHI_itemNumber+1].getElementsByTagName("img")[0].longDesc;	
// appendData() breaks IE5 Win
		SHI_itemDescription.firstChild.nodeValue=SHI_anchor[SHI_itemNumber+1].title+" [more info/ORDER]";
		SHI_itemDescription.title = "Follow this link for more Information";	
		SHI_itemDescription.className ="noHand";
		SHI_itemDescription.style.textDecoration ="underline";
	}else{
		SHI_itemDescription.className ="noHand";
		SHI_itemDescription.title="";
		SHI_itemDescription.href="#";
		SHI_itemDescription.style.textDecoration ="none";
	}
// we update the value of the counter in the DIV
//var current = eval(document.getElementById("zA_title").hash.substring(1)) + 1; auskommentiert am 7.1.2010
//SHI_zCounter.firstChild.data = "Item #"+current+" out of "+SHI_anchor.length;	 auskommentiert am 7.1.2010
}
// to make sure users don't follow the link in the title (it is there to be used as a match with the thumbnail that triggered the popup DIV)
function fakeIt() {return false}
// hiding the SlideShow
function hideSHI_stage() {
	document.getElementById("zDIV_slideShow").style.height="0"; // IE5 Mac
	document.getElementById("zDIV_slideShow").style.overflow="hidden"; // IE5 Mac
	document.getElementById("zDIV_slideShow").style.display="none";
	// we remove the opacity stuff
	document.getElementById("wrapper").className="none";
	// we set focus back to the thumbnail that triggered the "popup" DIV
	var SHI_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
	SHI_anchor[SHI_itemNumber].focus();
}
function badabingbadaboum() {
	SHI_stage = document.getElementById("zDIV_slideShow");
	SHI_itemTitle = document.getElementById("zA_title");
	SHI_itemDescription = document.getElementById("zA_description");
	SHI_navTop = document.getElementById("zA_top");
	SHI_navPrev = document.getElementById("zA_previous");
	SHI_navClose = document.getElementById("zA_close");
	SHI_navNext = document.getElementById("zA_next");
	//SHI_zCounter = document.getElementById("zDIV_counter");
	SHI_zImage = document.getElementById("zA_image").getElementsByTagName("img")[0];
	// we do some opacity stuff
	document.getElementById("wrapper").className="transparent";
	// IE5 Mac (phantom links)
	// this.blur();
	// this is to reset the fix for IE Mac (see statement in (hideSHI_stage())	
	SHI_stage.style.height="100%";
	SHI_stage.style.display="block";
	SHI_zImage.src = this.href.replace(this.hash,"");
	SHI_zImage.alt = this.getElementsByTagName("img")[0].alt;
	SHI_zImage.onclick = hideSHI_stage;
// "style.cursor" breaks IE5
	SHI_zImage.className = "hand";
	SHI_zImage.title = "close";
// the href value we set for this anchor will be used to give focus back to the appropriate thumbnail 
	SHI_itemTitle.setAttribute("href",this.href);
// since we have a real href value in there we don't want the user to trigger the link
	SHI_itemTitle.onclick=fakeIt;
// go to top Page = gallery
	SHI_navTop.href = "http://www.illustratorin.eu/pin-up/index.php?site=Gallery";
	SHI_navTop.target = "_self";
// clicking on the close box will close the popup DIV
	SHI_navClose.onclick=hideSHI_stage;
// setting the action for the prev/next links
	SHI_navPrev.onclick=goPrevious;
	SHI_navNext.onclick=goNext;	
// now we can set focus for keyboard users
	SHI_navPrev.focus();
// setting the height - mainly for IE - the second one is for IE5
	SHI_stage.style.height = (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight+"px" : document.body.clientHeight+"px";
// setting the width for IE 5 so there is no gap near the scrollbar
	if(document.documentElement.clientHeight == 0)SHI_stage.style.width=document.body.clientWidth+"px" ;
// setting the title and description
	SHI_itemTitle.firstChild.data = this.getElementsByTagName("img")[0].alt;
	SHI_itemDescription.firstChild.data = this.title;
// if there is a long description in there, we use it as href value of the short description and we give it a title to. If there is none we make sure we reset values previously set and we do not let the user follow the "empty" link
	if(this.getElementsByTagName("img")[0].longDesc){
		
		SHI_itemDescription.href = this.getElementsByTagName("img")[0].longDesc;
		SHI_itemDescription.target = "_blank"; //hinzugefügt am 7.1.2010
		//SHI_itemDescription.onclick = fensterpop(this.getElementsByTagName("img")[0].longDesc,'Order'); //hinzugefügt am 14.1.2010
		//var SHI_onClick = document.createElement('a');
		//SHI_onClick.onclick = fensterpop(this.getElementsByTagName("img")[0].longDesc,'Order');
// appendData() breaks IE5 Win
		// verlinkter Text unter großem Bild!!!
		SHI_itemDescription.firstChild.data=this.title+" [more info/ORDER]";
		SHI_itemDescription.title = "Follow this link to the orderform";	
	}else{
		SHI_itemDescription.removeAttribute("href");	
		SHI_itemDescription.title = "";	
	}
	// we set the starting values for the "counter"
	//var current = eval(SHI_itemTitle.hash.substring(1)) + 1; auskommentiert am 7.1.2010
	//SHI_zCounter.firstChild.nodeValue = "Slide #"+current+" out of "+SHI_anchor.length; auskommentiert am 7.1.2010	
	// hiding the button when everything "loads" depending on which slide we are on
	// first we reset both buttons in case they have been turned off last time the user left the slideshow
	SHI_navNext.className="nonOpaque";
	SHI_navPrev.className="nonOpaque";
	SHI_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
	if(SHI_itemNumber==0){
		SHI_navPrev.className="transparent";
		SHI_navNext.className="nonOpaque";
	}
	if(SHI_itemNumber==document.getElementById(SHI_gallery).getElementsByTagName("a").length-1){
		SHI_navNext.className="transparent";
		SHI_navPrev.className="nonOpaque";
	}
	return false;	
}
