var NewBank = 1000000;
var NewRDHas = 1;
var NewMarkHas = 1;
var BaseMarkup = 4;
var AvgWage = 50;
var BaseSalaryMutex = 1.5;
var SignOnBonus = 1000;
var SignOnPenalty = 10000;

$(document).ready(function(){
	$("#pgadv_buttonStart").click(function(){
			$.ajax({
			  url: 'adventure_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=pgadv_users&pg_value=money',
			  success: function (result) {
			    money = result;
			  }
			});
			$.ajax({
			  url: 'adventure_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=pgadv_users&pg_value=people',
			  success: function (result) {
			    people = result;
			  }
			});
			$("#pgadv_people").html(people);
			$("#pgadv_money").html(money);
			$("#pgadv_buttonStart").hide();
			$("#pgadv_exploreButton").show();
			$("#pgadv_claimButton").hide();
	});
});

$(document).ready(function(){
	$("#pgadv_exploreButton").click(function(){
			$.ajax({
			  url: 'adventure_getbase.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=pgadv_bases&pg_value=base',
			  success: function (result) {
			    base = result;
			  }
			});
			$("#pgadv_exploreButton").hide();
			$("#pgadv_claimButton").show();
			$("#pgadv_location").html(base);
	});
});

$(document).ready(function(){
	$("#pgadv_claimButton").click(function(){
		$("#pgadv_exploreButton").show();
		$("#pgadv_claimButton").hide();
	});
});

$(document).ready(function(){
	$("#dotbom_NewGameButton").click(function(){
		$.ajax({
			url: 'dotbom_newgame.php',
			async: false,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_GameInfo").html(result);
			}
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markup',
		  success: function (result) {
			markup = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_loadmarket.php',
		  async: false,
		  data: 'markup='+Number(markup),	
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Market").html(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_loadproduction.php',
		  async: false,
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Production").html(result);
		  }
		});
		$("#dotbom_Days").html("0");
		$("#dotbom_Money").html(NewBank);
		$("#dotbom_RDHas").html(NewRDHas);
		$("#dotbom_Markhas").html(NewMarkHas);		
		$("#dotbom_GeneralInfo").html("");
		$("#dotbom_PayrollInfo").html("");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		$("#dotbom_CurrentSalary").html(AvgWage);
		$("#dotbom_GameButton").hide();
		$("#dotbom_NewGameButton").show();
		$("#dotbom_CallItADayButton").show();
		$("#dotbom_CrackWhipButton").show();
		$("#dotbom_CallItADayButton").removeAttr("disabled");
		$("#dotbom_CrackWhipButton").removeAttr("disabled");
		$("#dotbom_RDHireButton").removeAttr("disabled");
		$("#dotbom_RDFireButton").removeAttr("disabled");
		$("#dotbom_RDXferButton").removeAttr("disabled");
		$("#dotbom_MarkHireButton").removeAttr("disabled");
		$("#dotbom_MarkFireButton").removeAttr("disabled");
		$("#dotbom_MarkXferButton").removeAttr("disabled");
		$("#dotbom_AdjustWages").removeAttr("disabled");
		$("#dotbom_AdjustMarkup").removeAttr("disabled");
		$("#dotbom_GameInfo").html("<p>Starting a new game...</p>");
	});
});

