//Variables:
osrate = 11.9; //How much per tonne to offset
ospp = 0.065; //how much CO2 (tonnes) emitted per person
co2tot=0;
msg1 = "A new window will now open. Under 'Offset A Wedding', change the quantity to " + co2tot +" tonnes and add it to your basket"; //popup message #1 when linking to shop
msg2 = "A new window will now open. Under 'Offset A Wedding', change the quantity to " + co2tot +" tonnes and add it to your basket, and then calculate your air travel emissions."; //popup message #2 when linking to shop

// ###### functions ########
function init() {
	document.getElementById("os_pp").innerHTML = eval(ospp*1000);
	document.getElementById("os_rate").innerHTML = osrate.toFixed(2);
}

function doCalc(){
	var num_guests = document.getElementById("num_guests").value;
	co2tot = eval(num_guests*ospp);
	oscost = eval(co2tot*osrate);
	document.getElementById("os_tot").innerHTML=co2tot.toFixed(1);
	document.getElementById("os_cost").innerHTML=oscost.toFixed(2);
	msg1 = "A new window will now open. Under 'Offset A Wedding', change the quantity to " + co2tot.toFixed(1) +" tonnes and add it to your basket"; //popup message #1 when linking to shop
	msg2 = "A new window will now open. Under 'Offset A Wedding', change the quantity to " + co2tot.toFixed(1) +" tonnes and add it to your basket, and then calculate your air travel emissions."; //popup message #2 when linking to shop
	return false;
}

function numsonly(ev) {
	key= window.event ? ev.keyCode : ev.which;
	keyre=/[\d]/;
	if(keyre.test(String.fromCharCode(key))==false){
		return false;
	}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function openWin(URL,msgsw,erolno) {
	if(msgsw!=""){
	alert(eval(msgsw));
	}
	newWin = window.open(URL,"newWin","height=768,width=1024,left=0,top=0,menubar=1,location=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,"); 
	//newWin.document.show(erolno,0,0);
}
