function setGrid(gridName, myData, myColumns, cellFormat) {
	var obj;
	try{
		obj = new AW.UI.Grid;
		obj.setId(gridName);
	       //	define data formats
	    var str = new AW.Formats.String; 
	    var num = new AW.Formats.Number; 
	       
		obj.setCellFormat(cellFormat);
	       
	        //	provide cells and headers text
		obj.setCellText(myData);
		obj.setHeaderText(myColumns);
	       
	        //	set number of rows/columns
		obj.setRowCount(myData.length);
		
		obj.setColumnCount(myColumns.length);
	        //	enable row selectors
		obj.setSelectorVisible(true);
		obj.setSelectorText(function (i) {
			return this.getRowPosition(i) + 1;
		});
	
	        //	set headers width/height
		obj.setSelectorWidth(30);
		obj.setHeaderHeight(20);
	
	        //	set row selection
		obj.setSelectionMode("single-row");
	    
		//obj.setVirtualMode(false);
		
		obj.loadingCompleted= function() { 
		    if (obj._maskLoading) { 
		       obj._maskLoading.style.display = 'none'; 
	        } 
		}
		
		obj.loading = function() {
			if (! obj._maskLoading) { 
		        var maskLoading = document.createElement('div'); 
		        document.body.appendChild(maskLoading); 
		        maskLoading.className = 'aw-grid-loading'; 
		        var gridEl = obj.element(); 
		        maskLoading.style.left = AW.getLeft(gridEl) + 'px'; 
		        maskLoading.style.top = AW.getTop(gridEl) + 'px'; 
		        maskLoading.style.width =  gridEl.clientWidth + 'px'; 
		        maskLoading.style.height =  gridEl.clientHeight + 'px'; 
		        obj._maskLoading = maskLoading; 
		   	}
	        obj.clearCellModel(); 
		    obj.clearRowModel(); 
		    obj.clearScrollModel(); 
		    obj.clearSelectionModel(); 
		    obj.clearSortModel(); 
		    obj.refresh(); 
	    	obj._maskLoading.style.display = 'block'; 
	    } 
		
		obj.disabled = function() { 
		    if (! obj._maskEl) {
		        var maskEl = document.createElement('div'); 
		        document.body.appendChild(maskEl); 
		        maskEl.className = 'aw-grid-mask'; 
		        var gridEl = obj.element(); 
		        maskEl.style.left = AW.getLeft(gridEl) + 'px'; 
		        maskEl.style.top = AW.getTop(gridEl) + 'px'; 
		        maskEl.style.width =  gridEl.clientWidth + 'px'; 
		        maskEl.style.height =  gridEl.clientHeight + 'px'; 
		        obj._maskEl = maskEl;
		    }
		    obj._maskEl.style.display = 'block'; 
		}; 
		
		obj.enabled= function() {
		    if (obj._maskEl) {
		        obj._maskEl.style.display = 'none';
		    }
		}
	
	}catch(err){
		      txt="There was an error on this page.\n\n";
              txt+="Error description: " + err.description + "\n\n";
              txt+="Click OK to continue.\n\n";
              errorUrl=location.pathname +"|"+ err.name +"|"+ err.message+"\n";
              alert(txt);
    }
	
    return obj;
}

function $(obj){
	return document.getElementById(obj);
}

function checkConfirm(option){
	return confirm('Are you sure you want to '+option+' this record ?');
}

function trim(value){
	var val='';
	for(var i=0;i<value.length;i++){
		if(value.charAt(i)!=' '){
			val=value.substring(i,value.length);
			break;
		}
	}
	for(var i=val.length-1;i>=0;i--){
		if(val.charAt(i)!=' '){
			val=val.substring(0,i+1);
			break;
		}
	}
	return val;
}

function CreateXHR(action,func){
    var request=this;
	request.ajax=null;
    try {
        request.ajax = new ActiveXObject('Msxml2.XMLHTTP');
    }catch (err1) {
        try {
            request.ajax = new ActiveXObject('Microsoft.XMLHTTP');
        }catch (err2) {
			try {
				request.ajax = new XMLHttpRequest();
			}catch(err3){
				request.ajax = false;
			}
		}
	}
	request.ajax.onreadystatechange=function(){
		if (request.ajax.readyState == 4) {
			if (request.ajax.status == 200) {
				func(request.ajax.responseText);
			}
		}
	};
	var go=null;
	request.go=function(data,method){
		request.ajax.open(method, action, true);
	   	request.ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		request.ajax.send(data);
	};
	return request;
}

function ajaxObject(url, callbackFunction) {
	var that=this;      
  	this.updating = false;
  	this.abort = function() {
   		if (that.updating) {
      		that.updating=false;
      		that.AJAX.abort();
      		that.AJAX=null;
    	}
  	}
  	
	this.update = function(passData,postMethod) { 
    	if (that.updating) { 
    		return false;
    	}
    	that.AJAX = null;                          
   		if (window.XMLHttpRequest) {              
     			that.AJAX=new XMLHttpRequest();              
   		} else {                                  
     			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
   		}                                             
   		if (that.AJAX==null) {                             
     			return false;                               
   		} else {
     		that.AJAX.onreadystatechange = function() {  
	       		if (that.AJAX.readyState==4) {             
         			that.updating=false;                
         			that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
         			that.AJAX=null;                                         
    	   		}                                                      
     		}
	   		that.updating = new Date();                              
			if (/post/i.test(postMethod)) {
	       		var uri=urlCall+'?'+that.updating.getTime();
		        that.AJAX.open("POST", uri, true);
	       		that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		        that.AJAX.setRequestHeader("Content-Length", passData.length);
		        that.AJAX.send(passData);
			} else {
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
			    that.AJAX.open("GET", uri, true);                             
		        that.AJAX.send(null);                                         
			}              
			return true;                                             
		}                                                                           
  	}
	var urlCall = url;        
  	this.callback = callbackFunction || function () { };
}
