/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = function () {
	initRollovers();
}

currentEl = 'item_1';
currentNum = 1;

function toggleFAQ(number){

	if(document.getElementById("answer_"+number).className == "hiddenAnswer"){
		switchBlock("answer_"+number,"visibleAnswer");
	}else{
		switchBlock("answer_"+number,"hiddenAnswer");
	}
}

function toggleEl(el,class1,class2){

	if(document.getElementById(el).className == class1){
		switchBlock(el,class2);
	}else{
		switchBlock(el,class1);
	}
}

function switchBlock(el,theClass){
	document.getElementById(el).className = theClass; 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	theURL = 'http://pulitzerarts.org/signup.php';
	winName = '';
	features = 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
	
	window.open(theURL,winName,features);
}

function popUpConcertPlayer(theURL){
	window.open(theURL,"audioPlayer","width=550,height=430,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

var archiveLink;

function toggleArchive(el){
	archiveBlock = document.getElementById("archiveLinks");
	archiveLink = el;
	difference = archiveLink.offsetTop - 45;
	
	//difference = archiveLink.offsetTop;
	
	if(archiveLink.className == 'activeSubNav'){
		archiveLink.className = '';
		archiveBlock.className = "closed";
	}else{
		archiveLink.className = 'activeSubNav';
		archiveBlock.style.top = difference+"px";
		archiveBlock.className = "open";
	}
}

function closeArchives(){
	archiveBlock = document.getElementById("archiveLinks");
	archiveLink.className = '';
	archiveBlock.className = "closed";
}

/* Events Archive Pagination */
function getNewPage(newPage,section,archivesOnHome,archivesPerPage,totalPages,urlName){

	myConn = new XHConn();

	//document.getElementById('archiveLinks').innerHTML = "page="+newPage+"&archivesPerPage="+archivesPerPage+"&archivesOnHome="+archivesOnHome+"&section="+section+"&totalPages="+totalPages;
	if(!myConn) return false;
	myConn.connect('/includes/php/eventsArchivePagination.php', 'GET', "page="+newPage+"&archivesPerPage="+archivesPerPage+"&archivesOnHome="+archivesOnHome+"&section="+section+"&totalPages="+totalPages+"&urlName="+urlName, displayNewPage); 
}

function displayNewPage(oXML){
	document.getElementById('archiveLinks').innerHTML = oXML.responseText;
}