var sectionXML;
var contentXML;
var siteXML;
var userXML;
var suggestXML;
var gatewayXML;
var pricingXML;
var receiptXML;
var subscriptionXML;

var curLocation = location.href;
var isQI = curLocation.match("quickinsert.com");
var isLocal = curLocation.match("localhost");
var isSSL = curLocation.match("https");
var isWWW = curLocation.match("www.");


if (isLocal != null)
  var defaultReqURL = "http://localhost";
else
  var defaultReqURL = "http://www.quickinsert.com";
  
//if (isSSL != null)
//	defaultReqURL = defaultReqURL.replace(/http/,"https");

if (isWWW == null && isQI != null)
	window.location = curLocation.replace(/quickinsert\.com/,"www.quickinsert.com");
	
//defaultReqURL = "";

//alert(defaultReqURL);

function globalGetReceipts (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetReceipts.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetSubscriptions (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetSubscriptions.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetSuggestions (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetSuggest.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetPricing (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetPricings.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetGateway (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetGateways.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetContent (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetContent.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetUsers (sID, siteID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetUsers.php",
					dataType: "xml",
					data: "sID="+sID+"&siteID="+siteID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetAllUsers (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetUsers.php",
					dataType: "xml",
					data: "sID="+sID+"&siteID=0",
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
					}
				});
			});	
	
}
function globalGetSites (sID, func) {
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetSites.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData)
					{
						if (func != null) {
							callFunction(func, xmlData);
						} 
						
					}
				});
			});	
	
}
function globalGetSections (sID, func) {	
		  $(function() {
				$.ajax({
					type: "GET",
					url: defaultReqURL+"/API/GetSections.php",
					dataType: "xml",
					data: "sID="+sID,
					//timeout: 3000,
					error: function(){
						alert('Error loading XML');
					},
					success: function(xmlData) { 
						if (func != null) {
							callFunction(func, xmlData);
						} 
						//return xmlData;
					} //success!
				});
			});
}
function callFunction(func, object)
{
    func(object);
}