/////////////////////////////////////////////////////////////////////
//Core Ajax Library
/////////////////////////////////////////////////////////////////////				
/*
	Version: 1.0
	Last changed: Feb 2009
	bases on mootools lib (1.2)
	Copyright by Christoph Stitz
*/
/////////////////////////////////////////////////////////////////////
//Info
/////////////////////////////////////////////////////////////////////
/*	
	
*/
/////////////////////////////////////////////////////////////////////
//Bugs
/////////////////////////////////////////////////////////////////////
/*	
	
*/
/////////////////////////////////////////////////////////////////////
//Behobene Bugs
/////////////////////////////////////////////////////////////////////
/*	
	
*/
/////////////////////////////////////////////////////////////////////
//Todo
/////////////////////////////////////////////////////////////////////
/*	
	
*/
/////////////////////////////////////////////////////////////////////
//Globals
/////////////////////////////////////////////////////////////////////
var CoreAjaxRequest = null; //save Request Handle
var CoreAjaxRequestBusy = false; // Safe if busy or not



/////////////////////////////////////////////////////////////////////
//Functions
/////////////////////////////////////////////////////////////////////

function CoreAjaxEvaluate(url,method,data)//make a request and evaluate javascript
{
	if(CoreAjaxRequestBusy==false)//if core ajax is not already doing anithing...
	{
		//send ajax request
		CoreAjaxRequest = new Request({  
			method: method,  
			url: url,  
			data: data,
			onRequest: function()
			{
				CoreAjaxRequestBusy = true;
			},  
			onComplete: function(response)
			{
				CoreAjaxRequestBusy = false;
				//alert("Core Ajax Script:\n\nExecute: "+response);//debug
				eval(response);
			},
			onFail: function()
			{
				alert("Core Ajax Script:\n\nRequest failed! :-(");
			}
		}).send();
	}
	else
	{
		alert("Core Ajax Script:\n\nCan not perform request because another is already in action!");
	}
}

function CoreAjaxLoadContent(url,method,data,obj)//make a request and load content directly
{
	//if(CoreAjaxRequestBusy==false)//if core ajax is not already doing anithing...
	//{
		//send ajax request
		CoreAjaxRequest = new Request({  
			method: method,  
			url: url,  
			data: data,
			evalScripts : true,//evaluate script tags
			onRequest: function()
			{
				CoreAjaxRequestBusy = true;
			},  
			onComplete: function(response)
			{
				CoreAjaxRequestBusy = false;
				//alert("Core Ajax Script:\n\nExecute: "+response);//debug
				obj.set('html',response);
			},
			onFail: function()
			{
				alert("Core Ajax Script:\n\nRequest failed! :-(");
			}
		}).send();
	//}
	//else
	//{
	//	alert("Core Ajax Script:\n\nCan not perform request because another is already in action!");
	//}
}

