/* Simplifies onload, you will no longer have to add an onload event call just call addLoadEvent */
function addLoadEvent(func,arg){
if (!arg){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
else{/*if the onload event has an argument/parameter cater for that*/
if (arg){
oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func(arg);
}
window.onload = function() {
oldonload();
func(arg);
}
}
}
}
function loadGAScript(){
/*Check browser for Dom compatibility*/
if (!document.getElementsByTagName) return false;
/*Determines whether the page is using a secure or unsecure protocol*/
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
/*Writes in the script to the document head*/
var gaScript = document.createElement("script");
gaScript.setAttribute("src",gaJsHost +"google-analytics.com/ga.js");
gaScript.setAttribute("type","text/javascript");
var domHead = document.getElementsByTagName("head")[0]
domHead.appendChild(gaScript);
}
loadGAScript();
/*Calls the analytics function*/
function callGA(){
var pageTracker = _gat._getTracker("UA-10821701-1");//change this value to your id
pageTracker._initData();
pageTracker._trackPageview();
}
addLoadEvent(callGA);