function $ (element) 
{
	return document.getElementById(element);
}

function Closeup(img)
{
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}

function Controlla(img)
{
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function viewFoto(img)
{
  
  w=foto1.width+20;
  h=foto1.height+20;
  
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;

  string="width="+w+",height="+h+",top="+wint+",left="+winl;
  
  finestra=window.open(img,"",string);
}
function RadioJump(pickup)
{
	window.location.href = pickup;
}
// Printing
function Printing(id){ 
	if(window.print()){
	var d=eval(id)==null||eval(id+".closed");
	if(!d){eval(id+".print()");}}
}

myPopup = '';

function PopupReturnWindow(file_id,w,h,scl,menu,stat,tool,full,locate,resize,tbar)
{

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var PopUp = 'POPUP';
  
  settings = 'height='+h+',';
  settings += 'width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+scl+',';
  settings +='menubar='+menu+',';
  settings +='statusbar='+stat+',';
  settings +='toolbar='+tool+',';
  settings +='fullscreen='+full+',';
  settings +='titlebar='+tbar+',';
  settings +='locationbar='+locate+',';
  settings +='resizable='+resize;
  
  myPopup = window.open(file_id,PopUp,settings);
    if (!myPopup.opener)
         myPopup.opener = self; 
}
function PopupWindow(file_id,w,h,scl,menu,tool,resize,tbar)
{

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var PopUp = 'POPUP';
  
  settings = 'height='+h+',';
  settings += 'width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+scl+',';
  settings +='menubar='+menu+',';
  settings +='toolbar='+tool+',';
  settings +='titlebar='+tbar+',';
  settings +='resizable='+resize;
  
  myPopup = window.open(file_id,PopUp,settings);
    if (!myPopup.opener)
         myPopup.opener = self; 
}

function PopupEvent(file_id)
{
  var h = 400;
  var w = 400;
  var sb = 'Yes';
  var rs = 'Yes';
  var mb = 'Yes';
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  
  settings = 'height='+h+',';
  settings += 'width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+sb+',';
  settings +='menubar='+mb+',';
  settings +='resizable='+rs;
    
  finish = window.open(file_id,"",settings);
}

function confirm_delete(url)
{
	var message = 'Are you sure you want to delete this item'; 
	if(confirm(message)) location.href = url;
}

function jJumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function populate_selectmenu(current,optionid,data,values)
{	
	var dataarray = data.split(',');
	var valuearray = values.split(',');
	var element = document.getElementById(optionid);
	dataarray[current.selectedIndex] = dataarray[current.selectedIndex].split('|');
	valuearray[current.selectedIndex] = valuearray[current.selectedIndex].split('|');
	for (count = 0; count < element.options.length;count++) element.remove(count);
	element.options[0] = new Option("","",false,false);
	for (count = 0; count < dataarray[current.selectedIndex].length;count++) element.options[count+1] = new Option(dataarray[current.selectedIndex][count],valuearray[current.selectedIndex][count],false,false);
}

// function loadContent added by Mathew Carter on Friday, 4th August 2006
function loadContent(file)
{
  var head = document.getElementsByTagName('head').item(0)
  var scriptTag = document.getElementById('loadScript');
  if(scriptTag) head.removeChild(scriptTag);
  script = document.createElement('script');
  script.src = file;
	script.type = 'text/javascript';
	script.id = 'loadScript';
	head.appendChild(script)
}
function changeImage(filename)
{
	document.mainimage.src = filename;
}
function checkAll(box)
{
	var i = 0, el, f = box.form, bWhich = box.checked;
	while (el = f.elements[i++])
		if (box != el && /^remove/.test(el.name))
			el.checked = bWhich;
}
function toggledisplay(hiddenid,plusid)
{
	var element = document.getElementById(hiddenid);
	if (element.style.display == 'none') 
	{
		element.style.display = '';
		if (plusid != '') plusid.innerHTML = '-';
	}
	else 
	{
		element.style.display = 'none';
		if (plusid != '') plusid.innerHTML = '+';
	}
}

/* 
	disable a form (eg. on submit)
	sets all inputs to readonly and submits to disabled
*/
function disableForm (form)
{
	var f = document.getElementById(form);
	for (var i=0; i<f.length; i++)
	{
		if (f.elements[i].type == "input")
		{
			f.elements[i].readOnly = true;
			f.elements[i].style.backgroundColor = "#cccccc";
		}
		if (f.elements[i].type == "submit")
		{
			f.elements[i].disabled = true;
		}
	}
}
function add_smily(sender)
{
	var smile = sender.getAttribute("alt") ;
	$("txt").value += smile ;
	
}
function valid_guestbook(sender)
{
	var errors = "" ;
	if($("name").value == "") errors += " - Your name is blank\n" ;
	if($("country_id").value == "") errors += " - You must select your country\n" ;
	if($("email").value == "" 
			|| $("email").value.indexOf("@") == -1 
			|| $("email").value.indexOf(" ") > -1
			|| $("email").value.indexOf("http://") > -1) 
		errors += " - You must have a valid email address\n";
	if($("txt").value == "") errors += " - You must have a message\n" ;
	if ($("captcha").value == "") errors += " - You have to fill in the captcha\n";
	if(errors != "") 
	{
		alert("Some errors have occurred:\n" + errors) ;
		return false ;
	}
}
function valid_accommodation_enquiry(sender)
{
	var errors = "" ;
	//alert($("accommodation_name").value + $("ac_id").value);
	//return false;
	
	if($("name").value == "") errors += " - Your name is blank\n" ;
	if($("email").value == "" || $("email").value.indexOf("@") == -1 || $("email").value.indexOf(" ") > -1) errors += " - You must have a email address\n" ;
	if($("message").value == "") errors += " - You must have a message\n" ;
	if(errors != "") 
	{
		alert("Some errors have occurred:\n" + errors) ;
		return false ;
	}
}
function valid_enquiry(sender)
{
	var errors = "" ;
	if($("first_name").value == "") errors += " - Your first name is blank\n" ;
	if($("last_name").value == "") errors += " - Your last name is blank\n" ;
	if($("email").value == "" || $("email").value.indexOf("@") == -1 || $("email").value.indexOf(" ") > -1) errors += " - You must have a email address\n" ;
	if($("comments").value == "") errors += " - You must have a message\n" ;
	if(errors != "") 
	{
		alert("Some errors have occurred:\n" + errors) ;
		return false ;
	}
}

function load () {
	var text = "2 St Martins Lane, <br />Airlie Beach 4802";
	
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		
		map.addControl(new GMapTypeControl());
		//map.addControl(new GSmallZoomControl());
		map.addControl(new GLargeMapControl());
		geocoder = new GClientGeocoder();  
		// -20.274562, 148.704197
		//alert(point.lat() + ", " + point.lng());
		var point = new GLatLng(-20.274562, 148.704197);
		map.setCenter(point, 16);
		//map.setCenter(point, 12, G_SATELLITE_MAP);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(text);
		GEvent.addListener(marker, "click", function() 
		{
			marker.openInfoWindowHtml(text);
		});
	}
}