$(document).ready(function(){
	$("#dotbom_CallItADayButton").click(function(){
		var bank = [];
		var EmpTotal = [];
		var RDCount = [];
		var MarkCount = [];
		$("#dotbom_GameInfo").html("");
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=bank',
		  success: function (result) {
		    bank = result;
		  }
		});
		IsGameOver(bank);
		if (bank>0) {
		$("#dotbom_GeneralInfo").html("<p>Calling it a day.  One day ends, and a new day begins.</p>");
		$("#dotbom_CrackWhipButton").removeAttr("disabled");
		$.ajax({
			url: 'dotbom_advanceday.php',
			async: false,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_Days").html(result);
			}
		});
		$.ajax({
			url: 'dotbom_payemployees.php',
			async: false,
			data: 'salarymutex=1',
			dataType: 'html',
			success: function (result) {
				$("#dotbom_PayrollInfo").html(result);
			}
		});
		SalaryQuit();
		$.ajax({
			url: 'dotbom_sellproducts.php',
			async: false,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_SalesInfo").html(result);
			}
		});
		$.ajax({
			url: 'dotbom_advanceproducts.php',
			async: false,
			data: 'advdays=1',
			dataType: 'html',
			success: function (result) {
				$("#dotbom_ProductInfo").html(result);
			}
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
			$("#dotbom_RDHas").text(result);
			RDCount = Number(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
			$("#dotbom_Markhas").text(result);
			MarkCount = Number(result);
		  }
		});
		var randomizer=Math.floor(Math.random()*101);
		EmpTotal=RDCount+MarkCount;
		if (randomizer <= EmpTotal ) {
			$.ajax({
				url: 'dotbom_randomevent.php',
				async: false,
				dataType: 'html',
				success: function (result) {
					$("#dotbom_CompanyInfo").html(result);
				}
			});
		} else {
			$("#dotbom_CompanyInfo").html("");
		}
		$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=bank',
			  success: function (result) {
	  			$("#dotbom_Money").text(result);
			  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markup',
		  success: function (result) {
			markup = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_loadmarket.php',
		  async: false,
		  data: 'markup='+Number(markup),	
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Market").html(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_loadproduction.php',
		  async: false,
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Production").html(result);
		  }
		});
		}else{
			$("#dotbom_GeneralInfo").html("<p>The company is out of money!</p>");
			$("#dotbom_GameButton").hide();
			$("#dotbom_NewGameButton").show();
		}
	});
});

$(document).ready(function(){
	$("#dotbom_CrackWhipButton").click(function(){
		var bank = [];
		$("#dotbom_GameInfo").html("");
		$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=bank',
			  success: function (result) {
	  			$("#dotbom_Money").text(result);
			  }
		});
		IsGameOver(bank);
		if (bank>0) {
		$("#dotbom_GeneralInfo").html("<p>The day is not over yet...  Is this time well spent?</p>");
		$("#dotbom_CrackWhipButton").attr("disabled","disabled");
		$.ajax({
			url: 'dotbom_payemployees.php',
			async: false,
			data: 'salarymutex='+BaseSalaryMutex,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_PayrollInfo").html(result);
			}
		});
		SalaryQuit();
		$.ajax({
			url: 'dotbom_sellproducts.php',
			async: false,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_SalesInfo").html(result);
			}
		});
		$.ajax({
			url: 'dotbom_advanceproducts.php',
			async: false,
			data: 'advdays=0',
			dataType: 'html',
			success: function (result) {
				$("#dotbom_ProductInfo").html(result);
			}
		});
		$.ajax({
			url: 'dotbom_randomevent.php',
			async: false,
			dataType: 'html',
			success: function (result) {
				$("#dotbom_CompanyInfo").html(result);
			}
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
			$("#dotbom_RDHas").text(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
			$("#dotbom_Markhas").text(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markup',
		  success: function (result) {
			markup = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_loadmarket.php',
		  async: false,
		  data: 'markup='+Number(markup),	
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Market").html(result);
		  }
		});
		$.ajax({
		  url: 'dotbom_loadproduction.php',
		  async: false,
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Production").html(result);
		  }
		});
		}else{
			$("#dotbom_GeneralInfo").html("<p>The company is out of money!</p>");
			$("#dotbom_GameButton").hide();
			$("#dotbom_NewGameButton").show();
		}
	});
});

$(document).ready(function(){
	$("#dotbom_RDHireButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Hiring R&amp;D employees...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var bank = 0;
		var rd = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=bank',
		  success: function (result) {
		    bank = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
		    rd = result;
		  }
		});
		var rdchange = $("#dotbom_RDEmpChange").val();
		if ((isNaN(rdchange)) || (rdchange <=0)){
			rdchange = 1;
			var Bonus = SignOnPenalty;
		}
		else {
			var Bonus = rdchange * SignOnBonus;
		}
		var rdnew = Number(rd) + Number(rdchange);
		if (bank > Bonus) {
			bank = bank - Bonus;
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=bank&pg_value='+bank,
			});	
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
			});	
			$("#dotbom_PayrollInfo").html("<p>Hiring " + rdchange + " engineer(s) at $" + Bonus + ".</p>");
			$("#dotbom_RDHas").html(rdnew);
		}
		else {
			$("#dotbom_PayrollInfo").html("<p>You do not have enough money to hire new employees.</p>");
		}
		$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=bank',
			  success: function (result) {
	  			$("#dotbom_Money").text(result);
			  }
		});
	});
});

