var map;
var geocoder;
var map_created = false;
var map_zoom = 11;
var map_top = -179;
var map_bottom = -1;
var map_left = 179;
var map_right = 1;
function embed_player(playwith, shortcode, flversion, preview, divid)
{
	if(playwith == 'flashhi')
	{
		if(flversion < 8)
		{
			flashconfirm = confirm("You have requested high quality Flash video but we have not detected Flash 8 or higher on your computer.  Please click OK to download it or Cancel to try to view anyway.");
			if(flashconfirm)
			{
				window.open('http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'Get Flash', 'width=800, height=600');
				return false;
			}
		}
		if(preview == 'f')
		{
			var s1 = new SWFObject("http://tsr2.propvid.tv/tsr3/files/flvplayer.swf",divid,"512","308","8");
			s1.addVariable("file","http://cdn.propvid.tv/tsr3/files/videos/"+shortcode+"-hi.flv");
		}
		else
		{
			var s1 = new SWFObject("http://tsr2.propvid.tv/tsr3/files/flvplayer.swf",divid,"512","308","8");
			s1.addVariable("file","http://tsr2.propvid.tv/tsr3/pv/movie_expire.php?file="+shortcode+"-hi.flv");
		}
		s1.addParam("allowfullscreen","true");
		s1.addVariable("displayheight","288");
		s1.addVariable("enablejs","true");
		s1.addVariable("javascriptid","single");
		s1.addVariable('bufferlength','5');
		s1.addVariable('smoothing','true');
		s1.setAttribute("style", ";");
		s1.write("single");
	}
	else if (playwith == 'none')
	{
		flashconfirm = confirm("You have requested Flash video but we have not detected Flash 7 or higher on your computer.  Please click OK to download it or Cancel to try to view anyway.");
		if(flashconfirm)
		{
			window.open('http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'Get Flash', 'width=800, height=600');
			return false;
		}
	}
	else if(playwith == 'flashlo')
	{
		if(flversion < 8)
		{
			flashconfirm = confirm("You have requested Flash video but we have not detected Flash 7 or higher on your computer.  Please click OK to download it or Cancel to try to view anyway.");
			if(flashconfirm)
			{
				window.open('http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'Get Flash', 'width=800, height=600');
				return false;
			}
		}
		document.write('<p id="single"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>');
		var s1 = new SWFObject("http://tsr2.propvid.tv/tsr3/files/flvplayer.swf",divid,"512","308","7");
		s1.addParam("allowfullscreen","false");
		s1.addVariable("displayheight","288");
		s1.addVariable("file","http://tsr2.propvid.tv/tsr3/files/videos/"+shortcode+"-lo.flv");
		s1.addVariable("enablejs","true");
		s1.addVariable("javascriptid","single");
		s1.addVariable('bufferlength','5');
		s1.addVariable('smoothing','true');
		s1.setAttribute("style", ";");
		s1.write("single");
	}
	else if(playwith == 'qthi')
	{
		if(preview == 'f')
		{
			QT_WriteOBJECT('http://cdn.propvid.tv/tsr3/files/videos/'+shortcode+'-stream.mov', '512', '308', '',
			'autoplay', 'true',
			'emb#bgcolor', 'black',
			'align', 'middle',
			'id', 'qt_player');
		}
		else
		{
			QT_WriteOBJECT('http://tsr2.propvid.tv/tsr3/pv/movie_expire.php?file='+shortcode+'-stream.mov', '512', '308', '',
			'autoplay', 'true',
			'emb#bgcolor', 'black',
			'align', 'middle',
			'id', 'qt_player');
		}
	}
}

function swapMapPhoto()
{
	Effect.toggle('photo', 'blind', {queue:'parallel'});
	Effect.toggle('map_wrapper', 'blind', {queue:'parallel'});
	if(map_created == false)
	{
		map_create();
	}
}
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, map_zoom);
	}
	);
	
}

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);
			marker.bindInfoWindowHtml(html);
			if(open)
			{
				marker.openInfoWindowHtml(html);
			}
			
		}
//		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(380, 240);
        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;
}
