// vars for Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1242350-1']);
_gaq.push(['_trackPageview']);
// vars for DoubleClick
var dblClickSrc = '3012733';
var dblClickGroup = 'pen2011';

 var oTrackit = {
    init:function() {
        this.google();
        this.dblClick();
    },

    google:function() {
		try {
			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);
		} catch (ee) {
			; //do nothing
		}
		$('a').has('img[src*="order_now.gif"]').click(function(){
			_gaq.push(['_trackEvent','Click_Order_Now','Click_Order_Now']);
		});
		$('div#hcp_PI_info').click(function(){
			_gaq.push(['_trackEvent','Click_Prescribing_Information','Click_Prescribing_Information']);
		});
		var loc = new String(window.location);
		if (!loc.match(/par_/)) {
			_gaq.push(['_trackEvent','HCP_Consumption','HCP_Consumption']);
		} else {
			_gaq.push(['_trackEvent','Parents_Consumption','Parents_Consumption']);
		}
		$('div#hcp_par_link').click(function(){
			_gaq.push(['_trackEvent','Parents_Click','Parents_Click']);
		});
		$('a[href*="Pentacel_PI_12-09.pdf"]').click(function(){
			_gaq.push(['_trackEvent','Parents_Click','Parents_Click','Patient Information PDF']);
		});
		$('a').has('img[src*="share.gif"]').click(function(){
			_gaq.push(['_trackEvent','Click_Share','Click on Share This Page']);
		});
		$('a').has('img[src*="print.gif"]').click(function(){
			_gaq.push(['_trackEvent','Click_Print','Click on Print']);
		});
		$('#stafglobal').submit(function(){
			_gaq.push(['_trackEvent','Email_Friend','Click on Send']);
		});
	vidStart = function() 
	{
			_gaq.push(['_trackEvent','Video_Starts','Video Consumption']);
	}
	vidPause = function() 
	{
			_gaq.push(['_trackEvent','Video_Pause','Video Pause Rate']);
	}
	vidEnd = function() 
	{
			_gaq.push(['_trackEvent','Video_Completes','Video Consumption Rate']);
	}
    },
	
	dblClick:function(){
		
		$('a').has('img[src*="order_now.gif"]').click(function(){
			dblClick.spotlight(this.href, 'u_hom928', true);
		});
		
		$('#impl-guide').click(function(){
			dblClick.spotlight(this.href, 'u_sta846', true);
		});
		
		$('#dl-link').click(function(){
			dblClick.spotlight(this.href, 'u_sta075', true);
		});
		
		$('#moreinfo').submit(function(){
			dblClick.spotlight(this.href, 'u_pra439', true);
		});
		
	}
}

$(window).bind("load", function() { oTrackit.init(); });

var dblClick = new Object();

dblClick.floodlight = function(actTag) {
	var axel = Math.random() + "";
	var a = axel * 10000000000000;
	document.write('<iframe src="http://fls.doubleclick.net/activityi;src='+dblClickSrc+';type='+dblClickGroup+';cat='+actTag+';ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
}

dblClick.spotlight = function (href, category, followLink) {
	var axel = Math.random() + "";
	var a = axel * 1000000000000000000;

	// what is this anyway??? 
	// document.url is read-only
	// see: http://bit.ly/mLvwgk and http://mzl.la/kWWPiy
	//document.url = href; 
	var doPing = new Image();
	// the URL below is a spotlight tag for page
	doPing.src = 'http://ad.doubleclick.net/activity;src=3012733;type=pen2011;cat=' + category + ';ord=1;num=' + a + '?';
	doPing.onload = function() { 
		// $.noop() does nothing, but the presence of a 
		// function call here will ensure the dblclick tracking
		// image is downloaded everytime
		$.noop(); 
	};
	return false;
}

function gaTag(cat,act,label) {
	try {
		_gaq.push(['_trackEvent',cat,act,label]);
	} catch (err) {
		; // do nothing, for now
	}
}