/*
	Change the captcha image to another one
	in case the current one is too hard to read
*/
function update_captcha (sender) {
	// seed it to gaurantee that the image is refreshed
	var seed = Math.floor(Math.random()*100);
	// get the path of the image
	var path = $("im").src;
	path = path.substr(0, path.indexOf("captcha.php"));
	// refresh the image to get a new captcha
	$("im").src = path + 'captcha.php?' + seed;
}


function validate (sender) {
	var errors = '';
	var checkErrors = '';
	
	switch (sender.id) {
		case 'agentmail':
			if ($('agent_name').value == '') errors += " - You need an agent name\n";
			if ($('contact_name').value == '') errors += " - You need a contact name\n";
			if ($('email').value == '' || $('email').value.indexOf('@') < 0) errors += " - Contact email is invalid\n";
			break;
		case 'brochure_frm':
			if ($('agent_name').value == '') errors += " - You need an agent name\n";
			if ($('contact_name').value == '') errors += " - You need a contact name\n";
			if ($('email').value == '' || $('email').value.indexOf('@') < 0) errors += " - Contact email is invalid\n";
			break;
		case 'loginAgentFrm':			
			if($("password").value != $("confirmPassword").value) errors += " - Password didn't match\n";
			if($("password").value.length <= 5) errors += " - Password doesn't have enough characters, Min 6\n";
			if ($('email').value == '' || $('email').value.indexOf('@') < 0) errors += " - Contact email is invalid\n";			
			if ($('consultant_name').value == '') errors += " - You need an name\n";
			if ($('address').value == '') errors += " - You need an address\n";
			if ($('suburb').value == '') errors += " - You need a Suburb\n";
			if ($('postcode').value == '') errors += " - You need a Postcode\n";
			if ($("agent_company_id").value == "other" && $("other_company").value == "")
			{
				errors += " - You need to add the New Company name\n";
			}
			else if ($("agent_company_id").value == "")
			{
				errors += " - You need to select a Company\n";
			}
			break;
		case 'agentEditFrm':
		if( $("new_password").value != "")
			{
				if($("new_password").value != $("confirm_password").value) errors += " - Password didn't match\n";
				if($("new_password").value.length <= 5) errors += " - Password doesn't have enough characters, Min 6\n";
			}
			if ($('email').value == '' || $('email').value.indexOf('@') < 0) errors += " - Contact email is invalid\n";			
			if ($('consultant_name').value == '') errors += " - You need an name\n";
			if ($('address').value == '') errors += " - You need an address\n";
			if ($('suburb').value == '') errors += " - You need a Suburb\n";
			if ($('postcode').value == '') errors += " - You need a Postcode\n";
			if ($("agent_company_id").value == "other" && $("other_company").value == "")
			{
				errors += " - You need to add the New Company name\n";
			}
			else if ($("agent_company_id").value == "")
			{
				errors += " - You need to select a Company\n";
			}
			break;		
	}
	if (errors != '') {
		alert('There are a few things wrong:\n'+errors);
		return false;
	}
	else if(errors == "" && sender.id == "loginAgentFrm")
	{
		$("ajax_msg").style.display = "";
		$("ajax_response").innerHTML = "Please wait while we check<br />if you are registered";
		
		new Ajax.Request('/inc/ajax/agent_login_ajax.php', {
			method: 'post',
			parameters: {
				action: 'checkAgent',
				email: $("email").value
			},
			onSuccess: function (r) {
				if(r.responseText == 0)
				{
					$("loginAgentFrm").submit();
					return true;
				}
				else
				{
					$("ajax_response").innerHTML = "Sorry. You are already registered. <a href=\"?Nav=agent\">Click here to Agent Login</a>";
				}
			}
		});
		return false;
	}
}
function optionCompany(sender)
{
	//alert($("agent_company_id").value);	
	if($("agent_company_id").value == "other")
	{
		$("other_company_tr").style.display = "" ;	
	}
	else
	{
		$("other_company_tr").style.display = "none" ;	
		$("other_company").value = "" ;	
	}
}
function competition(sender)
{
	var errors = '';
	//alert($("answer").value)	;
	if($('answer').value == '') errors += " - You must add an Answer\n";
	if (errors != '') {
		alert('An error occurred:\n'+errors);
		return false;
	}
	else if(errors == "")
	{
		$("ajax_msg").style.display = "";
		$("ajax_response").innerHTML = "We are currently checking your details<br /> and answer to this competition";
		
		new Ajax.Request('/inc/ajax/competition_ajax.php', {
			method: 'post',
			parameters: {
				action: 'registerAnswer',
				answer: $("answer").value,
				competition_id: $("competition_id").value
			},
			onSuccess: function (r) {
				if(r.responseText == 0)
				{
					$("ajax_response").innerHTML = "Your Answer has been sucessfully logged";
				}
				else
				{
					$("ajax_response").innerHTML = "You have already registered an Answer";
				}
			}
		});
		return false;
	}
}

