function popup_window(popup)
	{
	if (!popup.href) { return false; }
	popup.name = popup.name ? popup.name : 'anonymous';
	popup.string = '';
	popup.attributes = ['height','width'];
	if ((screen.height < popup.height) || (screen.width < popup.width))
		{
		popup.attributes[2] = 'scrollbars';
		popup.scrollbars = 1;
		popup.width += 16;
		if (popup.width > screen.width) { popup.width = screen.width; }
		popup.height += 16;
		if (popup.height > screen.height) { popup.height = screen.height; }
		}
	for (prop in popup.attributes)
		{
		var actual_prop = popup.attributes[prop];
		if (popup[actual_prop] == undefined) { next; }
		if (popup.string != '') { popup.string += ","; }
		popup.string += actual_prop + "=" + popup[actual_prop];
		}
	var popup_window = window.open(popup.href, popup.name, popup.string);
	if (window.focus) { popup_window.focus(); }
	return popup_window;
	}
function popup_image_fullsize(url, winname, width, height)
	{
	popup_window({href:url, name:winname, width:width, height:height});
	return false;
	}
function pause(t)
	{
	var start = new Date();
	while (1)
		{
		var now = new Date();
		var elapsed = now - start;
		if( elapsed > t )
			{
			break;
			}
		}
	}
// function XMLHttpRequestObject() {}
//XMLHttpRequestObject.prototype.blomp = true;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
function XMLHttpRequest() {}
try
	{
	XMLHttpRequest.prototype = new ActiveXObject("Msxml2.XMLHTTP");
	}
catch (e)
	{
	try
		{
		XMLHttpRequest.prototype = new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (E)
		{
		XMLHttpRequest.prototype.blomp = true;
		}
	}
@end @*/
//if (!xmlhttp && typeof XMLHttpRequest!='undefined')
//	{
//	XMLHttpRequestObject.prototype = new XMLHttpRequest();
//	}
function zXMLHttpRequestObject()
	{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try
		{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
		{
		try
			{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch (E)
			{
			xmlhttp = false;
			}
		}
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
		xmlhttp = new XMLHttpRequest();
		}
	return xmlhttp;
	}
//var xmlhttp = zXMLHttpRequestObject() ? true : false;
function RemoteRequest(request_obj)
	{
	if (!request_obj.url) { return false; }
	if (!request_obj.charset) { request_obj.charset = "utf-8"; }
	if (!request_obj.method) { request_obj.method = 'post'; }
	if (request_obj.method == 'post') { request_obj.urlencoded = true; }
	if (!request_obj.query) { request_obj.query = ''; }
	if (request_obj.asynchronous != false) { request_obj.asynchronous = true; }
	if (request_obj.args || request_obj.query)
		{
		request_obj.query = GetQueryString({args:request_obj.args, query:request_obj.query});
		}
	if (request_obj.method == 'get')
		{
		if (request_obj.query)
			{
			request_obj.query = '?'+request_obj.query;
			}
		request_obj.url += request_obj.query;
		request_obj.query = null;
		}
	if (!request_obj.type) { request_obj.type = 'responseText'; }
	if (!request_obj.error) { request_obj.error = function (error_message) { alert(error_message); } }
	
	var xmlhttp = XMLHttpRequestObject();
	xmlhttp.open(request_obj.method, request_obj.url, request_obj.asynchronous);
	if (request_obj.urlencoded)
		{
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset="+request_obj.charset);
		}
	if (request_obj.asynchronous)
		{
		xmlhttp.onreadystatechange=function()
			{
			if (xmlhttp.readyState==4)
				{
				if (xmlhttp.status != 200)
					{
					alert('status = '+xmlhttp.status);
					request_obj.error(xmlhttp[request_obj.type]);
					return false;
					}
				if (request_obj.callback)
					{
					request_obj.callback(xmlhttp[request_obj.type]);
					}
				else
					{
					alert('no callback - here goes\n'+xmlhttp[request_obj.type]);
					}
				}
			}
		}
	xmlhttp.send(request_obj.query);
	if (!request_obj.asynchronous) { return xmlhttp[request_obj.type]; }
	return false;
	}
function GetQueryString(request_obj)
	{
	for (var prop in request_obj.args)
		{
		request_obj.args[prop] = request_obj.args[prop].replace(/&/g, '%26');
		if (request_obj.method == 'get')
			{
			if (request_obj.args[prop] != escape(request_obj.args[prop]))
				{
				try
					{
					request_obj.args[prop] = encodeURIComponent(request_obj.args[prop]);
					}
				catch(e)
					{
					HandleEncodingError(request_obj.args[prop])
					}
				}
			}
		request_obj.query += '&'+prop+'='+request_obj.args[prop];
		}
	if (request_obj.query)
		{
		request_obj.query = request_obj.query.replace(/^(\?|&)/,'');
		}
	return request_obj.query;
	}
function HandleEncodingError(prop)
	{
	alert(prop + 'contains characters that may not be sent correctly');
	}
function CreateAPI()
	{
	}
var API = new CreateAPI();
CreateAPI.prototype.nullFunc = function() { alert('do nothing') };
//CreateAPI.prototype.send = xmlhttp ? function() { alert('send') } : CreateAPI.prototype.nullFunc;
