// JavaScript Document
var index=1;
var div=true;
var numpictures=3;
var started=false;

function headshow (){
	var transparency = 0
	if(!started){
		started=true;
		index = Math.ceil(Math.random()*numpictures)
		top = document.getElementById("headdiv0");
		top.src = "../../Images/Headers/head"+index+".jpg";
		index = index + 1;
		if (index > numpictures){
			index = 1;
		}
		down = document.getElementById("headdiv1");
		down.src = "../../Images/Headers/head"+index+".jpg";
		down.style.opacity = transparency/100;
		down.style.filter = "alpha(opacity=" + transparency +")";
		return setTimeout("headshow()",7500);
	}
	index = index + 1;
	if (index > numpictures){
		index = 1;
	}
	if (div){
		var top = document.getElementById("headdiv0");
		var down = document.getElementById("headdiv1");
		div = false;
	}
	else {
		var down = document.getElementById("headdiv0");
		var top = document.getElementById("headdiv1");
		div = true;
	}
	down.src = "../../Images/Headers/head" + index + ".jpg";
	interval = setInterval("adjust()",50);
	this.adjust = function (){
		transparency = transparency + 5;
		topacity = (100 - transparency)/100;
		opacityAsInt = 100 - transparency;
		top.style.opacity = topacity;
		down.style.opacity = transparency;
		top.style.opacity = (topacity);
		top.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
		down.style.opacity = transparency/100;
		down.style.filter = "alpha(opacity=" + transparency +")";
		if (transparency == 100){
			clearInterval(interval);
		}
	}
	return setTimeout("headshow()",7500);
}

function newsPics(numPics,newsID,lang){
	this.position = 1;
	this.numPics = numPics;
	this.newsID = newsID;
	this.pics = new Array(numPics);
	
	this.addPic = function(path, index)
	{
		this.pics[index] = path;		
	}
	
	this.setStartPic = function()
	{
		picContainer = document.getElementById('newsItemPic');
		picContainer.src = "../../Images/newsItems/"+lang+"/news"+this.newsID+"/"+this.pics[0];
	}

	this.prev = function() {
		picContainer = document.getElementById('newsItemPic');
		this.position -= 1;
		if (this.position < 1){
			this.position = this.numPics;
		}
		picContainer.src = "../../Images/newsItems/"+lang+"/news"+this.newsID+"/"+this.pics[this.position - 1];
	};
	this.next = function() {
		picContainer = document.getElementById('newsItemPic');
		this.position += 1;
		if (this.position > this.numPics){
			this.position = 1;
		}
		newPic = "this.pic"+this.position;
		picContainer.src = "../../Images/newsItems/"+lang+"/news"+this.newsID+"/"+this.pics[this.position - 1];
	};
}
