// preload nav images
var link1 = new Image();
link1.src = "../images/readitHover.png";
var link2 = new Image();
link2.src = "../images/watchitHover.png";
var link3 = new Image();
link3.src = "../images/liveitHover.png";
var link4 = new Image();
link4.src = "../images/discussitHover.png";

function sidebarLinks() {
	jQuery.each($("#sidebar li a"), function() {
		if (this.className != "current" && this.className != "available" && this.className != "constant") {
			this.style.cursor = "text";
			this.onclick = function() {
				return false;
			}
		}
	});
}

function chart() {
	/*$("#financial").change(function() {
		$("#financialChart").animate({ 
			width: (this.value*25)+"px",
		}, 1500);
	});
	$("#relational").change(function() {
		$("#relationalChart").animate({ 
			width: (this.value*25)+"px",
		}, 1500);
	});
	$("#mental").change(function() {
		$("#mentalChart").animate({ 
			width: (this.value*25)+"px",
		}, 1500);
	});
	$("#physical").change(function() {
		$("#physicalChart").animate({ 
			width: (this.value*25)+"px",
		}, 1500);
	});
	$("#spiritual").change(function() {
		$("#spiritualChart").animate({ 
			width: (this.value*25)+"px",
		}, 1500);
	});*/
}

function netWorth() {
	$("#calcNetWorth").click(function() {
		if ($("#qone").val() == "" || $("#qtwo").val() == "" || $("#qthree").val() == "" || $("#qfour").val() == "") {
			alert("Please make sure all fields are completed!");
			return;
		}
		// money format regex
		/*var pattern = /(((\d{1,3},)+\d{3})|\d+)\.\d{2}/;
		if (!pattern.test($("#qone").val()) || !pattern.test($("#qtwo").val()) || !pattern.test($("#qthree").val()) || !pattern.test($("#qfour").val())) {
			alert("Please make sure all fields are in the right format!");
			return;
		}*/
		var tai = parseInt($("#qone").val().replace(/,/, ""));
		var dpw = parseInt($("#qtwo").val().replace(/,/, ""));
		var hpd = parseInt($("#qthree").val().replace(/,/, ""));
		var doo = parseInt($("#qfour").val().replace(/,/, ""));
		
		var total = parseInt(tai / ((hpd * dpw) * 52 - (doo*hpd)));
		
		$("#total").text("Total: $"+total+" Per Hour");
		$("#totalHidden").attr("value", total);
	});
	$("#netWorthReset").click(function() {
		$("#total").text("Total: $0 Per Hour");
	});
}

$(function() {
	//sidebarLinks();
	//chart();
	netWorth();
});
