// JavaScript Document
$(document).ready(function() {
	SwapSetup();
	$('#gallery a').lightBox();
});

function SwapSetup(){
	var x = document.getElementsByTagName("img");
	for (var i=0;i<x.length;i++){
		var oversrc = x[i].getAttribute("oversrc");
		if (!oversrc) continue;
		// preload image
		x[i].oversrc_img = new Image();
		x[i].oversrc_img.src = oversrc;
		x[i].src_img = new Image();
		x[i].src_img.src = x[i].src;
		// set event handlers
		x[i].onmouseover = new Function("Swap(this, 'oversrc');");
		x[i].onmouseout = new Function("Swap(this, 'origsrc');");
		// save original src
		x[i].setAttribute("origsrc", x[i].src);
	}
	
	var x = document.getElementsByTagName("input");
	for(var i=0;i<x.length;i++) {
		var oversrc = x[i].getAttribute("oversrc");
		if (!oversrc) continue;
		// preload image
		x[i].oversrc_img = new Image();
		x[i].oversrc_img.src = oversrc;
		x[i].src_img = new Image();
		x[i].src_img.src = x[i].src;
		// set event handlers
		x[i].onmouseover = new Function("Swap(this, 'oversrc');");
		x[i].onmouseout = new Function("Swap(this, 'origsrc');");
		// save original src
		x[i].setAttribute("origsrc", x[i].src);
	}
}

//	Image rollover function
function Swap(el,which){
	el.src = el.getAttribute(which || "origsrc");
}

//Facebook window
function openFB(theText, title) {
   window.open("http://www.facebook.com/share.php?u=" + theText + "&t=" + title, "fbWnd", 'width=610,height=400,resizeable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
}