function showResetPassword()
{
	var display = document.getElementById('resetPassword').style.display ;
	
	if(display == "none")
	{
		 document.getElementById('resetPassword').style.display = "";
	}
	else
	{
		 document.getElementById('resetPassword').style.display = "none";
	}
}

function resetMyPassword(sender)
{
	//Validate the email address
	var emailaddress = $("resetEmail").value;
	var errors = "";
	if(emailaddress == "") errors += " You will need to enter your email address\n";
	if (emailaddress == '' || emailaddress.indexOf('@') < 0) errors += " - Contact email is invalid\n";
	if (errors != "")
	{
		alert(errors);
		return false;
	}
	
	//Show waiting 
	$("ajaxMessage").innerHTML = "<br />Resetting your password ...";
	
	new Ajax.Request
	(	
	 	'/inc/ajax/reset_password_ajax.php', 
		{
			method: 'post',
			parameters: 
			{
				action: 'resetPassword',
				email: emailaddress
			},
			onSuccess: function (r) 
			{
				if(r.responseText == "success")
				{
					$("ajaxMessage").innerHTML = "<br />A new password has been sent.<br />Please check your email.";
					$("resetPassword").style.display = "none";
					return true;
				}
				else
				{
					$("ajaxMessage").innerHTML = "<br />Your email address was not listed";
				}
			}
		}
	)
}
//Calculates the booking and displays
function bookcalc (sender)
{
	var selectValue = sender.value;
	var id = (sender.id).replace("selectPersons_","");	//strip the selectPersons_ text from the id
	var price = ($("price_"+id)).value;					//get the value of the price from the hidden variable
	
	var sum = selectValue*price;						//select value X price	
	($("run_price_sum_"+id)).value = sum;				//set the run_price_sum text field on the right	
	
	//now count the sum of all the run_price_sum rows
	recountTotals();	
}
function recountTotals()
{
	//get all inputs with "run_price_sum_" in them
		var totalSum = parseFloat(0);
		var inputs = document.getElementsByTagName("input");
		var input_count = inputs.length;			
		for ( i = 0 ; i < input_count ; i ++)
		{
			var type = inputs[i].type;
			var name = inputs[i].name;
			var value = parseFloat(inputs[i].value);
			var checked = inputs[i].checked;
			
			//only check text fields that have run_price_sum_ in them
			if(type == "text" && name.indexOf("run_price_sum_") != -1)
			{
				totalSum += value;
			}
		}
	
	//set the total in the text field
	($("run_price_total_")).value = totalSum;
}
/*
//Replaced this craptacular function
//Check out the variable names
function bookcalc (sender)
{
//	alert ($(sender.options.id).value);
	var h1 = parseInt(sender.name);
//	alert(h1);
	var h2 = "Hd"+h1;
//var h3 = sender.value;
	var h3 = sender.value;
//	alert (h3);
	var h = parseInt($(h2).value)*h3;
	
	var h4 = "htxt"+h1;
	($(h4).value) = h;
	var h5= $("ht").value;
	var i;
	var j,k;
	($("htotal").value)=0;
	var hm;
	hm=0;
	for (i=1; i<=h5; i++)
	{
		j="htxt"+i;
		($("htotal").value)=parseInt($("htotal").value)+parseInt($(j).value);
				if ($(i).value != 0)
		{
		
		hm = parseInt(hm) + parseInt($(i).value);
		}
	}
	$("nrow").value = parseInt(hm);
	//alert (hm);
	var thm,thn;
	var hemal=2;

	for (i=2; i<20 ; i++)
	{
		thm = "tr"+i;
	
		thn = ($(thm).style.display);
	
		if (i<=hm)
		{
			if (thn == "none" )
			{
				$(thm).style.display = "";
			}
		}
		else
		{
			if (thn == "none" )
			{
			
			}
			else
			{
			$(thm).style.display = "none";
			}
		}
		thn = ($(thm).style.display);
//		if (thn == "none" && i<=hm)
//		{
//		$(thm).style.display = "";
//		}
//		else
//		{
//			if (i>hm) {
//			$(thm).style.display = "none";
//			}
//			else
//			{
//			
//			}
//		}
	}	
}
*/
function addval (sender)
{
	var a = sender.checked;
	var b;
	var c;
	if (a)
	{
		$("PFname[1]").value = $("Fname").value;
		$("PLname[1]").value = $("Lname").value;
		b= document.getElementsByName("Contact");
		if (b.item(0).checked)
		{
				$("PCno[1]").value = $("Hno").value;	
		}
			else if (b.item(1).checked)
		{
		
		$("PCno[1]").value = $("Wno").value;			
		}
		else
		{
			$("PCno[1]").value = $("Mno").value;			
		}
		$("PEmail[1]").value = $("Femail").value;
	}
	else
	{
		$("PFname[1]").value = "";
		$("PLname[1]").value = "";
		$("PCno[1]").value = "";
		$("PEmail[1]").value = "";
	}
}

