/**
 ********************************************************************************
 * GOOGLE MAP
 ********************************************************************************
 */
var googleMapLoader = new Class({
	googleMapEl: null,
	googleMap: null,
	geoCoder: null,
	
	initialize: function(mapEl){
		this.googleMapEl = mapEl;
	},
	
	loadGoogleMap: function(addr){
		if(GBrowserIsCompatible()){
			if(this.googleMapEl != null){
				this.googleMap = new GMap2(this.googleMapEl);
				
				this.googleMap.setCenter(new GLatLng(-27.293689, 133.066406), 3);
				this.googleMap.addControl(new GSmallMapControl());
				
				this.showAddress(addr);
			}
		}
	},
	
	showAddress: function(addr){
		this.geoCoder = new GClientGeocoder();
		this.geoCoder.getLatLng(
			addr,
			function(point){
				if(!point){
					alert('Address cannot be found!');
				}else{
					this.googleMap.setCenter(point, 14);
					
					var marker = new GMarker(point);
					
					this.googleMap.addOverlay(marker);
				}
			}.bind(this)
		);
	}
});



/**
 ********************************************************************************
 * DOM READY
 ********************************************************************************
 */
window.addEvent('domready', function(e){
	if($('googleMap')){
		gm = new googleMapLoader($('googleMap'));
		if($('address')) gm.loadGoogleMap($('address').value);
		
	}
	
	if($('playerSmall')){
		var player = new Swiff('/wordpress/wp-content/themes/acurest/media/swf/videoLoaderSmall.swf', {
			id: 'videoLoader',
			height: 208,
			width: 325,
			vars: {
				videoUrl: '/wordpress/wp-content/themes/acurest/media/video/truefit_loop02a.flv',
				linkUrl: 'http://acurest.com.au/truefit-custom-mask/',
				replay: 'true'
		    }
		});
		player.inject($('playerSmall'));
	}
	
	if($('playerLarge')){
		var player = new Swiff('/wordpress/wp-content/themes/acurest/media/swf/videoLoaderLarge.swf', {
			id: 'videoLoader',
			height: 385,
			width: 640,
			vars: {
				videoUrl: '/wordpress/wp-content/themes/acurest/media/video/Acurest_Final.flv'
		    }
		});
		player.inject($('playerLarge'));
	}
});
