
function openPage(pageName, targetComponent, request)
{
	if (targetComponent == null)
	{
		gotoPage(pageName, request);
		return;
	}
	pageName += ".htm";
	//targetComponent.load()
}

var AllInOneUrlPrefix = "";

function gotoPage(pageName, request)
{
	var newLocation = AllInOneUrlPrefix + "PageLoader.php?PageName=" + pageName;
	for (key in request) {
		newLocation += "&" + key + '=' + encodeURIComponent(request[key]);
	}
	window.location.href = newLocation;
}

var ivLawTemplate = false;

function gotoTemplate(pageName, request)
{
	var newLocation = AllInOneUrlPrefix + "PageLoader.php?TemplateName=" + pageName;
	if (ivLawTemplate)
		newLocation = AllInOneUrlPrefix + "../ivlaw/app/ivIndex.html#/" + pageName;
	
	for (key in request) {
		if (request[key] == null || request[key] == "")
			continue;
		
		if (ivLawTemplate)
		newLocation += "/" + key + '/' + encodeURIComponent(request[key]);
		else
		newLocation += "&" + key + '=' + encodeURIComponent(request[key]);
	}
	window.location.href = newLocation;
}

if (typeof APIService == 'undefined')
{
	APIService = {
			createAPI: function(url) {
				return function(request){
					return {request: request, then: function(callback){
						$.post(url, request, function(data){
							callback({data: data});
						}, "json");
						
					}};
				}
			}
	};
}