
// Carl Filip //
// Static variables and script
var currentPage = 1;
var imageArr = new Array();
var pages;

function preload(pictures) {
    for (i = 0; i < pictures.length; i++){
        imageArr[i] = new Image()
        imageArr[i].src = bigImagePath + pictures[i]
    }
}

function nextSlide() {
    document.getElementById('page' + currentPage).className = "prospect-image-page inactive-element"; //("class", "prospect-image-page inactive-element");
    currentPage++;
    document.getElementById('page' + currentPage).className = "prospect-image-page active-element"; //setAttribute("class", "prospect-image-page active-element");
    updatePrevNextButtons();
}
function prevSlide() {
    document.getElementById('page' + currentPage).className = "prospect-image-page inactive-element"; //("class", "prospect-image-page inactive-element");
    currentPage--;
    document.getElementById('page' + currentPage).className = "prospect-image-page active-element"; // setAttribute("class", "prospect-image-page active-element");
    updatePrevNextButtons();
}
function HideIt(el)
{
	if(el)
	{
		el.style.visibility = 'hidden';
		el.style.display = 'none';
	}	
}

function ShowIt(el)
{
	if(el)
	{
		el.style.visibility = 'visible';
		el.style.display = 'block';
	}
}
function updatePrevNextButtons() {

    if (currentPage == 1) {
		//toggleVisibility(document.getElementById('prevLink-box'));
		//toggleVisibility(document.getElementById('nextLink-box'));
		//if (document.getElementById('prevLink-box') == null) return;
        //document.getElementById('prevLink-box').setAttribute("class", "inactive-element");
		HideIt(document.getElementById('prevLink-box'));
		//if (document.getElementById('nextLink-box') == null) return;
        //document.getElementById('nextLink-box').setAttribute("class", "active-element");
        ShowIt(document.getElementById('nextLink-box'));
    } else if (currentPage == pages) {
        //document.getElementById('prevLink-box').setAttribute("class", "active-element");
        //document.getElementById('nextLink-box').setAttribute("class", "inactive-element");
		ShowIt(document.getElementById('prevLink-box'));
		HideIt(document.getElementById('nextLink-box'));
		
    } else {
        //document.getElementById('prevLink-box').setAttribute("class", "active_element");
        //document.getElementById('nextLink-box').setAttribute("class", "active_element");
		ShowIt(document.getElementById('prevLink-box'));
		ShowIt(document.getElementById('nextLink-box'));
	}
}
function swap(name) {
    document.images.bigImage.src = bigImagePath + imageAddresses[name];
}

// Friendly attach onload event //
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
    if (oldonload) {
        oldonload();
        }
            func();
        }
    }
}
 
var imageAddresses;
addLoadEvent(function() {
	if (imageAddresses == null) return;
	pages = Math.ceil(imageAddresses.length/6)
    updatePrevNextButtons();
    preload(imageAddresses);
})
//addLoadEvent(loaded);
//addLoadEvent(function() { alert('added onload'); })
// And Carl Filip is DONE! //


// Georg //
// Prospekt-mal //

/*
var prospectPage = 0;
var prospectLastPage = 0;
var prospectPicFile = new Array();
var prospectPicCount = 0;

function prospectAddImage(imgFile) 
{
	prospectPicFile[prospectPicCount] = imgFile;
	prospectPicCount++;
	if (prospectPicCount == 1)
	{
		prospectShowPic(0); 
	}
	prospectLastPage = Math.floor(prospectPicCount / 6);
}

function prospectShowPic(imgIndex)
{
	var mainImage =	document.getElementById('mainimage');
	if(mainImage == null) alert('mainimage not found');
	mainImage.innerHTML = '<img src="Arch/_img/w424/' + prospectPicFile[imgIndex] + '" />';	
}

function prospectLoadImagePage(newPage)
{
	prospectPage = newPage;
	var nextText = document.getElementById('nextimages');
	if(nextText == null) alert('nextText not found');
	var prevText = document.getElementById('previmages');
	if(prevText == null) alert('prevText not found');
	var firstImage = prospectPage*6;
	var lastImage = firstImage + 5;
	var offs = 0;
	if (prospectPage == 0)
	{
		prevText.style.visibility = "hidden";
		nextText.style.visibility = "visible";

	}
	else if (prospectPage == prospectLastPage)
	{
		prevText.style.visibility = "visible";
		nextText.style.visibility = "hidden";

	}
	else
	{
		prevText.style.visibility = "visible";
		nextText.style.visibility = "visible";

	}
	for (var i=firstImage;i<=lastImage;i++)
	{
		var thImage = document.getElementById('th' + offs);
		if(thImage == null) alert('th' + offs + ' not found');
		if (i < prospectPicCount) 
		{
			thImage.innerHTML = '<img src="Arch/_img/w87/' + prospectPicFile[i] + '" onClick="prospectShowPic(' + i + ')" />';
		}
		else
		{
			thImage.innerHTML = '<div style="border-width: 0px;width: 85px; height: 63px;"></div>';
		}
		offs++;
	}

}

function prospectNextMouseOver()
{
	var nextText = document.getElementById('nextimages');
	if(nextText == null) alert('nextText not found');
}

function prospectPrevMouseOver()
{
	var prevText = document.getElementById('previmages');
	if(prevText == null) alert('nextText not found');
}


function prospectLoadPrevImages() 
{
	if(prospectPage > 0) prospectLoadImagePage(prospectPage - 1); 
}

function prospectLoadNextImages() 
{
	if(prospectPage < prospectLastPage) prospectLoadImagePage(prospectPage + 1); 
}

*/
