//Initialize Webpage and Page Elements
window.addEvent("domready", function( ) {
	if( $("L") || $("R") ) {
		heightL = $("L").getSize( ).y + $("header").getSize( ).y + 78;
		heightR = $("R").getSize( ).y + $("header").getSize( ).y + 78;
		if( heightL<window.getSize( ).y && heightR<window.getSize( ).y ) {
			$("footer").setStyle("position","absolute");
			$("footer").setStyle("top",window.getSize( ).y-130);
		}
	}
	//Common Elements :: Navigation Menu
	if( $("navMenu") ) {
		new Fx.MorphList("navMenu",{"bg":{"class":"menuBG"}});
		var subMenus = $$(".subMenu");
		if( subMenus ) {
			subMenus.setOpacity(0);
			parentMenu = subMenus.getParent( );
			subMenus.addEvents({
				"mouseover": function( ){ this.fade("in"); },
				"mouseout": function( ){ this.fade("out"); }
			});
			parentMenu.addEvents({
				"mouseover": function( ){ this.getChildren(".subMenu").fade("in"); },
				"mouseout": function( ){ this.getChildren(".subMenu").fade("out"); }
			});
		}
	}
	//Common Elements :: Image Zoom (Faux LightBox)
	if( $("zoom") ) {
//		$("zoom").setOpacity(0); $("zoom").setStyle("display","none");
		var imageWidth, imageHeight;
		$("zoom").addEvents({
			"click": function( event ){
				event.stop( );
//				$("zoom_BG").fade(0.5,0);
				this.fade("out");
				imageWidth = $("zoom_Image").getSize( ).x;
				imageHeight = $("zoom_Image").getSize( ).y;
				$("zoom_Image").setAttribute("src","images/_spacer.gif");
//				$("zoom_Image").setStyle("height",imageHeight+"px");
//				$("zoom_Image").setStyle("width",imageWidth+"px");
			}
		});
		$$(".showZoom").addEvents({
			"click": function( event ){
				event.stop( );
				$("zoom_Image").setAttribute("src",this.href);
				$("zoom_Caption").set("html",this.getAttribute("zoomCaption"));
				$("zoom_SubCaption").set("html",this.getAttribute("zoomSubCaption"));
				$("zoom_PLink").setStyle("height",$("zoom_Image").getSize( ).y+"px");
				$("zoom_PLink").setStyle("width",$("zoom_Image").getSize( ).x/2+"px");
				$("zoom_NLink").setStyle("height",$("zoom_Image").getSize( ).y+"px");
				$("zoom_NLink").setStyle("width",$("zoom_Image").getSize( ).x/2+"px");
				$("zoom").setStyle("display","block"); $("zoom").fade("in");
//				$("zoom_BG").fade(0,0.5);
			}
		});
	}
	//HomePage :: What's On Show
	if( $("slideshow") ) {
		window.addEvent("domready", function( ) {
			new Fx.Slideshow( "menu","pictures","loading",{auto: true,autostart: true,autointerval: 5000} );
		});
	}
	//Web Forms :: Feedback Form
	if( $('feedbackForm') )
		initializeForm( "FeedbackForm" );
});
