
/*******************************************

@Class Name 	= nOOne-ajax
@Autor				= Luca Tolotta
@Version			= 1.0
@Created			= 22/04/2009 12.00
@Update				= 

********************************************/

TypeReturnInnerHTML = 1;
TypeReturnInnerText = 2;
TypeReturnVatiables = 3;
TypeReturnValue 		= 4;
TypeReturnFunction  = 5;


function CallPageAjax(strURL, sObjectReturn, TypeReturn) {
		var xmlHttpReq = false;
    var self = this;
    
    if (window.XMLHttpRequest){/*Mozilla/Safari*/
			self.xmlHttpReq = new XMLHttpRequest();
    }/*IE*/
    else if (window.ActiveXObject) {
    	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    };
   
   self.xmlHttpReq.open("GET", strURL, true);
   
   self.xmlHttpReq.onreadystatechange = function(){
      if (self.xmlHttpReq.readyState == 4) {
        var response = self.xmlHttpReq.responseText;
        UpdatePage(self.xmlHttpReq.responseText, sObjectReturn, TypeReturn);
			};
   };
   
   self.xmlHttpReq.send(null);
};


function UpdatePage(str, sObjectReturn, TypeReturn){
	switch(TypeReturn){
		case TypeReturnInnerHTML:
  		sObjectReturn.innerHTML = str;
  		break;

	case TypeReturnInnerText:
  		sObjectReturn.innerText = str;
  		break;
	
	case TypeReturnValue:
  		sObjectReturn.value = str;
  		break;
	
  case TypeReturnVatiables:
  		sObjectReturn = str;
  		break;
  		
	case TypeReturnFunction:
		var f = new Function(str);
		f();
				
  	break;
		
	default:
  	sObjectReturn = str;
	};
};