function frmsub()
{
	var a,b;
	a = $("Agent").checked;
	if (a)
	{
	document.getElementById("Pdetail").action = "agent.php";
	}
	else
	{
	document.getElementById("Pdetail").action = "ptest.php";
	}
	document.getElementById("Pdetail").submit(); 
}
function chnfname(sender)
{
	if ((($("Fname").value).length) == 0)
	{
		alert ("Plase Enter Proper Value");
		$("Fname").focus();
	}
	if (($("Psngr").checked))
	{
		$("PFname[1]").value = $("Fname").value;
	}	
}
	
function chnlname(sender)
{
	if (($("Psngr").checked))
	{
		$("PLname[1]").value = $("Lname").value;}
	}
function chnemail(sender)
{
	if (($("Psngr").checked))
	{
		$("PEmail[1]").value = $("Femail").value;}
}

function chngno(sender)
{
	a = (sender.name);
	var b = "R" + a;
	var c = document.getElementById(b);
}

function isempty (sender)
{

}

//Here is the started of validation function for booking.php page
function validateBookingForm()
{
	if(!validateFirstName())
	{
		return false;
	}else if(!validateLastName())
	{
		return false;
	}else if(!validateEmail())
	{
		return false;
	}else if(!validateHomePhoneNumber())
	{
		return false;
	}else if(!validateAddress())
	{
		return false;
	}else if(!validateState())
	{
		return false;
	}else if(!validatePostcode())
	{
		return false;
	}else if(!validateCountry())
	{
		return false;
	}
	
	//count all the run totals again
	recountTotals();
	
	return true;
}

