// JavaScript Document

 $(function() {
	//jquery lightbox selectors
	$(".lightbox").lightBox(); // Select all links with lightbox class
	$('#screenshots a').lightBox();// Select all links in the screenshots object
	
	});
	
	//resize the flash menu on rollover/out for Firefox compatibility
	//Called from the flash movie ExternalInterface function
	function resizeFlashStage(newHeight){
		//alert(newHeight)
		var menu = document.getElementById('flash-menu')
		menu.height = newHeight;			
	};
	
	//For testing flash strings
	function debugFlash(param){
		//alert ( "debugFlash " + param);
	}	
	
	//ROI calculator methods
	
	function calcROI(emp, hours, pay){
		var overpayment = roundNumber(emp * hours * pay  * 0.01);
		var humanError = roundNumber(emp * hours * pay  * 0.005);
		var admin = roundNumber(emp * pay * 0.0666 );	
		
		var weekHours = roundNumber(emp * hours);
		var weekPay = roundNumber(weekHours * pay);
		var increase = roundNumber(weekHours * 0.01);
		var entry = roundNumber(emp *  0.08333);
		
				
		var weekTotal = roundNumber(overpayment + humanError + admin);
		var yearTotal = roundNumber(weekTotal * 52);
		
		overpayment = addCommas(overpayment);
		humanError = addCommas(humanError);
		admin = addCommas(admin);
		weekPay = addCommas(weekPay);
		weekTotal = addCommas(weekTotal);
		yearTotal = addCommas(yearTotal);
		
		var html = document.getElementById("roi").innerHTML;
				
		html = html.replace("$weekTotal", weekTotal);
		html = html.replace("$yearTotal", yearTotal);
		html = html.replace("$emp", emp);
		html = html.replace("$emp", emp);
		html = html.replace("$emp", emp);
		html = html.replace("$hours", weekHours);
		html = html.replace("$hours", weekHours);
		html = html.replace("$weekPay", weekPay);
		html = html.replace("$weekPay", weekPay);
		html = html.replace("$increase", increase );
		html = html.replace("$overpayment", overpayment);
		html = html.replace("$humanError", humanError);
		html = html.replace("$admin", admin);
		html = html.replace("$entry", entry);
		
		document.getElementById("roi-display").innerHTML = html;
	}

	
	function roundNumber(num) {
		var dec = 2;
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}

	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;
   }
   
   //End ROI calculator methods
   
   
   



	