/* Base JS for namespacing support and such
* Sources:
* - http://www.zachleat.com/web/2007/08/09/yui-code-review-yahoonamespace/
*/
if (typeof Timexchange == "undefined") {
    var Timexchange = {};
}
Timexchange.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a .length; i=i+1) {
        d=a[i].split(".");
        o=Timexchange; 

        // Timexchange is implied, so it is ignored if it is included
        for (j=(d[0] == "Timexchange") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};

Timexchange.namespace("Window");
Timexchange.Window = function () {
	return  {
	    Popup: function(url, width, height) {
            return window.open(url, null, "height="+height+",width="+width+",location=no,menubar=no,status=no,toolbar=no,scrollbars=yes");
	    },
	    BreakOutOfFrames: function() {
			if (top.location != location) {
				top.location.href = document.location.href;
			}
	    }
	};
}();


Timexchange.namespace("Window.OnLoad");
Timexchange.Window.OnLoad = function () {
	return  {
	    Add: function(func) {
			$(document).ready(func);
	    }
	};
}();

jQuery.fn.gate = function(condition) {
    return condition ? this : [];
};
