/*
var opGaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + opGaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
*/

/*
gatcId_S =			Google Analytics Tracking Code ID, e.g. UA-XXXXXX-Y
domain_S =			Domain where GATC is implemented, e.g. op.dk
trackType_S =		Type of data that is tracked, e.g. PDF downloads, online contact form submissions or click on e-mail addresses
trackSkuCode_S =	Internal product ID (SKU code) that is tracked 
*/

function opTrack(gatcId_S, domain_S, trackType_S, trackSkuCode_S, _gat) {

	var opPageTracker = _gat._getTracker(gatcId_S);
	opPageTracker._initData();
	opPageTracker._trackPageview();

	if (opPageTracker === undefined ||
		gatcId_S === undefined ||
		gatcId_S.length == 0 ||
		domain_S === undefined ||
		domain_S.length == 0 ||
		trackType_S === undefined ||
		trackType_S.length == 0) {
		
		// Do nothing
		
		
		
	} else { 
	
		var time_now = new Date();
		var epoch = time_now.getTime();
		var randomNumber = Math.floor((Math.random()*32767));
		var gatcOrderId = epoch.toString() + randomNumber.toString();
		
		// _addTrans parameter description
		// 1. GATC order ID (Required)
		// 2. Affiliation (I.e. store, channel)
		// 3. Total value (Excl. tax and shipping )  (Required)
		// 4. Tax
		// 5. Shipping
		// 6. City
		// 7. State or province
		// 8. Country
		
		opPageTracker._addTrans(
			gatcOrderId.toString(), 
			domain_S,
			'1.00',
			'0',
			'0',
			'',
			'',
			''
		);
		
		// _addItem parameter description
		// 1. GATC order ID (Required)
		// 2. SKU code (Stock Keeping Unit i.e. internal product ID)
		// 3. Product name
		// 4. Category or variation
		// 5. Unit price (Required)
		// 6. Quantity (Required)
		
		opPageTracker._addItem(
			gatcOrderId.toString(), 
			trackSkuCode_S,
			trackType_S,
			trackType_S,
			'1.00',
			'1'
		);
		
		opPageTracker._trackTrans();
	}
}
