﻿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.aspx";
function ajx(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 + "=" + URLEncode(evalScr);
			i++;
		}
		arr[arr.length - 1] = "";
		//the last prop is evaluated on complete
	} else {
		var arg = ajx.arguments;
		for (i = 0; i < arg.length - 1; i++) {
			arr[i] = URLEncode(arg[i]);
		}
		evalScr = arg[i]; //the last prop is evaluated on complete
		arr[arr.length - 1] = "";
	}
	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"
	}
	);
	return false;
}
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 + "=" + URLEncode(evalScr);
			i++;
		}
		//the last prop is evaluated on complete
		arr[arr.length - 1] = "";
	} else {
		var arg = ajxt.arguments;
		for (i = 0; i < arg.length - 1; i++) {
			arr[i] = URLEncode(arg[i]);
		}
		evalScr = arg[i]; //the last prop is evaluated on complete
		arr[arr.length - 1] = "";
	}
	window.open(ajx_base + "?" + arr.join("&"));
	return false;
}
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 createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else
		var expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ')
			c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0)
			return c.substring(nameEQ.length, c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name, "", -1);
}

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');
}
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 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;
}
*/

