/**
 * renderes only the plain.jsp with sitemesh.
 * (the result should only contain java-script code with tracking-information)
 * this code will be evaluated (because of 'dataType : "script"') 
 */
function invokeTracking()
{
	console.log("retrieving trackingcode");
	$.ajax({
		type:'GET',
		url:'/tracking/dummy.action',
		async:true,
		cache:false,
		dataType: "script",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			console.error(XMLHttpRequest, textStatus, errorThrown);
		},
		success:function(data){
			console.log("trackingcode rendered");
		}
	});

}
/**
 * tells webtrekk to track customEcommerceParameter 13
 */
function trackLinkOnCartPopUp(variantId)
{
	console.log("track link on cart popup");
	$.ajax({
		type:'GET',
		url:'/tracking/cartLink.action',
		async:false,
		cache:false,
		dataType : "script",
		data: ({id : 13, ref : variantId}),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			console.error(XMLHttpRequest, textStatus, errorThrown);
		},
		success:function(data){
			console.log("ecommerce param tracked");
		}
	});

}

/**
 * checks if some relevant trackingdata is set
 * (also if a form is on the page)
 * @param wt_data
 * @returns {Boolean}
 */
function containsTrackingData(wt){
	if (wt== null)
		return false;
	
	if (wt.customSessionParameter)
		return true;
	if (wt.customerId)
		return true;
	if (wt.customParameter)
		return true;
	if (wt.product)
		return true;
	if (wt.productCategory)
		return true;
	if (wt.productQuantity)
		return true;
	if (wt.productCost)
		return true;
	if (wt.productStatus)
		return true;
	if (wt.customEcommerceParameter)
		return true;
	if (wt.contentGroup)
		return true;
	
	if ($('input[name="wt_form"]').length!=0)
		return true;
	 
	
	return false;
}
