function showPopup(url, name, height, width, scroll, resizable, statusbar, screenpos) {
	var Xwin = width;
	var Ywin = height;
	var Xsize = screen.availWidth;
	var Ysize = screen.availHeight;
	var Xpos = 0;
	var Ypos = 0;
	switch(screenpos) {
		case "topleft":
			Xpos = 0;
			Ypos = 0;
			break;
		case "topright":
			Xpos = Xsize - width;
			Ypos = 0;
			break;
		case "bottomleft":
			Xpos = 0;
			Ypos = Ysize - height;
			break;
		case "bottomright":
			Xpos = Xsize - width;
			Ypos = Ysize - height;
			break;
		default:
			Xpos = (Xsize - width) / 2;
			Ypos = (Ysize - height) / 2;
			break;
	}
	var popwin;
	var opts = "status=" + statusbar + ",resizable=" + resizable + ",scrollbars=" + scroll + ",height=" + Ywin + ",width=" + Xwin + ",left=" + Xpos + ",top=" + Ypos;
	popwin = window.open(url, name, opts);
	popwin.focus();
}

function showPopupQuick(url, name) {
	showPopup(url, name, 600, 1000, 1, 1, 1, 'default');
	return false;
}

function startList() { 
	if (document.all&&document.getElementById) { 
		navRoot = document.getElementById("menu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover=function() { 
					this.className += " over";
				}
				node.onmouseout=function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}
function bookmarkPage() {
	title = document.title;
	url = location.href;
	if (window.sidebar) {
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if (window.external) {
		// IE Favorite
		window.external.AddFavorite(url, title); 
	} else if (window.opera && window.print) {
		// Opera Hotlist
		return true;
	}
}

function printPage() {
	window.print();
}
function closePage() {
	window.close();
}
function sendPage() {
	window.location = "mailto:?subject=" + document.title + "&body=I%20thought%20you%20might%20be%20interested%20in%20this%20page%20on%20the%20Almac%20website%3A%0D%0A%0D%0APage%3A%20%20" + document.title + "%0D%0A%0D%0AAddress%3A%20%20" + window.location;
}

function selectPage(url) {
	$(document).ready(function(){
		$("ul#nav a[@href*='" + url + "']").attr("class", "selected").parents("ul, li, a").each(function(index) {
			$(this).attr("class", "selected").siblings("a").attr("class", "selected");
		});
		$("ul#nav a.selected").siblings("ul").each(function(index) {
			$(this).slideDown("slow");
		});
	});
}
$(document).ready(function(){
/*
	$("h1").flash(
        { 
            src: '/shared/chevin2.swf', 
            flashvars: { 
                css: [
                    '* {color:#666666;}',
                    'a {color:#444444;text-decoration: none;}',
                    'a:hover {text-decoration:underline;}'
                ].join(' ')
            }
        },
        {version:7},
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.height = 30;//$alt.height();
            htmlOptions.width = 530;//$alt.width();
            $alt.addClass('alt');
            $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
        }
	);
*/
	$("ul#nav>li>ul").each(function(index) {
		$(this).hide();
	});						   
	
	$("ul#nav>li>a").click(function() {
		//$(this).next().slideDown();
	});
	
	var path = location.pathname.substring(0).toLowerCase();	
	if (path != "") {
		//selectPage(path);
		$("ul#nav a[@href$='" + path + "']")
		.attr("class", "selected")
		.parents("ul, li, a").each(function(index) {
			$(this).attr("class", "selected").siblings("a").attr("class", "selected");
		});
	}
	$("ul#nav a.selected").siblings("ul").each(function(index) {
		$(this).slideDown("slow");
	});

	$("a#bookmark").click(function() {
		bookmarkPage();
	});
	$("a#print").click(function() {
		window.print();
	});
	$("a#send").click(function() {
		sendPage();
	});
	$("a#close").click(function() {
		closePage();
	});
	$("#content a[rel='lightbox']").lightBox();
	MM_preloadImages('/images/subNav/diagArc.gif','/images/subNav/sci.gif','/images/subNav/sci-over.gif','/images/subNav/sciArc.gif','/images/subNav/clinServ.gif','/images/subNav/clinServ-over.gif','/images/subNav/clinServArc.gif','/images/subNav/clinTech.gif','/images/subNav/clinTech-over.gif','/images/subNav/clinTechArc.gif','/images/subNav/pharma.gif','/images/subNav/pharma-over.gif','/images/subNav/pharmaArc.gif');
	startList();

	$(".alternate tr:odd").addClass("alternate1");
	$(".alternate tr:even").addClass("alternate2");


	$(".accordion a").click(function() {
		$(this).next().slideToggle("slow");
		return false;
	}).next().hide();
});