var map;
var geocoder;
var map_created = false;
var map_zoom = 15;
var map_top = -179;
var map_bottom = -1;
var map_left = 179;
var map_right = 1;

function swapMapPhoto(video_visible)
{
	$('player_box').hide();
	$('map_wrapper').show();
}
function map_clear()
{
	map.clearOverlays()
}
function map_set_center_zoom()
{
	if(map_top == -179 || map_bottom == -1 || map_left == 179 || map_right == 1)
	{
		map.setCenter(new GLatLng(-36.385913,158.994141), 3);
	}
	sw = new GLatLng(map_bottom, map_left);
	ne = new GLatLng(map_top, map_right);
	bounds = new GLatLngBounds(sw, ne);
	map_zoom = map.getBoundsZoomLevel(bounds)-1;
	point = new GLatLng((map_bottom+map_top)/2, (map_left+map_right)/2);
	map.setCenter(point, map_zoom);
}
function map_center(addr1, city, state, country)
{
	geocoder.getLocations(addr1+','+city+','+state+','+country,
	function (response)
	{
		if(response.Status.code != 200)
		{
			if(center)
			{
				map.setCenter(new GLatLng(-36.385913,158.994141), 3);
			}
			return;
		}	
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
		map.setCenter(point, 12);
	}
	);
	
}

function map_marker_test(point)
{
	if(point.lat() < map_bottom)
	{
		map_bottom = point.lat();
	}
	if(point.lat() > map_top)
	{
		map_top = point.lat();
	}
	if(point.lng() < map_left)
	{
		map_left = point.lng();
	}
	if(point.lng() > map_right)
	{
		map_right = point.lng();
	}
//	alert('mb = '+map_bottom+' ml = '+map_left+' mt = '+map_top+' mr ='+map_right);
}

function map_add_marker(addr1,city,state,country, html, open)
{
	var point;
	geocoder.getLocations(addr1+','+city+','+state+','+country,
	function (response)
	{
		if(response.Status.code != 200)
		{
			return;
		}	
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
		if(place.AddressDetails.Accuracy == 8)
		{
			
			marker = new GMarker(point);
			map.addOverlay(marker);			
		}
//		alert('testing');
		map_marker_test(point);
//		alert('mb = '+map_bottom+' ml = '+map_left+' mt = '+map_top+' mr ='+map_right);
	}
	);
}
function map_create()
{
	if (GBrowserIsCompatible()) {

		var my_size = new GSize(512, 318);
        map = new GMap2(document.getElementById("map"), {size:my_size});
        map.addControl(new GSmallMapControl());
		geocoder = new GClientGeocoder();
		map_created = true;
		map.setCenter(new GLatLng(-36.385913,158.994141), 3);
      }
}

/*******************************************************
QUICKTIME DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
*******************************************************/

var quicktime=new Object();

// Set some base values
quicktime.installed=false;
quicktime.version='0.0';

if (navigator.plugins && navigator.plugins.length)
{
	for (x=0; x<navigator.plugins.length; x++)
	{
		if (navigator.plugins[x].name.indexOf('QuickTime Plug-in') != -1)
		{
			quicktime.installed=true;
			quicktime.version=navigator.plugins[x].name.split('QuickTime Plug-in ')[1].split(' ')[0];
			break;
		}
	}
}
else if (window.ActiveXObject)
{
	try
	{
		oQTime=new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck.1');
		if (oQTime)
		{
			quicktime.installed=oQTime.IsQuickTimeAvailable(0);
			quicktime.version=parseInt(oQTime.QuickTimeVersion.toString(16).substring(0,3))/100;
		}
	}
	catch(e) {}
}
var js_quicktime_available = false;
if(quicktime.installed=true && quicktime.version > 7)
{
	js_quicktime_available = true;
}
