/*
	On static template pages, the /ubi/template/identity/adobe/invoke/cart.ssi is included to attach Event handlers for opening the cart and tracking analytics.
*/


/* getting the current installed version */
/* setting the cartFascade to the current version */
/* when the QA form is submitted, upadate:
	*categoryPath
	*distributionMethod
	*defaultStore
	*defaultCountry
	*requiredVersion

*/


function saveRegionCookie( region ) {
	cart.setStoreRegion(region);
}

function saveUbiCartCookie()
{
	var exp_date = 10*365;
	
	var prevUrl = window.location.href.replace(/index_.\.html/,"");
	
	adobe.Cookie.set( "UBICART" , prevUrl , exp_date , "/", ".adobe.com" );
}

// Analytics starts here
var s_products = '';
var s_eVar45 = '';
var s_events = '';
var s_eVar2 = '';


var analyticsEventInterval = null;
var omnitureVarsQueue = new Array(); 

function reportAnalyticsEvent ( data )
	{
		
		if ( !omnitureVarsQueue )
			omnitureVarsQueue = new Array();
		
		omnitureVarsQueue[ omnitureVarsQueue.length ] = data;
		
		if (analyticsEventInterval == null)
		{
			analyticsEventInterval = setInterval(sendQueuedAnalyticsEvents,200);
		}
	}
	
function sendQueuedAnalyticsEvents () 
{ 
	// for flex apps
	if (omnitureVarsQueue && omnitureVarsQueue.length >= 1)
	{
		var data = omnitureVarsQueue[0];
		omnitureVarsQueue = omnitureVarsQueue.slice(1);
		
		
		for( var prop in data )
		{	
			this[prop] = data[prop];
			
			// need to clear the s obj as well
			if( this.s && data[prop] == "")
			{
				this.s[ prop.substring(2, prop.length) ] = "";	
			}
		}
		
		var ns = s_accountName;
		
		this.s['eVar45'] = "";
		s_eVar45 = "";
		// needs to check how we can invoke omniture.
		void(s_gs(ns));	
		
	}
	
		
	
	if (omnitureVarsQueue.length == 0) 
	{
		clearInterval(analyticsEventInterval);
		analyticsEventInterval = null;
	}
}	



