// ######################################
// ######################################
// Javascript Popups
// Copyright Artlogic www.artlogic.net
// ######################################


// Open the popup layer
function displayImage(which) {
	if (window.location.pathname =='/browse/') {
		document.getElementById('browseSearch').style.visibility = "hidden";
	}	
	var mask = document.getElementById('mask');
	new Effect.Appear(mask, {duration:0.5});
	
	var popupContainer = document.getElementById('popupContainer');
	new Effect.Appear(popupContainer, {duration:0.5});
	
	document.getElementById('popupContentArea').innerHTML = document.getElementById('popupContent' + which).innerHTML;
	
	window.setTimeout("displayImage2(" + which + ")", 1000);
}
	function displayImage2(which) {
		document.getElementById('mask').style.opacity = "1";
		
		frames['movieFrame'].location.href = movies[which];
	}

// Remove the popup layer
function removeLayer() {
	frames['movieFrame'].location.href = '/flgui/images/shim.gif';
	document.getElementById('mask').style.display = 'none';
	document.getElementById('popupContainer').style.display = 'none';
	if (window.location.pathname =='/browse/') {
		document.getElementById('browseSearch').style.visibility = "visible";
	}
}

// Show next popup
function nextImage(which) {
	var nextOne = parseInt(arguments[0]) + 1;
	
	document.getElementById('popupContentArea').innerHTML = document.getElementById('popupContent' + nextOne).innerHTML;
	
	frames['movieFrame'].location.href = movies[nextOne];
}

// Show previous popup
function previousImage(which) {
	var previousOne = parseInt(arguments[0]) - 1;
	
	document.getElementById('popupContentArea').innerHTML = document.getElementById('popupContent' + previousOne).innerHTML;
	
	frames['movieFrame'].location.href = movies[previousOne];
}


// Show rollover caption on list pages
function displayCaption(which) {
	document.getElementById('captionShower').innerHTML = which;
}
function noCaption() {
	document.getElementById('captionShower').innerHTML = '';
}


// Automatically open layer if there is the corresponding hash in the URL
function checkHash() {
	var l = document.location.hash;
	if (l) {
		var s = l.split('#');
		if (s.length > 1) {
			var hashValue = s[1]
			if (hashValue.length > 0) {
				displayImage(hashValue);
			}
		}
	}
}



// For news stories
function nextStory(which) {
	var nextOne = parseInt(arguments[0]) + 1;
	document.getElementById('newsViewer').style.display = 'none';
	
	window.setTimeout("nextStory2('" + nextOne + "')",100);
}
	function nextStory2(which) {
		document.getElementById('newsViewer').innerHTML = document.getElementById('popup' + which).innerHTML;
		new Effect.SlideDown('newsViewer', {duration:0.5});
	}
function previousStory(which) {
	var nextOne = parseInt(arguments[0]) - 1;
	document.getElementById('newsViewer').style.display = 'none';
	
	window.setTimeout("previousStory2('" + nextOne + "')",1);
}
	function previousStory2(which) {
		document.getElementById('newsViewer').innerHTML = document.getElementById('popup' + which).innerHTML;
		new Effect.SlideDown('newsViewer', {duration:0.5});
	}




var addClass = function(el, className) {
	var classes=el.className.toString();
	if ((" " + classes + " ").indexOf(" " + className + " ") == -1) {
		var newClasses = (classes == "") ? className : classes + " " + className;
		el.className=newClasses;
	}
}

var removeClass = function(el, className) {
	var classes=el.className.toString().split(" ");
	var newClasses = new Array();
	for (var i = 0; i < classes.length; i++) {
		if (classes[i] != className) {
			newClasses[newClasses.length] = classes[i];
		}
	}
	el.className = newClasses.join(" ");
}

 