function validateFirstName()
{
	var firstName = document.getElementById("first_name").value;
	var filter = /^[a-zA-Z\s]{1,30}$/;//name can only contains letters A to Z, a to z and Space, the length is 1 to 30
    if(firstName.search(filter)==-1)
    {
		
		alert("First Name Can Only Contains Alphanumeric Characters,Spaces And NOT Be Blank!\n Please Refill it!");
		changeBGColor("first_name",'red');
		return false;
    }
	return true;
	
}

function validateLastName()
{
	var lastName = document.getElementById("last_name").value;
	
	var filter = /^[a-zA-Z\s]{1,30}$/;//name can only contains letters A to Z, a to z and Space, the length is 1 to 30
    if(lastName.search(filter)==-1)
    {
        
		alert("Last Name Can Only Contains Alphanumeric Characters,Spaces And NOT Be Blank!\n Please Refill it!");
		changeBGColor("last_name",'red');
		return false;
    }
	return true;
}

function validateEmail()
{
	var email = document.getElementById("email").value;
	var filter  = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;//validate email
	if (email.search(filter)==-1)
	{
		alert("Email Can Not Be Blank And Must Be In The Right Format!\n Please Refill it!");
		changeBGColor("email",'red');
		return false;
    }
	return true;
	 
	
}

