// JavaScript Document
var products = new Array("resumate", "users", "import", "manager");
var prices = new Array(789, 189, 189, 189);
var total = 0;

function setTotal() {
	document.getElementById("SelectedPrice").innerHTML ="$"+ total;
	return true;
}

function addProduct(i) {
	document.getElementById(products[i]+i).style.color = "black";
	total += prices[i];
	return setTotal();
}

function loadProduct(i) {
	document.getElementById(products[i]).checked = true;
	return addProduct(i);
}

function removeProduct(i) {
	document.getElementById(products[i]+i).style.color = "gray";
	total -= prices[i];
	return setTotal();
}

function updateSelection(i) {
	if(document.getElementById(products[i]).checked == true)
		return addProduct(i);

	return removeProduct(i);
}

function abortProcessing() {
	return alert("Please choose a product.");
}

function nothingIsChecked() {
	return !document.getElementById(products[0]).checked &&
	       !document.getElementById(products[1]).checked &&
			 !document.getElementById(products[2]).checked &&
			 !document.getElementById(products[3]).checked;
}

//      0         1         2         3
// "resumate", "users", "import", "manager"
function getArg() {
	var e1 = document.getElementById(products[0]).checked;
	var e2 = document.getElementById(products[1]).checked;
	var e3 = document.getElementById(products[2]).checked;
	var e4 = document.getElementById(products[3]).checked;

	if( e1 && !e2 && !e3 && !e4) {
		total = 0;
		addProduct(0);
		return 0;
	} 

	if( e1 &&  e2 && !e3 && !e4) {
		total = 0;
		addProduct(0);
		addProduct(1);
		return 1;
	}

	if( e1 && !e2 &&  e3 && !e4) {
		total = 0;
		addProduct(0);
		addProduct(2);
		return 2;
	}

	if( e1 && !e2 && !e3 &&  e4) {
		total = 0;
		addProduct(0);
		addProduct(3);
		return 3;
	}
	
	if( e1 &&  e2 &&	e3 &&	!e4) {
		total = 0;
		addProduct(0);
		addProduct(1);
		addProduct(2);
		return 4;
 	}
 	
	if( e1 &&  e2 && !e3 &&  e4) {
		total = 0;
		addProduct(0);
		addProduct(1);
		addProduct(3);
		return 5;
 	}
 	
	if( e1 && !e2 &&  e3 &&  e4) {
		total = 0;
		addProduct(0);
		addProduct(2);
		addProduct(3);
		return 6;
 	}
 	
	if( e1 &&  e2 &&	e3 &&	 e4) {
		total = 0;
		addProduct(0);
		addProduct(1);
		addProduct(2);
		addProduct(3);
		return 7;
 	}
 	
	if(!e1 &&  e2 &&  e3 && !e4) {
		total = 0;
		addProduct(1);
		addProduct(2);
		addProduct(3);
		return 8;
 	}
 	
	if(!e1 &&  e2 && !e3 &&  e4) {
		total = 0;
		addProduct(1);
		addProduct(3);
		return 9;
	}
	
	if(!e1 && !e2 &&  e3 &&  e4) {
		total = 0;
		addProduct(2);
		addProduct(3);
		return 10;
 	}
 	
	if(!e1 &&  e2 &&  e3 &&  e4) {
		total = 0;
		addProduct(1);
		addProduct(2);
		addProduct(3);
		return 11;
 	}
 	
	if(!e1 &&  e2 && !e3 && !e4) {
		total = 0;
		addProduct(1);
		return 12;
	}
	
	if(!e1 && !e2 &&  e3 && !e4) {
		total = 0;
		addProduct(2);
		return 13;
	}

	total = 0;
	addProduct(3);
	return 14;
}

function processSelection() {
	if(nothingIsChecked()) return abortProcessing();

	var retURL = "./register.htm?p=";
	var arg = getArg();
	document.location=retURL+arg;
}

var productDescriptions = new Array(
'RESUMate Pro includes all of the candidate record functions of RESUMate Lite, and then integrates these candidate records with records for (1) clients, (2) jobs, and (3) hiring managers.',
'Add an additional network user to RESUMate.',
'Import Express is needed when you have hundreds (or thousands) of resume documents sitting in folders or email attachments. Easily create RESUMate database records that can be searched, edited and tracked.',
'RESUMate Manager is a report writing and analysis tool that works hand-in-hand with the Professional version of RESUMate. It extracts data describing job orders and interviews right from your database and assembles this data into a variety of one-click management reports.');

function loadDesc() {
	for(var i = 3; i >= 0; --i)
	   document.getElementById('desc'+i).innerHTML = productDescriptions[i];
}

function callFixForIE() {
	fls = document.getElementsByTagName("object");
	for (var a = 0; a < fls.length; a++){fls[a].outerHTML = fls[a].outerHTML;}
}

function initAll() {
	callFixForIE();
	loadProduct(0);
	loadProduct(2);
	loadDesc();
}

window.onload = initAll;

