//
function MOMEXObject(){
    return this; 
}

// Set prototype behaviour
MOMEXObject.prototype.addNamespace = function (prefix, uri){
    if(prefix && uri){
        this.namespace[prefix] = uri;
    }
};


MOMEXObject.prototype.showError = function(msg){
    if(document.showMessage){
        document.showMessage(msg, 'error');
    }
};

MOMEXObject.prototype.showWarning = function(msg){
    if(document.showMessage){
        document.showMessage(msg, 'warning');
    }
};

MOMEXObject.prototype.showMessage = function(msg){
    if(document.showMessage){
        document.showMessage(msg, 'information');
    }
};

MOMEXObject.prototype.showPosition = function(element){

    var left = element.offsetLeft;
    var top  = element.offsetTop;
    while(element=element.offsetParent)
    {
        left += element.offsetLeft;
        top  += element.offsetTop;
    }
    var obj = new Object;
    obj.top = top;
    obj.left = left;
    return obj;
}

MOMEXObject.prototype.getAbsoluteDateTime = function (myDate) {
	var currentDate = new Date ();
	var dateDiff = currentDate.difference(myDate);
	var diffDateTime = Math.abs(dateDiff);
	var tense = 'past';
	if (dateDiff > 0 ) {
		tense = 'future';
	}

	if ( diffDateTime < ( 12*60*60 ) ) {
		text = dateFormat(myDate, "h:MM TT");
	} else {
		text = dateFormat(myDate, "mmmm d, yyyy");
	}
	return text;
}

// Set some standard namespaces.
var ns = [];
ns.AJAX = 'http://www.metrex.net/momex/ajax#';
ns.ajax = ns.AJAX;

ns.MOMEX = 'http://www.metrex.net/momex#';
ns.momex = ns.MOMEX;

MOMEXObject.prototype.namespace = ns;


