<? include "/home/openingtimesco/brd_config.inc";
if ($_POST['hid'] && $_POST['hlat'] && $_POST['hlng']) {
$conn = mysql_connect($brd_slave_mysql_host,$brd_slave_mysql_username,$brd_slave_mysql_password);
mysql_select_db($brd_slave_mysql_database,$conn);
$buildstring = base64_encode($_POST['hid'] . " || " . $_POST['hlat'] . " || " .$_POST['hlng'] . " || " . $_POST['h1lat'] . " || " .$_POST['h1lng'] . " || " . "<a href='http://maps.google.com/maps?q=".$_POST['h1lat']."+".$_POST['h1lng']."+to+".$_POST['hlat']."+".$_POST['hlng']."&iwloc=A&hl=en'>INSPECT OLD LOCATION TO NEW LOCATION</a>");
$res2 = mysql_query("INSERT INTO updatedetails VALUES ('','$_POST[hid]','location','$buildstring','0',NOW())");
$headers  = "From: BRDEMAILSCRIPT@bigreddirectory.com\r\n";
$headers .= "Content-type: text/html\r\n";
$message = "New location update request for " . $_POST['hid'] . " - " . $_POST['hname'] ."<br>";
$message .="<a href='http://maps.google.com/maps?q=".$_POST['h1lat']."+".$_POST['h1lng']."+to+".$_POST['hlat']."+".$_POST['hlng']."&iwloc=A&hl=en'>INSPECT OLD LOCATION TO NEW LOCATION</a>    <a href='http://www.bigreddirectory.com/approve_newlocation.php?id=" . $_POST['hid']."&lat=".$_POST['hlat']."&lng=".$_POST['hlng']."&check=".$_POST['hid'] * 26 ."'>APPROVE NEW LOCATION</a>";
//mail("robert.ponting@pureinnovation.co.uk","UPDATE MAP LOCATION POSTED",$message,$headers);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="noindex, nofollow"/>
<style>
a.tinya{
	font:normal 12px/17px Verdana, Arial, Helvetica, sans-serif;
	color:#1B7D01;
	background-color:inherit;
	text-decoration:underline;
	padding:0;
	margin:0;
}
a.tinya:hover{
	color:#1B7D01;
	background-color:#F7F0D9;
	text-decoration:none;
}
</style>
<title>Details submitted succesfully</title>
<p align="center">New location details submitted</p>
<p align="center">All location update requests are checked for accuracy before approval</p>
<p></p>
<p align="center"><strong><a href="javascript:self.close()" class="tinya">Close window</a></strong></p>
	
<?php	
die();}

if (!$_GET[id]) {die("Error in submission");}

if ($_GET['id'] && !is_numeric($_GET['id'])) {die("Error");}
$conn = mysql_connect($brd_mysql_host,$brd_mysql_username,$brd_mysql_password);
mysql_select_db($brd_mysql_database,$conn);

$sql = "SELECT * FROM amenities_general WHERE id ='" . $_GET['id'] ."' AND url !=''";
$res=mysql_query($sql);
$name = mysql_result($res,0,"name");
$lat = mysql_result($res,0,"lat");
$lng = mysql_result($res,0,"lng");
$type = mysql_result($res,0,"type");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="noindex, nofollow"/>
<style>
a.tinya{
	font:normal 12px/17px Verdana, Arial, Helvetica, sans-serif;
	color:#1B7D01;
	background-color:inherit;
	text-decoration:underline;
	padding:0;
	margin:0;
}
a.tinya:hover{
	color:#1B7D01;
	background-color:#F7F0D9;
	text-decoration:none;
}
</style>
<title><?=$name;?> amend map location method</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=AIzaSyCUt8gk3MMMOKtHyhlyd7tJspiBKYRiP-o" type="text/javascript"></script>
<script type="text/javascript"> 
//<![CDATA[
		   
window.onunload = function(){
				GUnload();
			}
			window.onload = function(){

				if (GBrowserIsCompatible()) {
					
					// Init the map
					var map = new GMap2(document.getElementById('map_edit'));
					map.addControl(new GSmallMapControl());
					map.setCenter(new GLatLng(<?=$lat?>, <?=$lng?>), 12);
					
					// Creating a marker
					var marker = new GMarker(new GLatLng(<?=$lat?>, <?=$lng?>), {
							draggable: true, 
							title: 'Drag me'
						});
					
					// Adding a click event to the marker
					GEvent.addListener(marker, "click", function() {
					    marker.openInfoWindow('Drag me to correct location');
					});
					
					// Close InfoWindow at dragstart
					GEvent.addListener(marker, "dragstart", function() {
						map.closeInfoWindow();
					});
					
					GEvent.addListener(marker, "dragend", function() {
					  document.getElementById('hlat').value = marker.getPoint().lat();
					  document.getElementById('hlng').value = marker.getPoint().lng();
					});
										
					// Add the marker to the map	
					map.addOverlay(marker);
				}
			}		   
		   

//]]>
</script>
</head>
<body>
<p><strong>Amend map location for <?=$name?></strong></p>
<p>Drag the pointer to the entrance of the <?=strtolower($type)?></p>
<p>You can zoom in using the controls on the top left of the map</p>
<div id="map_edit" style="width:450px;height:400px;z-index:1"></div>
<p>All map location updates will be verified for accuracy by hand before publication</p>
<form id="update_map" name="update_map" method="post" action="/amend_map_location.php">
  <label>
    <input type="submit" name="Submit" id="Submit" value="Submit new location details" />
  </label>
  <input type="hidden" name="hname" id="hname" value="<?=$name?>"/>
  <input type="hidden" name="hid" id="hid" value="<?=$_GET['id']?>"/>
  <input type="hidden" name="h1lat" id="h1lat" value="<?=$lat?>"/>
  <input type="hidden" name="h1lng" id="h1lng" value="<?=$lng?>"/>
  <input type="hidden" name="hlat" id="hlat" />
  <input type="hidden" name="hlng" id="hlng" />
</form>
<p>&nbsp;</p>
</body>
</html>