var pictures = new Array("img/header/header4.jpg","img/header/header2.jpg","img/header/header3.jpg","img/header/header1.jpg");
var numPics = pictures.length;
var Pic = 0;

function flowPics() {
	setInterval('initImage()',6000);
}

function initImage() {
	if (Pic == numPics-1) {
		Pic = 0;
	}
	else {
		Pic = Pic + 1;
	}
	newImage = "url('" + pictures[Pic] + "')";
	header = document.getElementById('header');
	setOpacity(header, 10);
	header.style.backgroundImage = newImage;
	fadeIn('header', 10);	
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;

	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";

	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;

	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;

	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 1;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 5);
		}
	}
}


window.onkeyup = function (event) {

	if (event.keyCode == 27) {
		closePopup();
	}

}



function attendPic(picid) {

	picbox = document.getElementById('picbox'+picid);
	picbox.className = 'attended_picbox';

}

function n_attendPic(picid) {

	picbox = document.getElementById('picbox'+picid);
	picbox.className = 'row_pics';

}

function popupPic(imgurl, imgname) {

	popupboxparent = document.getElementById('pic_popup_box_parent');
	popupboxparent.style.display = 'block';
	picbox = document.getElementById('bigpicbox');
	picbox.innerHTML = "<img class='popupped_pic' src='"+imgurl+"'><p class='poppic_comment'>"+imgname+"</p>"

}

function closePopup() {
	
	popupboxparent.style.display = 'none';
	
}
