<?php
#CMS - CMS Made Simple
#(c)2004-2007 by Ted Kulp (ted@cmsmadesimple.org)
#This project's homepage is: http://cmsmadesimple.org
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#Author: D Baars (123 Hosting Service)

function smarty_cms_function_analitics($params, &$smarty)
{
	if(empty($params['urchin'])) {
		echo 'No google analitics urchin ID is been given, please insert the urchin ID as a parameter like {analitics urchin=""}.';
	}else
		$urchin = $params['urchin'];
?>

<script type="text/javascript">
defer="defer"
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '<? echo $urchin; ?>']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();

</script>

<?php
}

function smarty_cms_help_function_analitics() {
	?>
	<h3>What does this do?</h3>
	<p>Adds the google analitics tracker code into the cms.</p>
	<h3>How do I use it?</h3>
	<p>Just insert the tag into your template/page like: <code>{analitics urchin=""}</code>don't forget your urchin tracker ID<br></p>
	<h3>What parameters does it take?</h3>
	<ul>
		<li><em>(required)</em>urchin - Urchin tracker ID.</li>
	</ul>
	<?php
}

function smarty_cms_about_function_analitics() {
?>
	<p>Author: D Baars d.baars@123hostingservice.nl</p>
	<p>Version: 0.2 IE Bug fix </p>
	<p>Version: 0.1 (initial Release) Asynchronous Tracking methode </p>
	<?php
}

?>