$(document).ready(function(){
	$("#dotbom_RDFireButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Firing R&amp;D employees...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var rd = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
		    rd = result;
		  }
		});
		var rdchange = $("#dotbom_RDEmpChange").val();
		if ((isNaN(rdchange)) || (Number(rdchange) <=0)){
			rdchange = 1;
		}
		rdchange = Number(rdchange);
		if (rdchange <= rd){
			var rdnew = Number(rd) - Number(rdchange);
		}
		else {
			var rdnew = 0;
			var rdchange = 0;
			$("#dotbom_Disgruntled").html("<p>Not enough engineers to fire!</p>");
		}
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
		});	
		$("#dotbom_PayrollInfo").html("<p>Firing " + rdchange + " engineer(s)!</p>");
		$("#dotbom_RDHas").html(rdnew);
	});
});

$(document).ready(function(){
	$("#dotbom_RDXferButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Transferring employees from R&amp;D to Marketing...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var rd = 0;
		var mark = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
		    rd = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
		    mark = result;
		  }
		});
		var rdchange = $("#dotbom_RDEmpChange").val();
		if ((isNaN(rdchange)) || (Number(rdchange) <=0)){
			rdchange = 1;
		}
		rdchange = Number(rdchange);
		if (rdchange <= rd){
			var rdnew = Number(rd) - Number(rdchange);
			var marknew = Number(mark) + Number(rdchange);
		}
		else {
			var rdnew = Number(rd);
			var marknew = Number(mark);
			$("#dotbom_Disgruntled").html("<p>The board of directors decided everyone is fine where they are.</p>");
		}
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
		});	
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
		});	
		$("#dotbom_PayrollInfo").html("<p>" + rdchange + " engineer(s) transferred to marketing.</p>");
		$("#dotbom_RDHas").html(rdnew);
		$("#dotbom_Markhas").html(marknew);
	});
});

$(document).ready(function(){
	$("#dotbom_MarkHireButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Hiring Marketing employees...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var bank = 0;
		var rd = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=bank',
		  success: function (result) {
		    bank = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
		    mark = result;
		  }
		});
		var markchange = $("#dotbom_MarkEmpChange").val();
		if ((isNaN(markchange)) || (markchange <=0)){
			markchange = 1;
			var Bonus = SignOnPenalty;
		}
		else {
			var Bonus = markchange * SignOnBonus;
		}
		var marknew = Number(mark) + Number(markchange);
		if (bank > Bonus) {
			bank = bank - Bonus;
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=bank&pg_value='+bank,
			});	
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
			});	
			$("#dotbom_PayrollInfo").html("<p>Hiring " + markchange + " marketeer(s) at $" + Bonus + ".</p>");
			$("#dotbom_Markhas").html(marknew);
		}
		else {
			$("#dotbom_PayrollInfo").html("<p>You do not have enough money to hire new employees.</p>");
		}
		$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=bank',
			  success: function (result) {
	  			$("#dotbom_Money").text(result);
			  }
		});
	});
});

$(document).ready(function(){
	$("#dotbom_MarkFireButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Firing Marketing employees...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var mark = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
		    mark = result;
		  }
		});
		var markchange = $("#dotbom_MarkEmpChange").val();
		if ((isNaN(markchange)) || (Number(markchange) <=0)){
			markchange = 1;
		}
		markchange = Number(markchange);
		if (markchange <= mark){
			var marknew = Number(mark) - Number(markchange);
		}
		else {
			var marknew = 0;
			var markchange = 0;
			$("#dotbom_Disgruntled").html("<p>Not enough marketeers to fire!</p>");
		}
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
		});	
		$("#dotbom_PayrollInfo").html("<p>Firing " + markchange + " marketeer(s)!</p>");
		$("#dotbom_Markhas").html(marknew);
	});
});

