var GAUrchinEventTracking=function(){var fileExtensions="7z|aac|arc|arj|asf|asx|avi|bin|bmp|css|csv|doc|docm|docx|exe|gif|gz|gzip|hqx|jar|jpeg|jpg|js|mp2|mp3|mp4|mpeg|mpg|mov|movie|msi|msp|nzb|odb|odf|odg|odp|ods|odt|pdf|phps|png|ppt|pptx|qt|qtm|ra|ram|rar|rss|rtf|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xlsm|xlsx|xml|z|zip";var pathFilter=".*\/~\/media\/minedu\/files\/";var urlFilter="^https?:\/\/.+\\.minedu\\.govt\\.nz";if(!document.getElementsByTagName)return false;function trackEvent(category,action,label,value){function trim(str){return str.replace(/^\s+|\s+$/g,"");}
var reformedCategory=trim(category).toLowerCase();var reformedAction=trim(action).toLowerCase();var reformedLabel=trim(label);var reformedValue='';try{if(value>0){reformedValue=parseInt(value);}
else{reformedValue='';}}catch(err){reformedValue='';}
if(typeof(_gaq)!='undefined'){if(reformedValue==''){_gaq.push(['_trackEvent',reformedCategory,reformedAction,reformedLabel]);}
else{_gaq.push(['_trackEvent',reformedCategory,reformedAction,reformedLabel,parseInt(reformedValue)]);}
return true;}
else if(typeof(self.urchinTracker)!='undefined'){urchinTracker('/'+reformedCategory+'/'+reformedAction+'/'+reformedLabel+'/'+reformedValue);return true;}
return false;}
function pauseJS(timeInMilliS){var date=new Date();var curDate=null;do{curDate=new Date();}
while(curDate-date<timeInMilliS);}
var isInternal=new RegExp("^https?:\/\/"+window.location.host,"i");var isMailto=new RegExp("^mailto:","i");var isDownload=new RegExp("\\.("+fileExtensions+")$","i");var links=document.getElementsByTagName("a");for(l in links){if(href=links[l].href){if(urlFilter&&(typeof urlFilter=="string")){var isTracked=new RegExp(urlFilter,"i");}else{var isTracked=new RegExp("^&");}
if(!isInternal.test(href)&&!isDownload.test(href)&&!isMailto.test(href)&&!href.match(/^javascript\:/)&&!isTracked.test(href)){links[l].onclick=function(){trackEvent('external-links','click',this.href);pauseJS(400);};}
if(isMailto.test(href)){links[l].onclick=function(){trackEvent('mailto-links','click',this.href.substring(7));};}
if(isDownload.test(href)){links[l].onclick=function(){var extension=isDownload.exec(this.href);var file=this.href.replace(isInternal,'');if(pathFilter&&(typeof pathFilter=="string")){var pFRegExp=new RegExp(pathFilter,"i");file=file.replace(pFRegExp,'');}
trackEvent('downloads',extension[1],file);pauseJS(400);};}}}};contentLoaded(window,GAUrchinEventTracking);function contentLoaded(win,fn){var done=false,top=true,doc=win.document,root=doc.documentElement,add=doc.addEventListener?'addEventListener':'attachEvent',rem=doc.addEventListener?'removeEventListener':'detachEvent',pre=doc.addEventListener?'':'on',init=function(e){if(e.type=='readystatechange'&&doc.readyState!='complete')return;(e.type=='load'?win:doc)[rem](pre+e.type,init,false);if(!done&&(done=true))fn.call(win,e.type||e);},poll=function(){try{root.doScroll('left');}catch(e){setTimeout(poll,50);return;}
init('poll');};if(doc.readyState=='complete')fn.call(win,'lazy');else{if(doc.createEventObject&&root.doScroll){try{top=!win.frameElement;}catch(e){}
if(top)poll();}
doc[add](pre+'DOMContentLoaded',init,false);doc[add](pre+'readystatechange',init,false);win[add](pre+'load',init,false);}}
