function saveToPage(mode, userId, pageId) {
	var savePageDivs = document.getElementsByClassName('saveToPage');	
	var pageUrl = escape(window.location.pathname);
	var queryString = new String(window.location.search);
	var hash = window.location.hash.replace(/#/gi, '');
	
	// in case we want to save the currently opened section
	// this has implications though
	// ask PRF before commenting out this line
	hash = '';
	
	queryString = escape(window.location.search.replace(/\?/gi, ''));
		
	new Ajax.Request
	(
	
		'/__Ajax/SavePage.aspx', 
		{
			method: 'get', 
			parameters: 'mode=' + mode + '&user_id=' + userId + '&record_id=' + pageId + '&page_url=' + pageUrl + '&query_string=' + queryString + '&hash=' + hash, 
			onComplete: function(req) 
			{
			    if (req.responseText == 'True'){
					for (i=0; i < savePageDivs.length; i++) {
						savePageDivs[i].className = "saveToPageTick";
						savePageDivs[i].innerHTML = "<span>page saved</span>";
					}
					
					/* In case NU wants a timeout to change it back to save to page
					function tick(){
						savePageDivs[0].className = "saveToPage";
						savePageDivs[0].innerHTML = 'save to page';
					}
					setTimeout(tick, 8000);*/				
				}
			    else {
			        alert('There has been an error saving the page.');
				}
			}.bind(this)
		}
	)
}


function saveToPageNeeds(mode, userId, pageId) {
	var savePageNeeds = document.getElementsByClassName('saveToPageNeeds');
	var pageUrl = escape(window.location.pathname);
	var queryString = new String(window.location.search);
	var hash = window.location.hash.replace(/#/gi, '');
	
	// in case we want to save the currently opened section
	// this has implications though
	// ask PRF before commenting out this line
	hash = '';
	
	queryString = escape(window.location.search.replace(/\?/gi, ''));
	
	// uncomment these if you wish to prevent save to page at the top of solution from having the step in it.
	//if (mode == 'scenarios')
	//    queryString = '';
		
	new Ajax.Request
	(
	
		'/__Ajax/SavePage.aspx', 
		{
			method: 'get', 
			parameters: 'mode=' + mode + '&user_id=' + userId + '&record_id=' + pageId + '&page_url=' + pageUrl + '&query_string=' + queryString + '&hash=' + hash, 
			onComplete: function(req) 
			{
			    if (req.responseText == 'True'){
					for (i=0; i < savePageNeeds.length; i++) {
						savePageNeeds[i].className = "saveToPageNeedsTick";
						savePageNeeds[i].innerHTML = "<span>page saved</span>";
					}		
				}
			    else {
			        alert('There has been an error saving the page.');
				}
			}.bind(this)
		}
	)
}