$(document).ready(function(){
	$("#dotbom_MarkXferButton").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Transferring employees from Marketing to R&amp;D...</p>");
		$("#dotbom_Disgruntled").html("");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var rd = 0;
		var mark = 0;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=rdhas',
		  success: function (result) {
		    rd = result;
		  }
		});
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markhas',
		  success: function (result) {
		    mark = result;
		  }
		});
		var rdchange = $("#dotbom_MarkEmpChange").val();
		if ((isNaN(rdchange)) || (Number(rdchange) <=0)){
			rdchange = 1;
		}
		rdchange = Number(rdchange);
		if (rdchange <= rd){
			var rdnew = Number(rd) + Number(rdchange);
			var marknew = Number(mark) - Number(rdchange);
		}
		else {
			var rdnew = 0;
			var rdchange = 0;
			$("#dotbom_Disgruntled").html("<p>The board of directors decided everyone is fine where they are.</p>");
		}
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
		});	
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
		});	
		$("#dotbom_PayrollInfo").html("<p>" + rdchange + " marketeer(s) transferred to engineering.</p>");
		$("#dotbom_RDHas").html(rdnew);
		$("#dotbom_Markhas").html(marknew);
	});
});

$(document).ready(function(){
	$("#dotbom_AdjustWages").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Adjusting employee average hourly pay...</p>");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var quitmsg = "";
		var wagechange = $("#dotbom_NewSalary").val();
		var currentwage = $("#dotbom_CurrentSalary").val();
		if ((isNaN(wagechange)) || (wagechange <=0)){
			var wagenew = Number(currentwage);
			$("#dotbom_PayrollInfo").html("<p>You can't <i>not</i> pay the employees.  There must be some kind of a clerical error.</p>");
		} else {
			var wagenew = Number(wagechange);	
			$("#dotbom_PayrollInfo").html("<p>Hourly wages are set to $"+wagenew+" per hour.</p>");
			$("#dotbom_CurrentSalary").html(wagenew);
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=salary&pg_value='+wagenew,
			});	
		}
		if (wagenew < AvgWage) {
			// Employees may decide to quit.
			var quitchance = (wagenew/AvgWage)*100;
			var randomizer=Math.floor(Math.random()*101);
			if (randomizer > quitchance) {
				var rd = 0;
				var rdnew = 0;
				var rdquit = 0;
				$.ajax({
				  url: 'dotbom_getinfo.php',
				  async: false,
				  dataType: 'html',
				  data: 'pg_table=dotbom_company&pg_value=rdhas',
				  success: function (result) {
					rd = Number(result);
				  }
				});
				rdquit = (Math.floor(Math.random()*(rd+1)));
				rdnew = rd - rdquit;
				$.ajax({
				  url: 'dotbom_setinfo.php',
				  async: false,
				  dataType: 'html',
				  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
				});	
				$("#dotbom_RDHas").html(rdnew);
				if (rdquit > 0) {
					quitmsg = quitmsg + "<p>The engineers are disgruntled with the salary change.  " + rdquit + " engineers decide to quit.</p>";
				}
			}
			var randomizer=Math.floor(Math.random()*101);
			if (randomizer > quitchance) {
				var mark = 0;
				var marknew = 0;
				var markquit = 0;
				$.ajax({
				  url: 'dotbom_getinfo.php',
				  async: false,
				  dataType: 'html',
				  data: 'pg_table=dotbom_company&pg_value=markhas',
				  success: function (result) {
					mark = Number(result);
				  }
				});
				markquit = (Math.floor(Math.random()*(mark+1)));
				marknew = mark - markquit;
				$.ajax({
				  url: 'dotbom_setinfo.php',
				  async: false,
				  dataType: 'html',
				  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
				});	
				$("#dotbom_Markhas").html(marknew);
				if (markquit > 0) {
					quitmsg = quitmsg + "<p>The marketeers are disgruntled with the salary change.  " + markquit + " marketeers decide to quit.</p>";
				}	
			}
			$("#dotbom_Disgruntled").html(quitmsg);
		}
	});
});
$(document).ready(function(){
	$("#dotbom_AdjustMarkup").click(function(){
		$("#dotbom_GeneralInfo").html("<p>Adjusting product markup...</p>");
		$("#dotbom_SalesInfo").html("");
		$("#dotbom_ProductInfo").html("");
		$("#dotbom_CompanyInfo").html("");
		var markup = BaseMarkup;
		$.ajax({
		  url: 'dotbom_getinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_value=markup',
		  success: function (result) {
		    markup = result;
		  }
		});
		var markupchange = $("#dotbom_MarkupChange").val();
		if ((isNaN(markupchange)) || (markupchange <0)){
			markupchange = BaseMarkup;
		}
		var markupnew = Number(markupchange);
		$.ajax({
		  url: 'dotbom_setinfo.php',
		  async: false,
		  dataType: 'html',
		  data: 'pg_table=dotbom_company&pg_entry=markup&pg_value='+markupnew,
		});	
		$.ajax({
		  url: 'dotbom_loadmarket.php',
		  async: false,
		  data: 'markup='+Number(markupnew),	
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_Market").html(result);
		  }
		});
		$("#dotbom_Markup").html(markupnew);
		$("#dotbom_PayrollInfo").html("<p>New product markup is set to x"+markupnew+".</p>");
	});
});