function validateHomePhoneNumber()
{
	var homePhone = document.getElementById("number_home").value;
	var filter  = /^[0-9-\(\)\s]{6,15}$/;//Homephone number can only contains number 0 to 9 , ( , ) and space, the total length is 7 to 15
	if (homePhone.search(filter)==-1)
	{
		alert("Incorrect Format Of Home Phone(Should Contains Numbers , Spaces, And Brackets only)! \n The Length Should Between 7 and 15\n Please Refill it!");
		changeBGColor("number_home",'red');
		return false;
    }
	return true;
	
}

function validateAddress()
{

	var address = document.getElementById("address_1").value;
	var filter  = /^[a-zA-Z0-9\s\(\)]{1,50}$/;//address can contain all letters a to z and A to Z also can contains space ( and ), the length is 1 to 50
	if (address.search(filter)==-1)
	{
		alert("Incorrect Format address Should NOT Contains Special Characters Except '(' and ')' \n The Lenght Should Be Less Than 50!\n Please Refill it!");
		changeBGColor("address_1",'red');
		return false;
    }
	return true;
}

function validateState()
{
	var state = document.getElementById("state").value;
	var filter  = /^[a-zA-Z0-9\s\(\)]{1,20}$/;//state can contain all letters , space , ( and ) length is 20
	if (state.search(filter)==-1)
	{
		alert("State Can Not Contain Special Characters Except for '(' and ')'! \n Also Should Not Be Over 20 Characters!\n Please Refill it!  ");
		changeBGColor("state",'red');
		return false;
    }
	return true;
}

function validatePostcode()
{
	var postcode = document.getElementById("postcode").value;
	var filter  = /^\d{4,6}$/; // post code is 4 to 6 digits only
	if (postcode.search(filter)==-1)
	{
		alert("Postcode Can Only Contains numbers And Can Only Be 4 to 6 digits Number!\n Please Refill it!  ");
		changeBGColor("postcode",'red');
		return false;
    }
	return true;
}

