//network central tracking control script
//copyright 2009 Analytics Pros, Inc. (analyticspros.com)
//licensed to Digital Five, Inc. (digitalfive.com)


function utmCrossTrk (cPage, passCookies, value) {
	// cPage: a custom page to specify the Pageview string
	// passCookies: boolean - should GA provide a URL including the cookies?
	
	
	var tracker = window.utmCrossTracker, 
			iframe_url = document.location.protocol + '//tracker.digitalfive.com/track.asp';

	// These get passed as arguments in the URL (to the iframe)
	var values = {
		pRef: document.referrer.toString(),
		pPage: document.location.toString(),
		cPage: cPage,
		type: 'pageview',
		'value': value // optional
	};

	// compose a parameter string
	var params = document.location.search;
	for(var i in values) {
		params += '&' + urlencode(i) + '=' + urlencode(values[i]);
	}

	// assemble the iframe source URL
	iframe_url += '?params' + params;
	if(passCookies && tracker) iframe_url = tracker._getLinkerUrl(iframe_url, true);

	
/*	
	var iframe = document.getElementById("_UTM_iframe_tracker");
	iframe.src = iframe_url; 
	
	// remove the iframe if it already exists
	var l = document.getElementById('_UTM_iframe_tracker');
	if(l && l.parentNode) {
		l.parentNode.removeChild(l);
	}

	// generate the iframe (again)
	var b = document.getElementsByTagName('body')[0];
	var f = document.createElement('iframe');
	f.setAttribute('id', '_UTM_iframe_tracker');
	f.setAttribute('src', iframe_url);
	f.setAttribute('style', 'display: none; height: 0; width: 0;');
	f = b.appendChild(f);
	if(f.style) f.style.display = 'none';
*/

	return iframe_url;
}

function urlencode(s) {
	var e = escape(s).replace(/[*+\/@]|%20/g, function(t){
		switch(t){
		case '%20': return '+';
		default: return t.toString(16);
		}
	});
	return e;
}

document.write('<iframe id="_UTM_iframe_tracker" src="'+iframe_url+'" style="display: none; height: 0pt; width: 0pt;"/>');
