
//douglas crockford's prototypal inheritance function
//http://javascript.crockford.com/prototypal.html
if (typeof Object.create !== 'function') {
    Object.create = function (o) {
        function F() {}
        F.prototype = o;
        return new F();
    };
}



//create namespace
sector67 = {};

sector67.loadCSS = function(stylesheet) {
	//alert("in loadcss for '" + stylesheet + "'");
	var oLink = document.createElement('link')
	oLink.href = stylesheet;
	oLink.rel = 'stylesheet';
	oLink.type = 'text/css';
	document.body.appendChild(oLink);
};

// *** Ajax calls *************************************

//anonymous function to build sec67 ajax function
(function () {
	function GetXmlHttpObject() {
		var xmlHttp=null;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		} catch (e)	{
			// Internet Explorer
			try	{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)	{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}
	
	function makeAjaxCallback(forXmlHttp, successFunc) {
		return function () {
				if (forXmlHttp.readyState==4 || forXmlHttp.readyState=="complete") { 
					successFunc(forXmlHttp.responseText);
				}
		}
	}
	
	sector67.ajaxGet = function (url, params, callback) {
		var xmlHttp;
		xmlHttp=GetXmlHttpObject();
		if (params!="") url += "?" + params;
		xmlHttp.onreadystatechange = makeAjaxCallback(xmlHttp, callback);
		xmlHttp.open('GET', url, true);
		xmlHttp.send(null);
	}

	sector67.ajaxPost = function(url, params, callback) {
		var xmlHttp;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange = makeAjaxCallback(xmlHttp, callback);
		xmlHttp.open('POST', url, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(params);
	}
}) ();