function IsGameOver(bank)
{
	if (bank <= 0) {
		$("#dotbom_CallItADayButton").attr("disabled","disabled");
		$("#dotbom_CrackWhipButton").attr("disabled","disabled");
		$("#dotbom_RDHireButton").attr("disabled","disabled");
		$("#dotbom_RDFireButton").attr("disabled","disabled");
		$("#dotbom_RDXferButton").attr("disabled","disabled");
		$("#dotbom_MarkHireButton").attr("disabled","disabled");
		$("#dotbom_MarkFireButton").attr("disabled","disabled");
		$("#dotbom_MarkXferButton").attr("disabled","disabled");
		$("#dotbom_AdjustWages").attr("disabled","disabled");
		$("#dotbom_AdjustMarkup").attr("disabled","disabled");
		$.ajax({
		  url: 'dotbom_gameover.php',
		  async: false,
		  dataType: 'html',
		  success: function (result) {
			$("#dotbom_GameInfo").html(result);
		  }
		});
	}
}

function SalaryQuit()
{
	$.ajax({
	  url: 'dotbom_getinfo.php',
	  async: false,
	  dataType: 'html',
	  data: 'pg_table=dotbom_company&pg_value=salary',
	  success: function (result) {
		currentwages = Number(result);
	  }
	});
	if (currentwages < AvgWage) {
		// Employees may decide to quit.
		var quitmsg = "";
		var quitchance = (wagenew/AvgWage)*100;
		var randomizer=Math.floor(Math.random()*101);
		if (randomizer > quitchance) {
			var rd = 0;
			var rdnew = 0;
			var rdquit = 0;
			$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=rdhas',
			  success: function (result) {
				rd = Number(result);
			  }
			});
			rdquit = (Math.floor(Math.random()*(rd+1)));
			rdnew = rd - rdquit;
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=rdhas&pg_value='+rdnew,
			});	
			$("#dotbom_RDHas").html(rdnew);
			if (rdquit > 0) {
				quitmsg = quitmsg + "<p>The engineers are disgruntled with being paid a below average salary.  " + rdquit + " engineers decide to quit.</p>";
			}
		}
		var randomizer=Math.floor(Math.random()*101);
		if (randomizer > quitchance) {
			var mark = 0;
			var marknew = 0;
			var markquit = 0;
			$.ajax({
			  url: 'dotbom_getinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_value=markhas',
			  success: function (result) {
				mark = Number(result);
			  }
			});
			markquit = (Math.floor(Math.random()*(mark+1)));
			marknew = mark - markquit;
			$.ajax({
			  url: 'dotbom_setinfo.php',
			  async: false,
			  dataType: 'html',
			  data: 'pg_table=dotbom_company&pg_entry=markhas&pg_value='+marknew,
			});	
			$("#dotbom_Markhas").html(marknew);
			if (markquit > 0) {
				quitmsg = quitmsg + "<p>The marketeers are disgruntled with being paid a below average salary.  " + markquit + " marketeers decide to quit.</p>";
			}	
		}
		$("#dotbom_Disgruntled").html(quitmsg);
	}
}
