function quickPost(argObj) {
	var new_form = document.createElement("form");
	new_form.method = "post";
	new_form.action = "";
	new_form.style.display = "none";
	if(typeof(argObj) == "object") {
		for (prop in argObj) {
			var new_param = document.createElement("input");
			new_param.type = "hidden";
			new_param.name = prop;
			new_param.value = argObj[prop];
			new_form.appendChild(new_param);
		}
	} else {
		var new_param = document.createElement("input");
		new_param.type = "hidden";
		new_param.name = "quickPost";
		new_param.value = argObj;
		new_form.appendChild(new_param);	
	}
	document.body.appendChild(new_form);
	new_form.submit();
}
var ajx_base = "ajax.asp";
function ajx(argObj) {
	var i = 0;
	var arr = new Array();
	var evalScr = "";
	if (typeof(argObj) == "object") {
		// example ajx({ajax:"site_subscribe", eml:email, something:"alert('');"});
		for (var prop in argObj) {
			evalScr = argObj[prop];
			arr[i] = prop + "=" + URLEncDec.encode(evalScr);
			i++;
		}
		//the last prop is evaluated on complete
	} else {
		// example ajx("site_subscribe", email, "alert('');");
		var arg = ajx.arguments;
		for (i = 0; i < arg.length - 1; i++) {
			arr[i] = URLEncDec.encode(arg[i]);
		}
		evalScr = arg[i];//the last prop is evaluated on complete
	}
	var myAjax = new Ajax.Request (
		ajx_base + "?" + arr.join("&"), 
		{
			onComplete: function (originalRequest) {
				evalScr = String(evalScr).replace(/_response_/g, originalRequest.responseText);
				if (evalScr != "") eval(evalScr);
			},
			method: "get"
		}
	);
}
function ajxt(argObj) {
	var i = 0;
	var arr = new Array();
	var evalScr = "";
	if (typeof(argObj) == "object") {
		for (var prop in argObj) {
			evalScr = argObj[prop];
			arr[i] = prop + "=" + URLEncDec.encode(evalScr);
			i++;
		}
		//the last prop is evaluated on complete
	} else {
		var arg = ajxt.arguments;
		for (i = 0; i < arg.length - 1; i++) {
			arr[i] = URLEncDec.encode(arg[i]);
		}
		evalScr = arg[i];//the last prop is evaluated on complete
	}
	window.open(ajx_base + "?" + arr.join("&"));
}
function SetCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue) + "; expires=Mon, 31 Dec 2010 23:59:59 UTC;";
}
function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	// a name/value pair (a crumb) is separated by an equal sign
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
	}
	// a cookie with the requested name does not exist
	return null;
}
function GetCheckCount(checkName) {
	var colCheckBoxes = document.getElementsByName(checkName);
	var intCheckedCount = 0;
	for(var i = 0; i < colCheckBoxes.length; i++) {
		if(colCheckBoxes[i].checked) intCheckedCount++;
	}
	return intCheckedCount;
}
function getElm(sID) {
	return document.getElementById(sID);
}
function getElmValue(sID) {
	var elm = document.getElementById(sID);
	if(elm == null) return "";
	if(typeof(elm) != "object") return "";
	if(elm.value == null) return "";
	if(typeof(elm.value) != "string") return "";
	return elm.value;
}
function URLEncode(sStr) {
    return escape(sStr).
              replace(/\+/g, '%2B').
                 replace(/\"/g,'%22').
                    replace(/\'/g, '%27'). 
                       replace(/\//g,'%2F');
}
var URLEncDec = {
    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },
    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },
    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },
    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }
        return string;
    }
}

function keypress(e){
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else
		if (e)
			keycode = e.which;
		else
			return 0;
	return keycode;
}
var FlashElementInterval;
function FlashElement(elmID, flashesCount, callBack) {

	window.clearInterval(FlashElementInterval);

	var elm = getElm(elmID);
	if(elm == null) return;
	
	if(parseInt(flashesCount) == 0) {return;}	

	//decide what to do next
	if(typeof(callBack) == "undefined") {
		elm.style.backgroundColor = "black";
		elm.style.color = "white";
		FlashElementInterval = window.setInterval("FlashElement('" + elmID + "', " + parseInt(flashesCount) + ", true)", 300);
	} else {
		elm.style.backgroundColor = "";
		elm.style.color = "";		
		flashesCount = parseInt(flashesCount) - 1;
		FlashElementInterval = window.setInterval("FlashElement('" + elmID + "', " + parseInt(flashesCount) + ")", 300);		
	}
}
function goto(url) {
	if (typeof(url) == "undefined")
		document.location.reload();
	else
		if (url == "reload") 
			document.location.reload();
		else
			document.location = url;
}
function settitle(str) {
	document.title = str;
}
function setstatus(str) {
	self.status = str;
}
function eml(local, domain) {
	document.location = "mai" + "lto:" + local + "@" + domain;
}


// UNUSED //

/*
function makeLoading(sID) {
	var elm = getElm(sID);
	if(elm == null) return;
	doneLoading(sID);

	var myImage = new Image;
	myImage.src = "images/spinner-anim.gif";
	
	elm.innerHTML = "<br><br>";
	elm.className += " bgLoading ";
}

function doneLoading(sID) {
	var elm = getElm(sID);
	if(elm == null) return;
	var elmClass = String(elm.className);
	var re = /bgLoading/gi;
	elmClass = elmClass.replace(re, "");
	elm.className = elmClass;
	return;
}
*/
