$('#jsprint').html(' <button id="jsprintgo">Print results</button>'); 
$("#jsprintgo").click(function() { 
 $('<style media="print"> .noprint {display: none;} </style>').appendTo('head'); 
 window.print(); 
 return false;
});

function loadgooglejs() {
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"));
}

function getdomain(url) {
	url = url.toLowerCase();
	if (url.indexOf("//") >= 0) {
		url = url.split("//");
		url = url[1].split("/");
		return url[0];
	} else {
		return "";
	};
}

function getFName(url) {
	url = url.toLowerCase();
	if (url.indexOf("?") >= 0) {
           url = url.left(url.indexOf("?"));
        }
	url = url.split("/");
	return url.pop();
}

function getExt(url) {
        url = getFName(url).split(".");
	return url.pop();
}

function loadtrackingcode(pagePath) {
// Track this page
pageTracker._addOrganic("home.nzcity.co.nz","q");
pageTracker._addOrganic("zenbu.co.nz","q");
pageTracker._addOrganic("mws.ask.com","searchfor");
pageTracker._addOrganic("tattoodle.com","q");
pageTracker._trackPageview(pagePath);

// Handle html requests, internal, content and everything else is external
// if the request does not start with http then it is relitave therefore is content
// normal content is tracked when it opened therefore not handled by a click.

var arrInt = new Array(0);
arrInt[0] = "sec.westpac.co.nz";
arrInt.push("bol.westpac.co.nz");
arrInt.push("hotpoints.co.nz");
arrInt.push("westpaccards.co.nz");
arrInt.push("ecoshop.co.nz");

var arrOlc = new Array(0);
arrOlc[0] = "search.westpac.co.nz";
arrOlc.push("www.westpac.co.nz");
arrOlc.push("go.co.nz");
arrOlc.push("merchantservices.co.nz");
arrOlc.push("westpacgovtbusiness.co.nz");



    $("a[href^='http']").filter(function (index) {
                     return arrInt.toString().indexOf(getdomain($(this).attr('href'))) >= 0;
                }).click(function () {
                var id = $(this).attr('title');
                if (id == undefined) {
                    id = getdomain($(this).attr('href'));
                };
                pageTracker._trackPageview('/Link/Internal/' + id);
                pageTracker._trackPageview(pagePath + '/' + id);
            })
            .end()
            .filter(function (index) {
                     return arrOlc.concat(arrInt).toString().indexOf(getdomain($(this).attr('href'))) < 0;
                }).click(function () { 
                var href = $(this).attr('href');
                var id = $(this).attr('title');
                if (id == undefined) {
                    id = getdomain(href);
                    if (id == undefined) {
                        id = $(this).text;
                    };
                };
                pageTracker._trackPageview('/Link/External/' + id);
                pageTracker._trackPageview(pagePath + '/' + id);
            });

// Handle file attachments
    $("a[href*='/$FILE/'],a[href*='/$file/']").focus(function () {
       var id = $(this).attr('title');
        if (id == undefined) {
           id = getFName($(this).attr('href'));
           if (id == undefined) {
              id = $(this).text;
           }
	};
         pageTracker._trackPageview('/Link/' + getExt($(this).attr('href')) + '/' + id);
         pageTracker._trackPageview(pagePath + '/' +  id);
    });

}; 

