var allProductsRequested;

function setAllProductsRequested(myJSONObject){		
	allProductsRequested = myJSONObject;
}

function getAllProductsRequested(){	
	return allProductsRequested;
}


function initPricingAjax(requestName, objName) {
	// Add command request
	ajaxEngine.registerRequest(requestName, requestName);
	registerPricingAjaxObjects(objName);
}


// Add Objects to use for Ajax
function registerPricingAjaxObjects(objName) 
{
	var AjaxResponseObject = {};
	AjaxResponseObject.ajaxUpdate = function(ajaxResponse) {				
		var fieldNames = ajaxResponse.childNodes;  
		var stringToUse = {};		
		for (var i = 0; i < fieldNames.length; i++) 
	   	{	  
	   		if ((fieldNames[i].nodeType == 1) && (fieldNames[i].getAttribute("id")=="products"))
	   		{	 
	   			var extendedTextNodes = fieldNames[i].childNodes;
	   			for(var textCount = 0; textCount < extendedTextNodes.length; textCount++){
	   				if(textCount==0)
	   					stringToUse = fieldNames[i].childNodes[textCount].data;
	   				else
	   					stringToUse = stringToUse + fieldNames[i].childNodes[textCount].data;
	   			}				
				break;
	   		}	   			   		
	   	}
	   	 						
		var myJSONObject = eval('('+stringToUse+')');	
		setAllProductsRequested(myJSONObject);			
		updateAllPricingValues();
	}

	ajaxEngine.registerAjaxObject(objName, AjaxResponseObject);
}	

/* QN 10/16/08: added this function so that it could be used in the future to determine when to call the pricing ajax cmd */
function getContractPricesAjax(nvps)
{
		var requestName = 'SYGetContractUnitPrices';
		initPricingAjax(requestName, 'ProductPricingAjaxResponseObject');
		//if (isUserInEpp() && isUserLoggedIn())
		/* QN 2/16/09: Updated for EDU project, to NOT check for if the user is logged in */
		if (isUserInEpp())
			ajaxEngine.sendRequest(requestName, {method:'post', parameters:nvps, asynchronous: false});	
}



