function calculateTotals(selectbox,totalplayersinslot) {
/*
THIS FUNCTION UPDATES TOTALS OF SELECTED TEETIMES FOR BOOKING.
ARRAYS FOR EACH SELECTED TEETIME ARE INITIALISED VIA A SCRIPT
WITHIN THE PAGE CODE ITSELF, THESE ARE CREATED LIKE SO:
"totalArr0" ETC, ETC. THESE REFERENCES ARE USED IN THE SCRIPT
BELOW TO TARGET THE CORRECT ROW AND CALCULATE TOTAL COST.
*/
	var selectRow = selectbox.name; // Get name of dropdown	
	var selectRowAlpha = selectRow.replace(/[^a-z_]/g,''); // Strip row number from name of dropdown
	var selectRowNum = selectRow.replace(/[^0-9]/g,''); // Get row number from name of dropdown
	var selectRowNumRef = "totalArr"+selectRowNum; // Set reference to active row array
	var selectValue = parseFloat(selectbox.options[selectbox.selectedIndex].value); // Get value of selected dropdown
			
	if (selectRowAlpha == "player_one") { // Set row array values for each player
		eval("totalArr"+selectRowNum+"[0] = "+selectValue);
	} else if (selectRowAlpha == "player_two") {
		eval("totalArr"+selectRowNum+"[1] = "+selectValue);
	} else if (selectRowAlpha == "player_three") {
		eval("totalArr"+selectRowNum+"[2] = "+selectValue);
	} else if (selectRowAlpha == "player_four") {
		eval("totalArr"+selectRowNum+"[3] = "+selectValue);
	}	
	
	var target_total_update = eval("totalArr"+selectRowNum+"[0]")+eval("totalArr"+selectRowNum+"[1]")+eval("totalArr"+selectRowNum+"[2]")+eval("totalArr"+selectRowNum+"[3]"); // Calculate total cost by adding each player value
	
	var target_total_updateString = target_total_update.toString(); // Convert total to String for following comparison code
	
	var totalSplit = target_total_updateString.split("."); // Split total using decimal point to set currency formatting
	
	if (totalSplit[1]) { // If decimal point exists we get an array with 2 elements
		if (totalSplit[1].length == 1) { // If Array element 2 is 1 char long then add an extra zero
			target_total_update = totalSplit[0]+"."+totalSplit[1]+"0";
		}
	} else { // If no decimal point exists then add decimal point and 2 extra zeros
		target_total_update = target_total_update+".00";
	}
	
	var target_total_source = document.getElementById("total"+selectRowNum); // Set var of target span ID to display total
	target_total_source.innerHTML = target_total_update; // Update the row total with a sledgehammer ;)
	
	finalTotal = 0; // Set var for Final Total amount
	for(var z = 0; z < num_of_arrays; z++) { // Loop through row arrays and get each total and add to Final Total
		eval("var rowTotal"+z+" = document.getElementById('total"+z+"').innerHTML");
		var rowTotalRef = parseFloat(eval("rowTotal"+z));
		finalTotal = finalTotal+rowTotalRef;
	}
	
	var finalTotalString = finalTotal.toString(); // Convert Final Total to String for following comparison code
	var finalTotalSplit = finalTotalString.split("."); // Split Final Total using decimal point to set currency formatting
	
	if (finalTotalSplit[1]) { // If decimal point exists we get an array with 2 elements
		if (finalTotalSplit[1].length == 1) { // If Array element 2 is 1 char long then add an extra zero
			finalTotal = finalTotalSplit[0]+"."+finalTotalSplit[1]+"0";
		}
	} else { // If no decimal point exists then add decimal point and 2 extra zeros
		finalTotal = finalTotal+".00";
	}
	
	var target_final_total_source = document.getElementById("finaltotal"); // Set var of target span ID to display Final overall total
	target_final_total_source.innerHTML = finalTotal; // Finally, update the Final total with a sledgehammer ;)
}


function confirmSubmit(msg)
{
var agree=confirm(msg);
if (agree)
        return true;
else
        return false;
}

function check(method)
{
    var checkboxes = document.getElementsByTagName("select");
	
    for(i=0; i < checkboxes.length; i++)
    {
		var selectvalue = checkboxes[i].options[checkboxes[i].selectedIndex].value;
		
		if (selectvalue == 'yes' || selectvalue == 'no') {
			if (method == 1) {
				var toggle_text = '<a href="#" onclick="check(0);">Select None</a>';
				checkboxes[i].selectedIndex = 1;
			} else {
				var toggle_text = '<a href="#" onclick="check(1);">Select All</a>';	
				checkboxes[i].selectedIndex = 0;
			}
			
		}

    }

	var toggle_link = document.getElementById("toggle_link");
	toggle_link.innerHTML = toggle_text;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function go(url) {
    location.href = url;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function hidenav(){
	var navpanel=document.getElementById('navpanel');
    navpanel.style.display="none";
	var navtitle=document.getElementById('navtitle');
    navtitle.innerHTML="Show Categories:";
}
function expandnav(){
	var navpanel=document.getElementById('navpanel').style;
	var navtitle=document.getElementById('navtitle');
	alert (navpanel);
	if (navpanel.display=="none") {
        navpanel.display="";
    	navtitle.innerHTML="Hide Categories:";
    } else {
        navpanel.display="none";
    	navtitle.innerHTML="Show Categories:";
    }
}



function expandit(objname){
    var panel='';
    //curobj = objname;
    //imgobj = objname + 'img';
    panel = document.getElementById(objname).style;
	if (panel.display=="none") {
        panel.display="";
    } else {
        panel.display="none"
    }
}


function get_cookie(cookie_name)
{
  var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');

  if (results)
    return (unescape(results[1]));
  else
    return null;
}

function setTabs() {
	//document.getElementById("tabtree").style.display="block";
	var tab = null;
	var tab = document.cookie.match('tabselected' + '=(.*?)(;|$)');
	//alert(tab);
	if (tab == null) {
		openObjects();
	}
	if (tab[1] == "pages") {
		openPages();
	} else if (tab[1] == "objects") {
		openObjects();
	}
}


function expandboxLrg(targ){
	var navtarget="comment"+targ;
	var navlink="link"+targ;
	var navpanel=document.getElementById(navtarget).style;
	var navtitle=document.getElementById(navlink);
	//alert (navpanel);
	if (navpanel.height=="auto") {
        navpanel.height="0";
    	navtitle.innerHTML="View";
    } else {
        navpanel.height="auto";
    	navtitle.innerHTML="Hide";
    }
}