function openWin(url,w,h,resize) {
	var wint = (screen.height-h)/2;
	var winl = (screen.width-w)/2; 
	var win  = window.open(url,'_blank','width=' + w + ',height=' + h + ',resizable=' + resize + ',scrollbars=1,menubar=0,status=1,top=' + wint + ',left=' + winl);
}

function enlargeImage(img,w,h,print) {
	if (print == 1) {
		h = h+20;
	}
	var wint = (screen.height-h)/2;
	var winl = (screen.width-w)/2;
	var win  = window.open('/enlarge.php?img=' +img+ '&print=' +print+ '','_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width='+w+',height='+h+',top='+wint+',left='+winl+'')
}


function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = '*';
	var elems = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var i = 0;
	for (var j = 0; j < elems.length; j++) {
		if ( pattern.test(elems[j].className) ) {
			classElements[i++] = elems[j];
		}
	}
	return classElements;
}

function safeMail() {
	var safemails = getElementsByClass('safemail',null,'a');
	if (safemails) {
		for (i=0; i < safemails.length; i++) {
			safemails[i].href = safemails[i].href.replace('http://www.', 'mailto:');
			temp = safemails[i].href.split('/');
			temp[0] = temp[0].replace('mailto:','');
			temp = temp[1]+String.fromCharCode(64)+temp[0];
			safemails[i].innerHTML = temp;
			safemails[i].href = 'mailto:'+temp;
			safemails[i].className = '';
		}
	}
};

function findFirstChild(elm) {
	if ( !elm.childNodes.length ) return;
	var children = elm.childNodes.length;
	for ( var i = 0; i <= children; ++i )
		if ( elm.childNodes[i].nodeType == 1 ) return elm.childNodes[i];
	return;
}

function initSubMenus() {
	if (document.getElementById('menu') == undefined) return false;
	var menu = document.getElementById('menu');
	var smhs = getElementsByClass('smh',null,'li');
	var sms = getElementsByClass('sm',null,'ul');
	for (j=0; j<menu.childNodes.length; j++) {
		node = menu.childNodes[j];
		if (node.nodeName == "LI") 
			node.onmouseover = function() {
				sms[0].style.display = 'none';
				sms[1].style.display = 'none';
				sms[2].style.display = 'none';
				sms[3].style.display = 'none';
			}
	}
	
	var fch = smhs[0];
	fch.onmouseover = function() { sms[0].style.display = 'block'; }
	sms[0].onmouseover = function() { sms[0].style.display = 'block'; }
	sms[0].onmouseout = function() { sms[0].style.display = 'none'; }
	
	var fch = smhs[1];
	fch.onmouseover = function() { sms[1].style.display = 'block'; }
	sms[1].onmouseover = function() { sms[1].style.display = 'block'; }
	sms[1].onmouseout = function() { sms[1].style.display = 'none'; }
	
	var fch = smhs[2];
	fch.onmouseover = function() { sms[2].style.display = 'block'; }
	sms[2].onmouseover = function() { sms[2].style.display = 'block'; }
	sms[2].onmouseout = function() { sms[2].style.display = 'none'; }
	
	var fch = smhs[3];
	fch.onmouseover = function() { sms[3].style.display = 'block'; }
	sms[3].onmouseover = function() { sms[3].style.display = 'block'; }
	sms[3].onmouseout = function() { sms[3].style.display = 'none'; }
}

function showBanner(movie) {
	var so = new SWFObject('/images2/banners/' + movie, 'bannermovie', '468', '60', '8', '#000000');
	so.write('bannermovie');
}

addEvent(window, 'load', safeMail);
addEvent(window, 'load', initSubMenus);
