function loadCoin() {
	$("coin").style.backgroundImage = "url('http://idecisive.com/_images/coin.gif')";
}

function flipCoin(pass) {
	$("coin").style.backgroundPosition = (Math.random() < 0.5) ? "0 25px" : "-320px 25px";
	if (pass < 20) {
		pass++;
		setTimeout("flipCoin("+pass+")", 30);
	}
}

function randomNumber(pass) {
	var l = parseInt($("rmin").value);
	var h = parseInt($("rmax").value);
	if (h < l) {
		alert("Min cannot exceed Max");
		return false;
	}
	if (l < 0) {
		alert("Positive numbers only");
		return false;
	}
	if (h >= 1000000) {
		alert("Max must be less than one million");
		return false;
	}
	var f = (Math.floor(Math.LOG10E*Math.log(h) + 0.0001) - 1) * 30;
	f = 190 - Math.max(f, 0);
	$("number").style.fontSize = f + "px";
	var n = Math.floor(Math.random()*((h-l)+1)) + l;
	$("number").innerHTML = n;
	if (pass < 10) {
		pass++;
		setTimeout("randomNumber("+pass+")", 20);
	}
}

function showThis(t) {
	var y = 0;
	if (t.offsetParent) {
		y = t.offsetTop;
		while (t = t.offsetParent) {
			y += t.offsetTop;
		}
	}
	window.scrollTo(0, y - 10);
}

function showOptions() {
	var m = parseInt($("options").value);
	for (i=3; i<=10; i++) {
		$("row_for_option"+i).style.display = (i<=m) ? "" : "none";
	}
}

function chooseOption() {
	var m = parseInt($("options").value);
	var n = Math.floor(Math.random()*m) + 1;
	var option = ($("option"+n).value) ? $("option"+n).value : "Option "+n;
	alert("Choose " + option);
}

function donateChoice(pass) {
	var n = Math.floor(Math.random()*2);
	var option = new Array(2);
	option[0] = '<br /><a href="/donate/">Sure, click here!</a>';
	option[1] = '<br />Maybe next time.';
	$("donate").innerHTML = option[n];
	if (pass < 10) {
		pass++;
		setTimeout("donateChoice("+pass+")", 20);
	}
}

function contact() {
	var c = "com";
	var b = "iDecisive";
	var a = "web08";
	window.location=("mai" + "lto:" + a + "@" + b + "." + c);
}

function $(id) {
	return document.getElementById(id);
}
