function addLoadEvent ( func ) {
	var oldonload = window.onload;
	if ( typeof window.onload != 'function' ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	}
}

var RecaptchaOptions = {
	theme : 'clean'
}

var pageLoaders = {
	init : function ( ) {
		var content = document.getElementById("content");
		var directionals = document.getElementById("directionals");
		var contentHeight = 0;
		if ( directionals && content ) {
			var directHeight = $("directionals").getHeight();
			contentHeight = $("content").getHeight();
			if ( contentHeight < directHeight ) {
				content.style.height = ( directHeight ) + "px";
			}
		}


		var imgList = document.getElementById("imgs");
		if ( imgList ) {
			var imgLinks = imgList.getElementsByTagName("a");
			var imgSrcs = "";
			for ( i=0; i<imgLinks.length; i++ ) {
				imgSrcs = imgLinks[i].getElementsByTagName("img");
				if ( imgSrcs.length ) {
					imgLinks[i].onclick = new Function( "return lst.imgPop(this.href,"+i+");" );
					if ( i>0 ) {
						imgLinks[i].onmouseover = new Function( "return lst.imgRoll(this.href);" );
						lst.slideImgs[i-1] = imgLinks[i].href;
						lst.numSlides++;
					}
				}
			}
			var imgBlock = document.createElement("div");
			imgBlock.id = "blowUp";
			imgBlock.style.display = "none";

			var blockImg = document.createElement("img" );
			blockImg.width = "640";
			blockImg.height = "480";
			blockImg.id = "blockImg";
			blockImg.src = "";
			blockImg.onclick = new Function( "lst.imgClear();" );
			imgBlock.appendChild(blockImg);

			var blockImg1 = document.createElement("img" );
			blockImg1.width = "640";
			blockImg1.height = "480";
			blockImg1.id = "blockImg1";
			blockImg1.src = "";
			blockImg1.style.display = "none";
			blockImg1.onclick = new Function( "lst.imgClear();" );
			imgBlock.appendChild(blockImg1);

			var slideBut = document.createElement("input");
			slideBut.type = "button";
			slideBut.value = "Slide Show/Next";
			slideBut.onclick = new Function( "lst.slideShow();" );
			imgBlock.appendChild(slideBut);

			var closeImg = document.createElement("input");
			closeImg.type = "button";
			closeImg.value = "Close/Stop";
			closeImg.onclick = new Function( "lst.imgClear();" );
			imgBlock.appendChild(closeImg);
			
			document.body.appendChild(imgBlock);
		}
	}
}

var contactForms = {
	contactCheck : function ( ) {
		var msg = "";
		var fname = document.getElementById("First_Name");
		var lname = document.getElementById("Last_Name");
		var email = document.getElementById("Your_Email");
		var phone = document.getElementById("Your_Phone");
		if ( fname.value == "" ) {
			msg += "Please enter your first name.\n";
		}
		if ( lname.value == "" ) {
			msg += "Please enter your last name.\n";
		}
		if ( email.value == "" ) {
			msg += "Please enter your email address.\n";
		}
		if ( phone.value == "" ) {
			msg += "Please enter your phone number.\n";
		}
		if ( msg ) {
			alert( msg );
			return false;
		}
		return true;
	}
}

var lst = {
	showInProgress : "",
	slideImgs : {  },
	numSlides : 0,
	nextSlide : 0,
	slideBlock : 0,
	imgPop : function ( img, i ) {
		lst.nextSlide = i;
		var blowUp = document.getElementById("blowUp");
		if ( blowUp ) {
			var blockImg = document.getElementById("blockImg");
			var blockImg1 = document.getElementById("blockImg1");
			blockImg.style.display = "block";
			blockImg1.style.display = "none";
			lst.slideBlock = 0;
			blockImg.style.left = ((($("blowUp").getWidth())-640)/2)+"px";
			blockImg1.style.left = ((($("blowUp").getWidth())-640)/2)+"px";
			if ( blockImg ) {
				blockImg.src = img;
				new Effect.Appear( "blowUp", {duration: 0.8} );
			}
		}
		return false;
	},
	imgRoll : function ( img ) {
		var marquisImg = document.getElementById("marquis");
		if ( marquisImg ) {
			var marquis = marquisImg.parentNode;
			if ( marquis ) {
				marquisImg.src = img;
				marquis.href = img;
			}
		}		
	},
	imgClear : function ( ) {
		if ( lst.showInProgress ) {
			clearTimeout(lst.showInProgress);
		}
		var blowUp = document.getElementById("blowUp");
		if ( blowUp ) {
			new Effect.Fade( "blowUp", {duration: 0.8} );
		}
		return false;
	},
	slideShow : function ( ) {
		clearTimeout(lst.showInProgress);
		var slideImg = document.getElementById("blockImg");
		var slideImg1 = document.getElementById("blockImg1");
		if ( lst.nextSlide >= lst.numSlides ) {
			lst.nextSlide = 0;
		}
		if ( lst.slideBlock == 0 ) {
			slideImg1.src = lst.slideImgs[lst.nextSlide];
			new Effect.Parallel([
				new Effect.Fade(slideImg,{sync: true}),
				new Effect.Appear(slideImg1,{sync: true})],
				{ duration: 0.8 } );
				lst.slideBlock = 1;
		} else {
			slideImg.src = lst.slideImgs[lst.nextSlide];
			new Effect.Parallel([
				new Effect.Fade(slideImg1,{sync: true}),
				new Effect.Appear(slideImg,{sync: true})],
				{ duration: 0.8 } );
				lst.slideBlock = 0;
		}
		lst.nextSlide++;
		lst.showInProgress = setTimeout( "lst.slideShow()" , 3000);
	},
	largeImgs : function ( ) {
		var imgBlock = document.getElementById("blowUp");
		if ( imgBlock ) {
			new Effect.Appear( "blowUp", {duration: 0.8} );
		}
		return false;
	}
}

if ( document.getElementById && document.getElementsByTagName ) {
	addLoadEvent(pageLoaders.init);
}