YAHOO.namespace("example.container");
function showLoader(){
	        if (!YAHOO.example.container.wait) {
	
	            // Initialize the temporary Panel to display while waiting for external content to load
	
	            YAHOO.example.container.wait = 
	                    new YAHOO.widget.Panel("wait",  
	                                                    { width: "240px", 
	                                                      fixedcenter: true, 
	                                                      close: false, 
	                                                      draggable: false, 
	                                                      zindex:4,
	                                                      modal: true,
	                                                      visible: false
	                                                    } 
	                                                );
	    
	            YAHOO.example.container.wait.setHeader("Loading, please wait...");
	            YAHOO.example.container.wait.setBody("<img src=\"loading.gif\"/>");
	            YAHOO.example.container.wait.render(document.body);
	     	   // Show the Panel
		}
YAHOO.example.container.wait.show();
}
function hideLoader(){
 YAHOO.example.container.wait.hide();
}

function sendAjaxRequest(url, ajaxResponse){
showLoader();
 var callback = {
            success : function(o) {
                ajaxResponse.innerHTML = o.responseText;
                ajaxResponse.style.visibility = "visible";
                hideLoader();
            },
            failure : function(o) {
                ajaxResponse.innerHTML = o.responseText;
                ajaxResponse.style.visibility = "visible";
                ajaxResponse.innerHTML = "CONNECTION FAILED!";
                hideLoader();
            }
          }
//ajaxResponse.innerHTML = "";
// Connect to our data source and load the data
var conn = YAHOO.util.Connect.asyncRequest("POST", url, callback);
}

function getURL(link, object){
	var objectString = "";
	if(object != undefined && object != null)
	{
		for(var objectField in object)
		{
			if(objectString != "")
			{
				objectString += "&";
			}
			if(object[objectField] instanceof Array == false)
			{
				objectString += encodeURIComponent(objectField) + "=" + encodeURIComponent(object[objectField]);
			}
			else
			{
				for(var i = 0; i < object[objectField].length; i++)
				{
					objectString += encodeURIComponent(objectField) + "=" + encodeURIComponent(object[objectField][i]);
					if(i  < object[objectField].length - 1)
					{
						objectString += "&";
					}
				}
			}
		}
	}
	return link+"?"+objectString;

}

function addAjaxEvent(objectId, eventType, handler){
return YAHOO.util.Event.on(objectId, eventType, handler);
}   
