function ajaxpage_callback() {
	if ($(document.body).hasClassName('nm_currentPage_photogallery')) {
		webkit.modinit('photogallery');
	}
}

// informs function "ajax" in webkit.js as to whether page being called is calendar page
var calendarPage = "/calendar.php";

var calendar_slidestart = "#D7EDEB";
var calendar_slidefinish = "#F7F8F8";

function mediaplayer_js(songID) {
	if (songID) {           self.frames['mediaplayer'].location.href='nm_webkit/templates/mediaplayer.php?width=400&height=40&downloadbutton=0&medialoader=1&firstload=0&songID=' + songID;
}
}

function checkrequired(which) {
	var pass=true;
	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) {
					pass=false;
					break;
				}
			}
		}
	}
	if (!pass) {
		shortFieldName=tempobj.name.substring(8,30).toUpperCase();
		alert("There are missing fields in this form. Please make sure that all required fields are properly completed.");
		return false;
	}
	else
	return true;
}

function clearfield() {
	if (document.contact.requiredcontent.value == 'enter the content of your email message here') {
		document.contact.requiredcontent.value = '';
	}
}

document.observe('dom:loaded', function () {
	webkit.initAjaxLinks('buttonbar');		
	if ($(document.body).hasClassName('nm_currentPage_calendar')) {
		webkit.initCalAjaxLinks();
	}
	else {
		webkit.initAjaxLinks();	
	}
	if ($(document.body).hasClassName('nm_currentPage_media')) {
		activateObservers('media');		
	}
	else if ($(document.body).hasClassName('nm_currentPage_photogallery')) {
		webkit.modinit('photogallery');
	}
});

function activateObservers(page) {
	if (page == "media") {
		// page anchors
		$$('#pageanchors li a').each(function(o) {
			o.stopObserving('click');
			o.observe('click', function(e) {
				e.stop();
				var thisID = o.id.replace(/_anchor$/,'');
				new Effect.ScrollTo(thisID, { duration:0.5});
			})
		})

		// cancel observers for download links
		$$('#interviewdownloads li a').each(function(o) {
			o.stopObserving('click');
		});		
	}
}

function ajaxpage_callback(page) {
	if (page.match(/media\.php$/)) {
		activateObservers('media');
	}
	if ($('photogallery_wrapper')) {
		webkit.modinit('photogallery');
	}
}
