<?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 '<center><font color="#FF0000"><b>No google analitics urchin ID is been given, please insert the urchin ID as a parameter like {analitics urchin=""}.</b></font></center>';
	}else
		$urchin = $params['urchin'];
?>

<script type="text/javascript">
defer="defer"
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("<? echo $urchin; ?>");
pageTracker._trackPageview();
} catch(err) {}</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>Insert the tag into your template just before the /head tag for the best results 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.3 IE bug fix</p>
	<p>Version: 0.2 Echo's error message on front-end if no urchin id is given</p>
	<p>Version: 0.1 (initial Release) new urchin methode </p>
	<?php
}

?>