	// ie version sniffer
function vIe(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}

// scripts to show/hide details of an event

function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}

function showevent(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function hideevent(id) {
	//safe function to hide an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

// from http://www.webdeveloper.com/forum/showthread.php?t=72954

function processAjax(url) {
//force IE6 and earlier and small screens to use non-js link in calling anchor
var arrayPageSize = this.getPageSize();
//var oldIe = (vIe() < 7);
oldIe = (vIe() < 7) && (vIe() != -1);
if ((oldIe) || (arrayPageSize[0]<900)) {
return true;
} else {
// stretch opaque overlay to fill page and show it
setStyle('overlay', 'width', Math.max(arrayPageSize[0],2000) + 'px');
setStyle('overlay', 'height', Math.max(arrayPageSize[1],1500) + 'px');
setStyle('overlay', 'display', 'block');
// size and show event window in waiting state centred on viewport
setStyle('eventwin', 'width', 0.7*arrayPageSize[0] + 'px');
setStyle('eventwin', 'maxHeight', '160px');
setStyle('eventwin', 'left', 0.15*arrayPageSize[0] + 'px');
setStyle('eventwin', 'top', 0.4*arrayPageSize[2]-160 + 'px');
//setStyle('eventwin', 'top', '50px');
showevent('eventwin');
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = targetDiv;
try {
req.open("GET", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = targetDiv;
req.open("GET", url, true);
req.send();

}
}
//stop caller following href
return false;
}
}

function targetDiv() {
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
//document.getElementById('eventwin').innerHTML = req.responseText;
setTimeout('delayed()',100);
//showevent('eventwin');
} else {
alert("Problem: " + req.statusText);
}
}
}

function delayed() {
document.getElementById('eventwin').setAttribute("class", "showevent");
document.getElementById('eventwin').setAttribute("className", "showevent"); //IE
// size and show event window in ready state centred on viewport
// read page size again in case viewport has been resized while waiting for event details
var arrayPageSize = this.getPageSize();
setStyle('eventwin', 'width', 0.7*arrayPageSize[0] + 'px');
setStyle('eventwin', 'maxHeight', 0.85*arrayPageSize[2] + 'px');
setStyle('eventwin', 'left', 0.15*arrayPageSize[0] + 'px');
setStyle('eventwin', 'top', 0.1*arrayPageSize[2] + 'px');
document.getElementById('eventdetail').innerHTML = req.responseText;
showevent('eventwin');
// size the iframe used by spektrix
setStyle('spekframe','height', 0.7*arrayPageSize[2] + 'px');
}

// request to close event div - hide the overlay and event div; reset the class and content of the event window
function closeEvent() {
//force IE6 and earlier to use non-js link in calling anchor
var lteIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
if (lteIE6) {
return true;
} else {
setStyle('overlay', 'display', 'none');
setStyle('eventwin', 'display', 'none');
document.getElementById('eventwin').setAttribute("class", "waitevent");
document.getElementById('eventwin').setAttribute("className", "waitevent"); //IE
document.getElementById('eventdetail').innerHTML = "&nbsp;";
}
}

// open a window to receive trailer details; parameter=id of film on filmtrailer.com

function showTrailer(filmId) {
//	if (! window.focus)return true;
	var href;
	var windowparams;
	var arrayPageSize = this.getPageSize();
	href='trailer.asp?fId='+filmId
	// close event div and restore underlying diary
	// essential to getElementById BEFORE hiding divs
	setStyle('overlay', 'display', 'none');
	setStyle('eventwin', 'display', 'none');
	document.getElementById('eventwin').setAttribute("class", "waitevent");
	document.getElementById('eventwin').setAttribute("className", "waitevent"); //IE
	document.getElementById('eventdetail').innerHTML = "&nbsp;";
	//
	windowparams='width='
	windowparams+=700
	windowparams+=', height='
	windowparams+=500
	windowparams+=', resizable=no, scrollbars=yes, titlebar=no, toolbar=no, location='
	windowparams+='no'
	windowparams+=', directories=no, menubar=no, status=no, copyhistory=no, dependent=yes,'
	windowparams+='screenX='
	windowparams+=(arrayPageSize[0]-700)/2
	windowparams+=', screenY='
	if (arrayPageSize[2]>550) {
		windowparams+=100;
	} else {
		windowparams+=20;
	}
	windowparams+=', left='
	windowparams+=(arrayPageSize[0]-700)/2
	windowparams+=', top='
	if (arrayPageSize[2]>550) {
		windowparams+=100;
	} else {
		windowparams+=20;
	}
	windowparams+=', titlebar=no';
	window.open(
				href,
				'_blankt',
				windowparams);
//	return false;
}

    //
    //  getPageSize()
    //  returns array: pixel width/height of page, height of viewport
    //
    function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight,windowHeight];
	}