//------------------------------------------//
// Javascript Functions                     //
// (C) Copyright 2010, Kevin Green          //
// E-Mail: kevin@echoit.net.au              //
// ---------------------------------------- //
// Use of this code is not permitted        //
// unless this header remains intact        //
//------------------------------------------//

//------------------------------------------
// Simple E-Mail address spam protection
//------------------------------------------
function nospam(name,domain,showText) {
	if(!showText) {
		document.write('<a href=\"mailto:' + name + '@' + domain + '\">' + name + '@' + domain + '</a>');
	} else {
		document.write('<a href=\"mailto:' + name + '@' + domain + '\">' + showText + '</a>');
	}
}

//------------------------------------------
// Google Maps
//------------------------------------------
function createMarker(point,html) {
	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

	return marker;
}

function createWotMarker(point,html,map) {
	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		map.setCenter(new GLatLng( -32.072554, 115.894475 ), 17);
		marker.openInfoWindowHtml(html);
	});

	return marker;
}

function Gload() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("wotGoogleMap"));
		map.setCenter(new GLatLng(-32.072554,115.894475), 17);

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

		// Default to Hybrid map
		map.setMapType(G_HYBRID_MAP);

		var point = new GLatLng( -32.072554, 115.894475 );

		var marker = createWotMarker(point,'<img src="../images/map_logo.png" width="188" height="119" alt="World of Treats" style="display: inline" />&nbsp;&nbsp;&nbsp;&nbsp;',map);

		map.addOverlay(marker);

	}
}

//------------------------------------------
// Slideshow
//------------------------------------------
// Preload images
pic1 = new Image(830,302); pic1.src="../images/bg_home_1.jpg"; 
pic2 = new Image(830,302); pic2.src="../images/bg_home_2.jpg"; 
pic3 = new Image(830,302); pic3.src="../images/bg_home_3.jpg"; 
pic4 = new Image(830,302); pic4.src="../images/bg_home_4.jpg"; 

$(document).ready(function() {
	if(document.getElementById('slideshow')) {
		pics  = '<a href="contact/"><img src="images/bg_home_1.jpg" width="910" height="350" alt="World of Treats" /></a>';
		pics += '<a href="contact/"><img src="images/bg_home_2.jpg" width="910" height="350" alt="World of Treats" /></a>';
		pics += '<a href="contact/"><img src="images/bg_home_3.jpg" width="910" height="350" alt="World of Treats" /></a>';
		pics += '<a href="contact/"><img src="images/bg_home_4.jpg" width="910" height="350" alt="World of Treats" /></a>';
		
		document.getElementById('slideshow').innerHTML = pics;

		document.getElementById('slideshow').style.display='block';
		$('#slideshow').cycle({ 
		    fx:    'fade', 
		    speed:  3000
		 });
	}
});