function validateCountry()
{
	var country = document.getElementById("country").value;
	var filter  = /^[a-zA-Z]{1,20}$/;//state can contain all letters , space , ( and ) length is 20
	if (country.search(filter)==-1)
	{
		alert("Country Can Not Contain Special Characters\n Also Should Not Be Over 20 Characters!\n Please Refill it!  ");
		changeBGColor("country",'red');
		return false;
    }
	return true;
}
function changeBGColor(fieldId, color)
{
	document.getElementById(fieldId).style.backgroundColor = color;
}
//End of validation function for booking.php page
////////////////////////////////////////////////////////////////////////////////////
//	Functions for adding rows to guests
////////////////////////////////////////////////////////////////////////////////////
function addGuest()
{
	//If table doesn't exist yet, make a new table
		//else, add a row to the table
	if(document.getElementById('guestTable') == null)
	{
		makeGuestTable();
	}
	else
	{
		addRowToTable();
	}
}
function makeGuestTable()
{
	//Creates a new table
	var guestTableSpan = document.getElementById('guestTableSpan');	//get the span item
	var guestTable = document.createElement('table');				//create a new table
	guestTable.id = "guestTable";	
	guestTableSpan.appendChild(guestTable);							//attach the table to the span
	
	//Add the header row
	var tbl = document.getElementById('guestTable') ;
	var lastRow = tbl.rows.length;
  	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
  	var row = tbl.insertRow(lastRow);
	row.setAttribute("class","rowOdd");
	
	//Guest #
	var cell = row.insertCell(0);
	var textNode = document.createTextNode("Guest #");
	cell.appendChild(textNode);
	
	//First Name
	var cell = row.insertCell(1);
	var textNode = document.createTextNode("First Name");
	cell.appendChild(textNode);
	
	//Last Name
	var cell = row.insertCell(2);
	var textNode = document.createTextNode("Last Name");
	cell.appendChild(textNode);
	
	//Contact Phone
	var cell = row.insertCell(3);
	var textNode = document.createTextNode("Contact Phone");
	cell.appendChild(textNode);
	
	//Email
	var cellLeft = row.insertCell(4);
	var textNode = document.createTextNode("Email");
	cellLeft.appendChild(textNode);
	
	//Food
	var cell = row.insertCell(5);
	var textNode = document.createTextNode("Food type");
	cell.appendChild(textNode);
	
	//Comment
	var cell = row.insertCell(6);
	var textNode = document.createTextNode("Comments");
	cell.appendChild(textNode);
	
	addRowToTable();												//add a row to the table
}
function addRowToTable()
{
	var tbl = document.getElementById('guestTable') ;
	var lastRow = tbl.rows.length;
  	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
  	var row = tbl.insertRow(lastRow);
	row.setAttribute("class","rowEven");

	//setup the elements
		// Guest #1
		var cell = row.insertCell(0);
		cell.setAttribute("style","text-align:center;");
		var textNode = document.createTextNode(iteration);
		cell.appendChild(textNode);
		
		//First Name
		var cell = row.insertCell(1);
		var inputElement = document.createElement('input');
		inputElement.type = 'text';
		inputElement.name = 'guest_firstName_'+ iteration;
		inputElement.id = 'guest_firstName_'+ iteration;
		inputElement.size = 20;		
		cell.appendChild(inputElement);
		
		//Last Name
		var cell = row.insertCell(2);
		var inputElement = document.createElement('input');
		inputElement.type = 'text';
		inputElement.name = 'guest_lastName_'+ iteration;
		inputElement.id = 'guest_lastName_'+ iteration;
		inputElement.size = 20;		
		cell.appendChild(inputElement);
		
		//Contact Phone
		var cell = row.insertCell(3);
		var inputElement = document.createElement('input');
		inputElement.type = 'text';
		inputElement.name = 'guest_phone_'+ iteration;
		inputElement.id = 'guest_phone_'+ iteration;
		inputElement.size = 20;		
		cell.appendChild(inputElement);
		
		//Email
		var cell = row.insertCell(4);
		var inputElement = document.createElement('input');
		inputElement.type = 'text';
		inputElement.name = 'guest_email_'+ iteration;
		inputElement.id = 'guest_email_'+ iteration;
		inputElement.size = 20;		
		cell.appendChild(inputElement);
		
		//Food
		// Select
		var cell = row.insertCell(5);
		var sel = document.createElement('select');
		sel.name = 'guest_food_'+ iteration;
		sel.options[0] = new Option('Regular', 'Regular');
		sel.options[1] = new Option('Vegetarian', 'Vegetarian');
		sel.options[2] = new Option('Celiac', 'Celiac');
		sel.options[3] = new Option('Diabetic', 'Diabetic');
		sel.options[4] = new Option('Special', 'Special');	
		cell.appendChild(sel);
		
		//Comment
		var cell = row.insertCell(6);
		var inputElement = document.createElement('input');
		inputElement.type = 'text';
		inputElement.name = 'guest_comment_'+ iteration;
		inputElement.id = 'guest_comment_'+ iteration;
		inputElement.size = 20;		
		cell.appendChild(inputElement);
}
function removeGuest(sender)
{		
	var tbl = document.getElementById('guestTable');
  	var lastRow = tbl.rows.length;
  	if (lastRow > 1) tbl.deleteRow(lastRow - 1);	
}
////////////////////////////////////////////////////////////////////////////////////
//	Functions for adding rows to guests
////////////////////////////////////////////////////////////////////////////////////