Malibu = {
	init : function( controller ) {

		dojo.query("#header img").onmouseover( Malibu.nav.mouseover ).onmouseout( Malibu.nav.mouseout );

		if ( Malibu[controller] && Malibu[controller].init ) {
			Malibu[controller].init();
		}
		
		Malibu.preload( [
		              '/images/nav/hover/amenities.gif',
		              '/images/nav/hover/apartments.gif',
		              '/images/nav/hover/contact_schedule.gif',
		              '/images/nav/hover/floorplans.gif',
		              '/images/nav/hover/home.gif',
		              '/images/nav/hover/leasing.gif',
		              '/images/nav/hover/location.gif',
		              '/images/nav/hover/services.gif',
		              '/images/button_video_ON.png',
		              '/images/button_schedule_ON.png',
		              '/images/top_btns/button-schedule-over.gif',
		              '/images/top_btns/button-video-over.gif',
		              '/images/top_btns/button-vacation-over.gif'
		              ]);
		
	},
	
	nav : {
		
		mouseover : function( event ) {
			var image = event.currentTarget;
			image.src = image.src.replace(/normal/, "hover");
		},
		
		mouseout : function( event ) {
			var image = event.currentTarget;
			image.src = image.src.replace(/hover/, "normal");
		}
		
	},
	
	preload : function( images ) {
		
		for ( var index = 0; index < images.length; index++ ) {
				var image = new Image();
				image.src = images[index];
		};

	},
	
	floorplans : {
		
		init : function() {
			
			dojo.query('.floorplanOver').onmouseover( Malibu.floorplans.mouseover );
			
		},
	
		mouseover : function( event ) {
			
			var id = event.currentTarget.id.substr( event.currentTarget.id.length - 1 );
			var floorplans = dojo.query('div.floorplan');
			for ( var index=0; index < floorplans.length; index++ ) {
				if ( floorplans[index].id == 'floorplan_' + id ) {
					dojo.style( floorplans[index], 'display', 'block' );
				} else {
					dojo.style( floorplans[index], 'display', 'none' );
				}
			}
			
		}
		
	},
	
	location : {
		
		init : function() {
		
		
			if (GBrowserIsCompatible()) {
				map = new GMap2( document.getElementById( 'gmap' ) );
				map.setCenter( new GLatLng( 34.18795,-118.817139 ), 10);
				map.addOverlay( new GMarker( new GLatLng(34.02485,-118.804114), {title:'Villa Malibu' } ) );
				map.addControl( new GSmallMapControl );
				map.openInfoWindow( new GLatLng(34.02485,-118.804114), document.getElementById('maptag') );
			}
			
		}
		
	},
	
	splash : function(src, width, height) {
		var dialog = new dijit.Dialog({
			'class' : 'tundra',
			content : '<img src="' + src + '"/>',
			style : 'width: ' + width + 'px; height: ' + height + 'px',
			draggable : false
		});
		dojo.connect(dialog.domNode.parentNode, 'onclick', dialog, function(event) {this.destroy();});
		dialog.show();
	}
	
};