function post_form(form_id)
{
	document.getElementById(form_id).submit();
}

function setIdProperty( id, property, value )
{
	var styleObject = document.getElementById( id );
	if (styleObject != null)
	{
		styleObject = styleObject.style;
		styleObject[ property ] = value;
	}
}

function getIdProperty(id, property)
{
	var styleObject = document.getElementById( id );
	if (styleObject != null)
	{
		return styleObject.style[property];
	}
}

function swap(id)
{
	if (getIdProperty(id+"_1", "display") == 'none')
	{
		setIdProperty(id+"_2", "display", "none");
		setIdProperty(id+"_1", "display", "inline");
	}
	else
	{
		setIdProperty(id+"_1", "display", "none");
		setIdProperty(id+"_2", "display", "inline");
	}
}

function hide(id)
{
	setIdProperty(id, "display", "none");
}

function show(id)
{
	setIdProperty(id, "display", "inline");
}


function popUp(URL, width, height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+"');");
}

function get_address(input) {
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}
	} while (i < input.length);

	return output;
}

function makeTime(seconds)
{
	//alert("Seconds: " + seconds);
	vote_hours = Math.floor(seconds / 3600);
	seconds = seconds % 3600;
	
	//alert("Hours: "+vote_hours+", remaining seconds: "+seconds);
	
	vote_minutes = padTime(Math.floor(seconds / 60));
	seconds = seconds % 60;
	
	vote_seconds = padTime(seconds);

	return (vote_hours == 0 ? "" : vote_hours + ":") + vote_minutes + ":" + vote_seconds;
}

function padTime(i)
{
	if (i < 10)
		i = "0"+i;
		
	return i;
}
