/* ############################## */
/* Global Javascript              */
/* ############################## */

function preloadRollovers() {
	if (document.images) {
		var preloaded = new Array();
		var myImages = new Array("images/btn_calendar2.jpg",
								 "images/btn_comments2.jpg",
								 "images/btn_gallery2.jpg",
								 "images/btn_specialevents2.jpg",
								 "images/toggle_collapse.jpg",
								 "images/toggle_expand.jpg"
								 );
		
		for (i = 0; i < myImages.length; i++) {
			preloaded[i] = new Image;
			preloaded[i].src = myImages[i];
		}
	}	
}

function flash(name, w, h) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="'+name+'" align="middle">');
	document.write('	<param name="allowScriptAccess" value="sameDomain" />');
	document.write('	<param name="movie" value="flash/'+name+'.swf" />');
	document.write('	<param name="quality" value="high" />');
	document.write('	<param name="scale" value="noscale" />');
	document.write('	<param name="bgcolor" value="#000000" />');
	document.write('	<embed src="flash/'+name+'.swf" quality="high" scale="noscale" bgcolor="#000000" width="'+w+'" height="'+h+'" name="'+name+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function rollOver(id, num) {
	document.getElementById(id).src = "images/"+id+""+num+".jpg";
}

function popup(url, name, w, h, s) {
	window.open(url, name, 'width='+w+', height='+h+', location=no, resizable=no, menubar=no, scrollbars='+s+', status=no, toolbar=no');
}

function centerMe(w, h) {
	var x = Math.round((screen.width - w) / 2);
	var y = Math.round((screen.height - h) / 2);
	
	window.moveTo(x, y);
}

function getCount(id, leaveOne) {
	var count = 0;
	
	while (document.getElementById(id+""+count))
		count += 1;
		
	if (leaveOne)
		count -= 1;
		
	return count;
}

function collapseAllOnLoad(id, image) {
	for (i = 0; i < getCount(id, true); i++) {
		document.getElementById(id+""+i).style.display = "none";
		document.getElementById(image+""+i).src = "images/toggle_expand.gif";
	}
}

function collapseAll(id) {
	for (i = 0; i < getCount(id); i++) {
		document.getElementById(id+""+i).style.display = "none";
		document.getElementById("toggle"+i).src = "images/toggle_expand.gif";
	}
}

function expandAll(id) {
	for (i = 0; i < getCount(id); i++) {
		document.getElementById(id+""+i).style.display = "block";
		document.getElementById("toggle"+i).src = "images/toggle_collapse.gif";
	}
}

function toggle(image, id) {
  	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
		document.getElementById(image).src = "images/toggle_collapse.gif";
	} else {
		document.getElementById(id).style.display = "none";
		document.getElementById(image).src = "images/toggle_expand.gif";
	}
}