// avail recommendation product columns
function getAvailSaaSProductColumns() {
	return ['ProductId','Name','NetUnitPrice','LinkURL','ImageURL'];
}

// default mapping of avail product recommendation response parameters 
function mapAvailSaaSDefaultProductRecommResponse(availResponse){
	var recommendations = new Array();
	var length = availResponse.length;
	if(availResponse != null)
	{
		for(var i = 0; i < availResponse.length; i++)
		{
			recommendations.push({"name":availResponse[i][1], "price":availResponse[i][2], "imageURL":availResponse[i][3], "URL":availResponse[i][4]});
		}
	}
	return recommendations;
}

// send Avail product recommendation request




function getAvailSaaSProductRecommendations(productID, templateName, productlinksskus){
	if (productID != null && productID != "" && templateName != null && templateName != "")
	{
	    //Create emark object
	   // var emark = new Emark();
	    //Request recommendations
	    
	    var prodRecs = emark.getRecommendations(templateName , 'ProductId:'+ productID);
	    //if(productlinksskus != null && productlinksskus != ""){
	    //upsellLinksSkus=productlinksskus;
	    //}
	   
}
}


function getAvailSaaSProductsRecommendations(productIDs, templateName){
	if (productIDs != null && productIDs != "" && templateName != null && templateName != "")
	{
	    //Create emark object
	    // var emark = new Emark();
	    //Request recommendations
	    
	    var prodRecs = emark.getRecommendations(templateName , 'ProductIds:'+ productIDs );
}else if(templateName != null && templateName.indexOf('Warenkorb_Highlight') !=-1 )
{
	var prodRecs = emark.getRecommendations(templateName , 'ProductIds:'+ '12345' );
}

}
//send Avail user recommendation request
function getAvailSaaSUserRecommendations(userID, templateName, responseHandler, responseType){
	if (userID != null && userID != "" && templateName != null && templateName != "")
	{
	    //Create emark object
	    var emark = new Emark();
	    //Request recommendations
	    var userRecs = emark.getUserPredictions(userID, templateName, '', getAvailSaaSProductColumns());
	    //The code of the responseHandler method brackets will be executed when the predictions are committed
	}
}

//send Avail search recommendation request
function getAvailSaaSSearchRecommendations(searchTerm, templateName, responseHandler, responseType){
	if (searchTerm != null && searchTerm != "" && templateName != null && templateName != "")
	{
	    //Create emark object
	    var emark = new Emark();
	    //Request recommendations
	    var userRecs = emark.getSearchPredictions(searchTerm, templateName, '', getAvailSaaSProductColumns());
	    //The code of the responseHandler method brackets will be executed when the predictions are committed

	}
}

// send Avail order event
function sendAvailSaaSOrderEvent(userID, productIDs, prices, documentno, currency){
	if(userID == null || userID == "" )userID=documentno;
	if (productIDs != null && productIDs != "")
	{
	     //log order event
	    var status = emark.logPurchase(userID, productIDs, prices, documentno, currency);
	}
}

//send Avail search event
function sendAvailSaaSSearchEvent(searchTerm, productID, responseHandler, responseType){
	if (searchTerm != null && searchTerm != "" && productID != null && productID != "")
	{
	    //Create emark object
	    var emark = new Emark();
	    //log order event
	    var orderResponse = emark.saveSearch(searchTerm, productID);

	}
}

//send Avail ClickedOn event
function sendAvailSaaSClickedOn(productID,trackingcode){
	if ( productID != null && productID != "")
	{
	    //Create emark object
	    //log order event
	    var status=null;
	    //var trackingcode=getCookie("avail_trackingcode");
	    if (trackingcode != null && trackingcode.length > 0){
	    	status = emark.logClickedOn(productID, trackingcode);
	    }
	}
	
}


//send Avail AddToBasket event
function sendAvailSaaSAddedToCartEvent(productID,trackingcode){
	if ( productID != null && productID != "")
	{
	    //Create emark object
	    //log order event
	    var status=null;
	    if (trackingcode != null && trackingcode.length > 0){
	    	status = emark.logAddedToCart(productID, trackingcode);
	    }else{
	    	status = emark.logAddedToCart(productID);
	    }
	}
	
}


//send Avail Removed From Cart event
function sendAvailSaaSRemovedFromCartEvent(productID){
	if ( productID != null && productID != "")
	{
	    //Create emark object
	    //log order event
	    var status=null;
	    
	    	status = emark.logRemovedFromCart(productID);

	     emark.commit(function() {
	    			});
	}
	
}


// Presentation Methods
