// This is my javascript file!

	function LoadNodeInfo() {
		
		// Get the objects for the form fields we need to replace
		tObj = document.getElementById('edit-field-promote-headline-0-value');
		sObj = document.getElementById('edit-field-promote-subheadline-0-value');
		cToAObj = document.getElementById('edit-field-call-to-action-0-value');
		
		// Save the original values in case we need to rollback
		tOrig = tObj.value;
		sOrig = sObj.value;
		cToAOrig = cToAObj.value;
		
		status_message = "Loading....";
		
		//tObj.value = status_message;
		//sObj.value = status_message;
		//cToAObj.value = status_message;
		
		// Get the node_id that has been entered
		var node_id = document.getElementById('nodeid').value;
		
		// If the node_id field isn't empty, try and load that node info
		if (node_id != '') {
		
			// AJAX call to load the promote info from the module
			$.get('/etr_utilities/load_promote_info/' + node_id, function(data) {
				
				// If the node was invalid, then the module returns a 0
				// Otherwise, continue processing
				if (data != '0') {
				
					// Explode the string on ||| (our field separator)
					var values = data.toString().split("|||");
					
					// Save each piece of the array into variables for easier testing
					var pTitle = values[1];
					var subpTitle = values[2];
					var cToA = values[3];
					
					// Test for the Promote Title
					//if (confirm("Do you really want to replace the Promote Title with: " + pTitle + "?")) {				
						tObj.value = pTitle;				
					//}
					//else {
					//	tObj.value = tOrig;
					//}
					
					// if (confirm("Do you really want to replace the Promote Subtitle with: " + subpTitle + "?")) {				
						sObj.value = subpTitle;				
					//}
					//else {
					//	sObj.value = sOrig;
					//}
					
					// Test for the Call To Action
					//if (confirm("Do you really want to replace the Call To Action with: " + cToA + "?")) {
						cToAObj.value = cToA;
					//}
					//else {
					//	cToAObj.value = cToAOrig;
					//}
					
				}
				else {
				
					alert('That is an invalid node reference.');
					
					tObj.value = tOrig;
					sObj.value = sOrig;
					cToAObj.value = cToAOrig;
				
				}
				
			});
		
		}
		else {
			alert('No node ID specified');
		}
	
	}
	



