//------------------------------------------//
// Javascript Functions                     //
// (C) Copyright 2008, Kevin Green          //
// E-Mail: kevin@green.id.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>');
	}
}

//------------------------------------------
// Confirmation box
//------------------------------------------
function confirmThis(msg,url) {
	input_box = confirm(msg);
	if (input_box==true) { 
		// User clicked OK
		window.location.href(url);
	}
}

//------------------------------------------
// Toggle <div> display status
//------------------------------------------
function toggleview(id) {
	if ( ! id ) return;

	itm = document.getElementById(id);

	if (itm.style.display == "none") {
		my_show_div(id);
	} else {
		my_hide_div(id);
	}
}

//------------------------------------------
// Toggle 2 <div>'s display status
//------------------------------------------
function togglediv(id1, id2) {
        toggleview(id1);
        toggleview(id2);
}

//------------------------------------------
// Hide <div>
//------------------------------------------
function my_hide_div(id) {
	itm = document.getElementById(id);

	if ( ! itm ) return;
	itm.style.display = "none";
}

//------------------------------------------
// Show <div>
//------------------------------------------
function my_show_div(id) {
	itm = document.getElementById(id);

	if ( ! itm ) return;
	itm.style.display = "";
}

//------------------------------------------
// Menu code for IE
//------------------------------------------
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//------------------------------------------
// Google Maps
//------------------------------------------
function createMarker(point,html) {
	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

	return marker;
}

function createOdeumMarker(point,html,map) {
	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		map.setCenter(new GLatLng(-32.065047,115.897994), 16);
		marker.openInfoWindowHtml(html);
	});

	return marker;
}

function Gload() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("odeumGoogleMap"));
		map.setCenter(new GLatLng(-32.065047,115.897994), 16);

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

		// Default to Hybrid map
		map.setMapType(G_HYBRID_MAP);

		var point = new GLatLng( -32.065047, 115.897994);

		var marker = createOdeumMarker(point,'<img src="images/1/map_logo.jpg" width="200" height="70" alt="Odeum Produce" title="Odeum Produce" style="display: inline" />',map);

		map.addOverlay(marker);

	}
}

function openMapWindow(path) {
	if(window.open) {
		window.open(path + 'map.php','odeumMapWindow','width=700,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
	}
}