function subNav() {
	if (document.all) {
		nodeList = $("buttons").getElementsByTagName('li');
		nodes = $A(nodeList);
		nodes.each(function(node) {
			elem = $A(document.getElementsByClassName('sub-buttons', node));
			if (elem.length == 0) {
				elem = $A(document.getElementsByClassName('sub-sub-buttons', node));
			}
			if (elem.length > 0) {
				if (elem.length > 0) {
					node.onmouseover=function() {
						Element.addClassName(this, 'over');

					}
					node.onmouseout=function() {
						Element.removeClassName(this, 'over');
					}
				}
			}
		});
	}
}

function popups() {
	nodeList = document.getElementsByClassName('popup');
	nodes = $A(nodeList);
	nodes.each(function(node) {
		node.onclick=function(e) {
			if (Element.hasClassName(node, '800-600')) {
				openWindow(this.href, 800, 600);
			} else if (Element.hasClassName(node, '640-480')) {
				openWindow(this.href, 640, 480);
			} else {
				openWindow(this.href);
			}
			return false;
		}
	});
}

/** simple fucnction to pre-load the rollovers */
function preLoadImages() {
	images = ['country_but_business_over.gif', 'country_but_home_over.gif', 'country_but_opportunity_over.gif'];
    var newImg = new Image();
    images.each(function(image) {
		newImg.src = '/themes/local/images/' + image;
	});
}

function rollovers() {
	images = $A(document.getElementsByClassName('rollover'));

	imgDivs = '<div id="mb-pic-home"><img src="/themes/local/images/country_home_photo.jpg" alt="" width="339" height="225" /></div>\n';
	imgDivs += '<div id="mb-pic-business"><img src="/themes/local/images/country_business_photo.jpg" alt="" width="339" height="225" /></div>\n';
	imgDivs += '<div id="mb-pic-opportunity"><img src="/themes/local/images/country_opportunity_photo.jpg" alt="" width="339" height="225" /></div>\n';

	new Insertion.Bottom('middle-bar', imgDivs);

	images.each(function(image) {
		image.origImg = image.src;
		image.overImg = image.src.substring(0, image.src.lastIndexOf('.')) + '_over.gif';
		image.bigPic = $('mb-pic');
		image.bigPicOver = 'mb-pic-' + image.origImg.substring(image.src.lastIndexOf('_') + 1, image.origImg.lastIndexOf('.'));
		Element.hide(image.bigPicOver);

		image.onmouseover=function() {
			this.src = this.overImg;
			new Effect.Appear(this.bigPicOver, {duration: .5});
		}
		image.onmouseout=function() {
			this.src = this.origImg;
			new Effect.Fade(this.bigPicOver, {duration: .5});
		}
	});
}

function delNews(id) {
	var doIt = confirm("Are you sure you would like to permanently delete this news item?");
	if (doIt) {
		document.newsDelForm.delId.value = id;
		document.newsDelForm.submit();
	}
}

function openWindow(path, w, h) {
    w = w == null ? 500 : w;
    h = h == null ? 300 : h;
	var name = 'elwindow';
	var scroll = 'yes';
	var winl = (screen.width - w) / 2;
	var newWindow = window.open(path, name, "scrollbars="+scroll+",width="+w+",height="+h+",top=100,left="+winl+",resizable=yes,toolbar=no,location=no");
	if (self.focus) newWindow.window.focus();
}