
function openMov() {

	var url = 'movie.html';
	var width = 361;
	var height = 300;
	var title = 'lojoball';

	var x = (640 - width)/2;
	var y = (480 - height)/2;
	if (screen) {
		y = (screen.availHeight - height)/2;
		x = (screen.availWidth - width)/2;
	}

	var properties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',top=' + y + ',left=' + x
	popup = window.open(url, title, properties);
	popup.focus();
}

function addEvent (obj, type, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(type, fn, false);
	}
	else if (obj.attachEvent) {
		obj['e' + type + fn] = fn;
		obj[type + fn] = function() {
			obj['e' + type + fn](window.event);
		};
		obj.attachEvent('on' + type, obj[type + fn]);
	}
}


addEvent(window, 'load', function() {
	// fix google toolbar auto fill colour
	// http://code.jenseng.com/google/
	var inputs = ['name', 'email', 'message', 'password', 'firstname', 'lastname', 'email_address', 'confirm_email_address', 'street_address', 'suburbs', 'city', 'state', 'postcode', 'country', 'telephone'];
	for (var i = 0; i < inputs.length; i++) {
		if ($(inputs[i])) {
			$(inputs[i]).onpropertychange = function () {
				if (this.style.backgroundColor != '') {
					this.style.backgroundColor = '#fff';
				}
			}
		}
	}
	
	if (typeof $$ != 'undefined') {
		$$('a.jplightbox').each(function (e) {
			e.addEvent('click', function (evt) {
				evt.stop();
				Popup.load(this.get('href') + '?inline=1');
			});
		});
	}
});


if (typeof $ == 'undefined') {
	function $(element) {
		if (typeof element == 'string' && element.length > 0) {
			element = document.getElementById(element);
		}
		return element;
	}
}

function $t(str) {
	return document.createTextNode(str);
}

Popup = {
	container: 'detailcontainer',
	created: false,
	detailimg: 'detailimg',
	xml: '',
	lastHref: null,

	load:	function (href, container, detailimg) {
		if (container) Popup.container = container;
		if (detailimg) Popup.detailimg = detailimg;

		if (Popup.created && href == Popup.lastHref) {
			Popup.show(Popup.xml);
			return;
		}
		var con = Popup.xhcon();
		if (!con) {
			return;
		}
		con.connect(href, 'GET', Math.random(), Popup.show);
		Popup.lastHref = href;
	},

	showImage: function(src) {
		var detailimg = $(Popup.detailimg);
		detailimg.src = src;
	},

	show: function (oXML) {
		Popup.xml = oXML;
		var str = oXML.responseText;
		if (/^\s$/.test(str) || str == '') {
			alert('Page not found');
			return;
		}

		$(Popup.container).style.display = 'none';
		$(Popup.container).innerHTML = str;

		var overlay = $('detailoverlay');
		if (overlay) {
			var sizes = Popup.getSizes();
			overlay.style.height = sizes.page.height + 'px';
			if (/msie/gi.test(navigator.userAgent.toLowerCase())) {
				overlay.style.filter = 'alpha(opacity=50)';
				overlay.style.width = sizes.page.width + 'px';
			}
			overlay.onclick = function (event) {
				Popup.hide();
			}
		}

		$(Popup.container).style.display = 'block';
		if ($('quantity')) {
			$('quantity').style.visibility = 'hidden';
		}

		Popup.created = true;
	},

	hide: function () {
		var container = $(Popup.container);
		if ($('quantity')) {
			$('quantity').style.visibility = 'visible';
		}
		container.style.display = 'none';
		// remove all children
		while (container.childNodes.length > 0) {
			container.removeChild(container.childNodes[0]);
		}
	},

	getSizes: function () {
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			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
			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 = windowWidth;
		}
		else {
			pageWidth = xScroll;
		}


		return { page: {width: pageWidth, height: pageHeight}, window: {width: windowWidth, height: windowHeight }};
	},

	xhcon:		function () {
		var xmlhttp, bComplete = false;
		try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (e) { try { xmlhttp = new XMLHttpRequest(); }
		catch (e) { xmlhttp = false; }}}
		if (!xmlhttp) {
			return null;
		}
		this.connect = function(sURL, sMethod, sVars, fnDone) {
			if (!xmlhttp) {
				return false;
			}
			bComplete = false;
			sMethod = sMethod.toUpperCase();

			try {
				if (sMethod == "GET") {
					xmlhttp.open(sMethod, sURL+"&"+sVars, true);
					sVars = "";
				}
				else {
					xmlhttp.open(sMethod, sURL, true);
					xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				}
				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4 && !bComplete) {
						bComplete = true;
						fnDone(xmlhttp);
					}
				};
				xmlhttp.send(sVars);
			}
			catch(z) { return false; }
			return true;
		};
		return this;
	}
}