// JavaScript Document
	
function setAndExecute(divId)
{
   var div = document.getElementById(divId);
   
  // div.innerHTML = innerHTML;
  
   var x = div.getElementsByTagName("object"); 
   //var y = div.getElementsByTagName("embed");
   for(var i=0;i<x.length;i++)
   {
       eval(x[i].text);
   }
}


function birdseyeview ()
{
	
	var url			=	"ajax_map_content.php";
	var	params 		= 	"actions=BIRDSEYEVIEW";
	
	$('map_tab_2').className = 'maptab_selected';	
	$('map_tab_1').className = ' ';
	$('map_tab_3').className = ' ';
	
	new Ajax.Request(url,{method:"get",parameters:params,onSuccess:map_birds_view,onFailure:disp_error_map})
}

function map_birds_view (reqObj)
{
	$('map_contnt_div').innerHTML = reqObj.responseText;	
	var lat1 = $('virtual_lat').value;
	var lng1 = $('virtual_lng').value;
	
	var signlat=1;
	var signlon=-1;
	if(lat1< 0) 
	{
		signlat = -1; 
	} 
	latAbs = Math.abs( Math.round(lat1 * 1000000)); //Math.round is used to eliminate the small error caused by rounding in the computer: //e.g. 0.2 is not the same as 0.20000000000284 //Error checks 
	/*if(latAbs > (90 * 1000000)) 
	{ 
		alert(' Degrees Latitude must be in the range of -90. to 90. '); 
		lat1= ''; 
		latAbs=0; 
	}*/
	if(lng1 < 0) 
	{ 
		signlon = -1; 
	} 
	lonAbs = Math.abs(Math.round(lng1 * 1000000)); //Math.round is used to eliminate the small error caused by rounding in the computer: //e.g. 0.2 is not the same as 0.20000000000284 //Error checks 
	/*if(lonAbs > (180 * 1000000)) 
	{ 
		alert(' Degrees Longitude must be in the range of -180 to 180. '); 
		lng1=''; 
		lonAbs=0; 
	}*/
		
	
	var latdegree = ((Math.floor(latAbs / 1000000) * signlat) + '°' + Math.floor(  ((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)  + '&#39;' +  ( Math.floor(((((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60) - Math.floor(((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)) * 100000) *60/100000 ) + '&quot;'  );
	var lngdegree = ((Math.floor(lonAbs / 1000000) * signlon) + '°' + Math.floor(  ((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60)  + '&#39;' +  ( Math.floor(((((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60) - Math.floor(((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60)) * 100000) *60/100000 ) + '&quot;'  );
	signlat=1;
	signlon=1;
	
	
	GetMap (lat1,lng1);
	$('latlong_div').innerHTML = latdegree +" "+lngdegree;
	
}

function disp_error_map ()
{
}

function GetMap(lat1,lng1)
{
	map = new VEMap('myMap'); //line 1
	/*var veMiami = new VELatLong(25.9577745, -80.2391839); //line 2	*/
	var veMiami = new VELatLong(lat1, lng1); //line 2	
	map.LoadMap(veMiami, 4, 'r'); //line 3
    map.SetMapStyle(VEMapStyle.Birdseye);
	var veMiamiPin = new VEPushpin('SuperBowl', veMiami); //line 4
	map.AddPushpin(veMiamiPin); //line 5		
}
function change_map_content (action,property_id)
{
	var url			=	"ajax_map_content.php";
	if(action == 'PICTURESVIDEOS')
	{
		
		$('map_tab_3').className = 'maptab_selected';	
		$('map_tab_1').className = ' ';
		$('map_tab_2').className = ' ';		
	}
	else
	{
		$('map_tab_1').className = 'maptab_selected';	
		$('map_tab_2').className = ' ';
		$('map_tab_3').className = ' ';		
	}
	
	var lat1 = $('virtual_lat').value;
	var lng1 = $('virtual_lng').value;
	
	var	params 		= 	"actions="+escape(action)+"&lat1="+escape(lat1)+"&lng1="+escape(lng1)+"&property_id="+property_id;	
	new Ajax.Request(url,{method:"get",parameters:params,onSuccess:map_content_result,onFailure:disp_error_map})
}
function map_content_result (reqObj)
{
	$('map_contnt_div').innerHTML = reqObj.responseText;
	
	setAndExecute ('map_contnt_div');
}
