
/**************************************************************************/
/**************************************************************************/

var SBUList = eval('(' + '{"getAllSBUs":{"ALM":"ALM","SNM":"SNM","REMAN":"REMAN","OTHER":"OTHER","CF":"CF","SNPS":"SNPS","AT":"AT"}}' + ')');

$(document).ready(function() {
	setup();
});
		

/***********************************Start: Action Handlers**********************************************/
	function setup(){
		setupListenersPullDown('.pulldownSBU', 80, SBUList.getAllSBUs, 'update');
		$('.pulldownSBU').text('REMAN');
		
	    $('#commitAccountIdentifierListIcon').click( function() {
	    	var a = $('.pulldownSBU').data('selectKeyValue');
	    	alert("Commit pressed " + a);
	     });
	
	}
	
	function setupListenersPullDown(selectID, iWidth, list, action) {    	
    	$(selectID).editable(  function (sVal) {
          return sVal;
		}, {
		type: 'select',
		id: selectID +'_id',
		data: function(value, settings) {
			   //These were read in before the Data Table was loaded.  (see above)
			   //value contains the text of the cell.
			   var jsonArray = "{";
			   var selected = "";
			   $.each(list, function(key, thisValue) { 
				   jsonArray=jsonArray+('"'+key+'":"'+thisValue+'",'); 
				   if (value==thisValue) {
					  selected = '"selected":"'+key+'"}';
					  $('.pulldownSBU').data('selectKeyValue',key);
				   }
			   });
			   if(value == undefined || value == 'undefined' || value == '') {
				   jsonArray = jsonArray.substring(0,jsonArray.lastIndexOf(',')) + "}";
			   }			   
			   jsonArray=jsonArray+selected;
			   return eval('(' + jsonArray + ')');
			}
		,    
		'callback': function( sValue, settings ) {
           $(this).data('selectKeyValue',sValue);
           alert("callback called");
		},
		onblur  : 'submit',						
		tooltip : 'click to edit',		
		height  : '14px',
		width   : iWidth
    	} );      		
	}
	
