/**
 * @author a
 */

 var myRequest = typeof myRequest !== "undefined"? myRequest : {};
 
 myRequest = {
 	
	request : function(){
		
	var xhr;
	
	if( typeof XMLHttpRequest === "function"){
	
		var xhr =  new XMLHttpRequest();		
	
	}else{
	
		var ids = ['MSXML2.XMLHTTP.3.0',
				   'MSXML".XMLHTTP',
				   'Microsoft.XMLHTTP'];
			
			for(var i = 0; i<ids.length; i++){
				try{
					xhr = new ActiveXObject(ids[i]);
					break;
				}catch(e){}					
			}			
		}
		
	return xhr;
	},
		
	get : function(url, callback){
		xhr = myRequest.request();
		xhr.onreadystatechange = (function(myxhr){
			return function(){
				if(xhr.readyState < 4){
				return;
				}
				if(xhr.status !== 200){
				alert(xhr.status + ' is a wrong status');
				return;
				}

				callback(myxhr);
			}
		})(xhr);

		xhr.open('GET', url, true);
		xhr.send('');
		
	},	
	
	post : function(url, send, callback){
		xhr = myRequest.request();
		xhr.onreadystatechange = (function(myxhr){
			return function(){
				if(xhr.readyState < 4){
				return;
				}
				if(xhr.status !== 200){
				alert(xhr.status + ' is a wrong status');
				return;
				}

				callback(myxhr);
			}
		})(xhr);

		xhr.open('POST', url, true);
		xhr.send(send);
		
	}	
 }
 



