<?php

/**
* @version 3.0.0
* @package Joomla 3.0
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

global $googlekey,$amp,$location_img_w,$location_img_h,$linktogoogle,$embed_map;
$document =& JFactory::getDocument();
if($googlekey!==""){

 //  $document->addScript( "http://maps.google.com/maps?file=api".$amp."v=2.x".$amp."key=".$googlekey);
}
$uri = JFactory::getURI(); 
if($uri->isSSL() == false) {
	
	$http = 'http';
	
} else {
	$http = 'https';	
}
$lang =& JFactory::getLanguage();
$locales = $lang->getLocale();
$tag = $lang->getTag();

$iso639 = explode('-',$tag);
$iso639 = $iso639[0];
$document->addScript($http."://maps.googleapis.com/maps/api/js?sensor=false&language=".$iso639);
$document->addScript( JURI::root(true).'/components/com_dtregister/assets/js/dt_jquery.js');
$mlocation = $this->getModel('location');
$location = $mlocation->table;
$location->load(JRequest::getVar('id',0));

?>
<?php if($embed_map){ ?>
<script type="text/javascript">
   var map = null;

    var geocoder = null;

	var address = null;

	var display_address = null;
	
	var infowindow = new google.maps.InfoWindow();
   
	function initialize() { 
    	//var latlngPos = new google.maps.LatLng(51.515252, -0.189852);
		var latlngPos = new google.maps.LatLng(<?php echo round( $location->lat,5); ?>,<?php echo  round($location->lng,5)?>);

		var myOptions = {
		   zoom: 10,
		   center: latlngPos,
		   mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
		map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
		
		 var marker = new google.maps.Marker({
					map: map, 
					position: latlngPos
				});
		 infowindow.setContent(display_address);
         infowindow.open(map, marker);

	}

</script>
<?php } ?>
 <table class="location_box">

    <tr>

      <td colspan="2" align="left" class="location_name"><?php echo stripslashes($location->name); ?></td>

    </tr>

    <tr>

    <?php if(file_exists($location->image) && $location->showimage==1 ){?>

      <td align="left" valign="top" class="location_image">

        <img src="index.php?option=com_dtregister&controller=file&task=thumb&w=<?php echo $location_img_w; ?>&h=<?php echo $location_img_h; ?>&filename=images/dtregister/locations/<?php echo basename($location->image); ?>" border="0" /></td>

         <?php } ?>

      <td valign="top" align="left" class="location_details">

       <?php if($location->address !=""){?>

	      <?php echo stripslashes($location->address); ?>

       <?php }?>

       <?php if($location->address2 !=""){?>

              <br /><?php echo stripslashes($location->address2); ?>

       <?php }?>

       <?php if($location->city !=""){?>

         <br /><?php echo stripslashes($location->city); ?>,&nbsp;<?php echo stripslashes($location->state); ?>&nbsp;&nbsp;<?php echo stripslashes($location->zip); ?>

        <?php }?>

        <?php if($location->country !=""){?>

         <br /><?php echo stripslashes($location->country); ?>

        <?php }?>

        <?php if($location->phone !=""){?>

          <br /><b><?php echo JText::_( 'DT_PHONE' ); ?></b>: <?php echo $location->phone; ?>

        <?php }?>

        <?php if($location->email !=""){?>

          <br /><b><?php echo JText::_( 'DT_EMAIL' ); ?></b>: <a href="mailto:<?php echo $location->email; ?>">[<?php echo JText::_( 'DT_CLICK_TO_EMAIL' ); ?>]</a>

        <?php }?>

        <?php if($location->website !=""){?>

          <br /><b><?php echo JText::_( 'DT_WEBSITE' ); ?></b>: <a href="<?php echo $location->website; ?>" target="_blank"><?php echo $location->website; ?></a>

        <?php }?>

      </td>

    </tr>

   </table>

   <div style="margin-left:6px">
<?php if($embed_map){ ?>
   <div id="map_canvas" style="width: 500px; height: 300px">

   </div>
<?php } ?>
  <?php

		 if($linktogoogle==1){

	?>

     [<a target="_blank" href="http://maps.google.com/maps?f=d&hl=en&z=11&om=0&layer=t&utm_campaign=en&utm_source=en-ha-na-us-google-dd&utm_medium=ha&saddr=<?php echo $location->address.', '.$location->city.', '.$location->state.' '.$location->zip; ?>"><?php echo JText::_( 'DT_GOOGLE_LINK' ); ?></a>]

       <?php } ?>

   </div>
  <script>
    
	address = '<?php echo $location->address.$location->address2.', '.$location->city.', '.$location->state.' '.$location->zip; ?>';
	DTjQuery('html').css('background','none');
	
  </script>
   <?php

    if($location->address2 !=""){

	   $location->address2 = "<br />".$location->address2;

	}

   ?>

   <script>
	 
	 display_address = '<?php echo $location->address.$location->address2.'<br /> '.$location->city.', '.$location->state.' '.$location->zip; ?>';
	 
	<?php if($embed_map){ ?>
	 DTjQuery(function(){
		 
		 initialize();
	});
    <?php } ?>
   </script>