function enter_uott_contest(){
	window.open('/website/_template.html?quoter=contests&worksite=UOTT&page_name=uott_contest.html');
}

function calculateAmount(website_id) {
	for (var i=1; i<=9; i++) {
		if (eval("document.calculator.q"+i+".value == ''")) {
			eval("document.calculator.q"+i+".value = 0");
		}
	}

	var q1 = parseFloat(document.calculator.q1.value.replace(/,/g,''));
	var q2 = parseFloat(document.calculator.q2.value.replace(/,/g,''));
	var q3 = parseFloat(document.calculator.q3.value.replace(/,/g,''));
	var q4 = parseFloat(document.calculator.q4.value.replace(/,/g,''));
	var q5 = parseFloat(document.calculator.q5.value.replace(/,/g,''));
	var q6 = parseFloat(document.calculator.q6.value.replace(/,/g,''));
	var q7 = parseFloat(document.calculator.q7.value.replace(/,/g,''));
	var q8 = parseFloat(document.calculator.q8.value.replace(/,/g,''));
	var q9 = parseFloat(document.calculator.q9.value.replace(/,/g,''));
	var val = (q6 + q7 + q8 + q9) - (q1 + q2 + q3 + q4 + q5);
	var display_val = Math.abs(val);

	var label = document.getElementById("result");
	
	if (website_id != "french") {
		label.innerHTML = " $" + addCommas(display_val.toFixed(2)) + "";
	} else {
		label.innerHTML = " " + addCommas(display_val.toFixed(2)) + " $";
		label.innerHTML = label.innerHTML.replace(/\,/g," ");
	}
	if(q1 > 0){
		document.getElementById("results").style.display="";
		if (val > 0) {
			document.getElementById("positive").style.display = "";
			document.getElementById("negative").style.display = "none";
		} else {
			document.getElementById("positive").style.display = "none";
			document.getElementById("negative").style.display = "";
		}
        	document.getElementById("calculator_error").style.display= "none";
//		window.location = String(window.location).replace(/\#.*$/, "") + "#term-life-insurance-calculator-results";
	//	window.location = String(window.location).replace(/\#.*$/, "") + "-Result";
		var myresult= document.getElementById("focusresult");
		myresult.focus();
	}else{
		document.getElementById("results").style.display="none";
		document.getElementById("positive").style.display = "none";
		document.getElementById("negative").style.display = "none";
        	document.getElementById("calculator_error").style.display= "";
	}
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function redirect(whereTo) {
	if (whereTo) {
		window.location = whereTo;
	} else {
		window.location = "/apply_now";
//		window.location = (document.language_swap.website_id.value == 'french' ? "/adherez_aujourdhui" : "/apply_now");
	}
}

function addCommasToThisField(field_id){
	obj = field_id;
	obj.value = addCommas_2(obj.value);
}



function addCommas_2(nStr)
{
	nStr = nStr.replace(/[^0-9]/g,'');
	var j =0;
	var i;
	nStr = nStr.replace(/^([0]*)(\d*)/,'$2');
	var total =  "";
	for(i = nStr.length; i > 0; i--){
		if(j == 3){
			total = nStr.charAt(i-1)+',' + total;
			j=1;
		}else{
			total = nStr.charAt(i-1)+total;
			j++;
		}
	}
	return total;
}

