  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-10397001-3']);
  _gaq.push(['_trackPageview']);

  window.onload = function () {

/* Nyomtatási kép mérése START */
	var isprint = new RegExp('folderID=830','i');
	if(isprint.test(window.location)) {
		var hrefA = window.location.href;
		var hrefB = hrefA.match('(.*)main.php.*$');
		var hrefC = hrefA.replace(hrefB[1],'');
		_gaq.push(['_trackEvent', 'Print', 'View', hrefC]);
	}
/* Nyomtatási kép mérése END */




/* Linkek mérése */

/*
var headID = document.getElementsByTagName("head")[0];         
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'http://jezsuita.hu/audioplayer/audio-player.js';

var newScript2 = document.createElement('script');
newScript2.type = 'text/javascript';
newScript2.innerHTML =  'AudioPlayer.setup("http://jezsuita.hu/audioplayer/player.swf", {          width: 290            });  ';

headID.appendChild(newScript);
headID.appendChild(newScript2);

*/

	var links = document.getElementsByTagName('a');
	for (var x=0; x < links.length; x++) {

/*	
	//links[x].load = function () {
		var onclick = links[x].getAttribute('onclick');
		if (onclick) {
		var mates = onclick.match(".*ezit.hu\/(.*)\/index.*autoplay");
		if(mates) {



//	var code  = '<p id="audioplayer_1">Alternative content</p>';
       var code = 'X<script type="text/javascript">';
       code += ' AudioPlayer.embed("audioplayer_' + [x] + '", {soundFile: "http://jezsuita.hu/audioplayer/test.mp3"});  ';
       code += ' </script>  ';

//var myText = document.createTextNode(code);
//document.getElementById("content").appendChild(myText);


			links[x].innerHTML = code;
}
		}
//}
*/

		links[x].onclick = function () {  
/*		links[x].onmouseover = function () {  */
			var trackDownloadExtensions = "7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip";
			var isDownload = new RegExp("\\.(" + trackDownloadExtensions + ")$", "i");
			if(isDownload.test(this.getAttribute('href'))) {
				_gaq.push(['_trackEvent', 'Downloads', isDownload.exec(this.getAttribute('href')), this.getAttribute('href')]);				
			}
			else {

				var mydomain = new RegExp('http://([w]{3}\.){0,1}(jezsuita|parbeszed).(ezit.){0,1}(hu|com)', 'i'); 
				var islinkout = new RegExp('http://', 'i');
				var isradioblog = new RegExp('index.php\?autoplay','i');


				if(mydomain.test(this.getAttribute('onclick'))) {
					/* && isradioblog.test(this.getAttribute('onclick'))) {*/
					var mates = this.getAttribute('onclick').match(".*ezit.hu\/(.*)\/index.*autoplay");
					if(mates) {
						_gaq.push(['_trackEvent', 'Audio', 'Window Open', mates[1]]); 
						MyWindow=window.open('http://parbeszed.ezit.hu/'+ mates[1] +'/index.php?autoplay=1','Jezsuita','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=130,height=85'); 
					}
				}


				if(islinkout.test(this.getAttribute('href')) && !mydomain.test(this.getAttribute('href'))) { 
					_gaq.push(['_trackEvent', 'Outgoing links', 'Click', this.getAttribute('href')]); 
					}

				var isdownload1 = new RegExp('download.php','i');
				if((islinkout.test(this.getAttribute('href')) && isdownload1.test(this.getAttribute('href')) && ismydomain.test(this.getAttribute('href'))) || isdownload1.test(this.getAttribute('href')) ) { 
					var matches = this.getAttribute('href').match('ctag\=(.*)&docID\=(.*)$');
					_gaq.push(['_trackEvent', 'Downloads', 'docID', matches[2]]); 
					}


			};



		};
	}
  };





  (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';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
