
//*********************** GLOBAL FUNCTIONS ***********************//
//****************************************************************//


// ----------------------- CONTACT FORM VALIDATION -----------------------//
function trimAll(sString)
{
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function isValidEmail(str) {
	return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function isFormComplete(FormName,formFields) {
	var x = 0, i = 0;
	var formArray = formFields.split(",");
	for(i=0; i < FormName.elements.length; i++) {
		for (x=0; x < formArray.length; x++) {
if (FormName.elements[i].name == formArray[x] && trimAll(FormName.elements[i].value) == "") {
	alert('Please enter the '+FormName.elements[i].name +' and try again.');
	FormName.elements[i].focus();
	return false;
}
		}
	}
	return true;
}

function submitForm(form) {
	if (!isFormComplete(form, form.required.value)) {
		return false;
	}
	if (!isValidEmail(form.email.value)) {
		alert("Please enter a valid Email.");
		form.email.focus();
		return false;
	}
}

function checkValue(field,text,newfield){
	if(field.value=='Other'){
		newfield.style.visibility = "visible";
		newfield.focus();
		newfield.value=text;
		newfield.select();
	}else{
		newfield.value='';
		newfield.style.visibility = "hidden";
	}
}


function Validate(objForm) {
	
	
	var arrValidated=new Array();
	
	for (var i=0; i<objForm.elements.length; i++) {
		var element=objForm.elements[i];
		var elName=element.name;
		if ((!elName)||(elName.length == 0)||(arrValidated[elName]))
continue;
		arrValidated[elName] = true;
		var validationType = element.getAttribute("validate");
		if ((!validationType)||(validationType.length == 0))
continue;
		var strMessages=element.getAttribute("msg");
		if (!strMessages)
strMessages = "";
		var arrMessages = strMessages.split("|");
		var arrValidationTypes = validationType.split("|");		
		for (var j=0; j<arrValidationTypes.length; j++) {
var curValidationType = arrValidationTypes[j];
var blnValid=true;
switch (curValidationType) {
	case "not_empty":
		blnValid = ValidateNotEmpty(element);
		break;
	case "integer":
		blnValid = ValidateInteger(element);
		break;
	case "number":
		blnValid = ValidateNumber(element);
		break;
	case "email":
		blnValid = ValidateEmail(element);
		break;
	case "phone":
		blnValid = ValidatePhone(element);
		break;
	default:
		try {
blnValid = eval(curValidationType+"(element)");
		}
		catch (ex) {
blnValid = true;
		}
}
if (blnValid == false) {
	var message="invalid value for "+element.name;
	if ((j < arrMessages.length)&&(arrMessages[j].length > 0))
		message = arrMessages[j];
	InsertError(element, message);
	if ((typeof element.focus == "function")||(element.focus)) {
		element.focus();
	}
	return false;
}
else
	ClearError(element);
		}
		
	}
	
	return true;
}

//Empty Validation
function ValidateNotEmpty(objElement) {
	var strValue = GetElementValue(objElement);
	var blnResult = true;
	if(allTrim(strValue) == "") //check for nothing
	{
	blnResult = false;
	}
	return blnResult;
}

//Integer Validation
function  ValidateInteger(objElement)
   //  check for valid numeric strings	
   {
   var strString = GetElementValue(objElement);
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
  
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

//Number Validation
function  ValidateNumber(objElement)
   //  check for valid numeric strings	
   {
   var strString = GetElementValue(objElement);
   var strValidChars = ".0123456789"; //decimal ok
   var strChar;
   var blnResult = true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
   //Email Validation
   function ValidateEmail(objElement) {
	//  Will check for @, period after @ and text in between
	var strValue = GetElementValue(objElement);
	var in_space = strValue.indexOf(" ");
	if (in_space != -1)
	{ return false;  }

	var len = strValue.length;
	var alpha = strValue.indexOf("@");
	var last_alpha = strValue.lastIndexOf("@");

	if (alpha != last_alpha)
	 { return false; }

	// No @, in first position, or name too short
	if (alpha == -1 || alpha == 0 || len<6 )
	 { return false; }

	var last_p = strValue.lastIndexOf(".");
// Be sure period at least two spaces after @, but not last char.

	if (last_p - alpha < 2 || last_p == (len - 1) )
		{ return false; }
	}
	

	
	//Valid PhoneNumber
	function ValidatePhone(objElement){
	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";
	// characters which are allowed in international phone numbers
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.
	var minDigitsInIPhoneNumber = 10;
	
	var strValue = GetElementValue(objElement);
	s=stripCharsInBag(strValue,validWorldPhoneChars);
	return (ValidateInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}


function GetElementValue(objElement) {
	var result="";
	switch (objElement.type) {
		case "text":
		case "hidden":
		case "textarea":
		case "password":
result = objElement.value;
break;
		case "select-one":
		case "select":
if (objElement.selectedIndex >= 0)
	result = objElement.options[objElement.selectedIndex].value;
break;
		case "radio":
		case "checkbox":
for (var i=0; i<objElement.form.elements.length; i++) {
	if (objElement.form.elements[i].name == objElement.name) {
		if (objElement.form.elements[i].checked)
result += objElement.form.elements[i].value+",";
	}
}
break;
	}
	return result;
}

function InsertError(element, strMessage) {
	if ((element.form.getAttribute("show_alert")) && (element.form.getAttribute("show_alert") != "0")) {
		alert(strMessage);
		return;
	}
	
	var strSpanID = element.name+"_val_error";
	var objSpan = document.getElementById(strSpanID);
	if (!objSpan) {
		if ((element.type == "radio")||(element.type == "checkbox")) {
for (var i=0; i<element.form.elements.length; i++) {
	if (element.form.elements[i].name == element.name) {
		element = element.form.elements[i];
	}
}
		}
		objSpan = document.createElement("span");
		objSpan.id = strSpanID;
		objSpan.className = "validation_error";
		var nodeAfter=0;
		var nodeParent = element.parentNode;
		for (var i=0; i<nodeParent.childNodes.length; i++) {
if (nodeParent.childNodes[i] == element) {
	if (i < (nodeParent.childNodes.length-1))
		nodeAfter = nodeParent.childNodes[i+1];
	break;
}
		}
		if ((!nodeAfter)&&(nodeParent.parentNode)) {
nodeParent = nodeParent.parentNode;
for (var i=0; i<nodeParent.childNodes.length; i++) {
	if (nodeParent.childNodes[i] == element.parentNode) {
		if (i < (nodeParent.childNodes.length-1))
nodeAfter = nodeParent.childNodes[i+1];
		break;
	}
}
		}
		if (nodeAfter)
nodeParent.insertBefore(objSpan, nodeAfter);
		else
document.body.appendChild(objSpan);
	}
	objSpan.innerHTML = strMessage;
}

function ClearError(element) {
	var strSpanID = element.name+"_val_error";
	var objSpan = document.getElementById(strSpanID);
	if (objSpan) {
		objSpan.innerHTML = "";
	}
}

function allTrim(cValue){
 var lDone=false;
 while (lDone==false){
  if (cValue.length==0) {return cValue;}
  if (cValue.indexOf(' ')==0){cValue=cValue.substring(1);lDone=false; continue;}
  else {lDone=true;}
  if (cValue.lastIndexOf(' ')==cValue.length-1){cValue=cValue.substring(0, cValue.length-1);lDone=false;continue;}
  else {lDone=true;}
 }
 return cValue;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
// ----------------------- Category deletion confirmation & link fwd -----------------------//
function deleteBooking(link, categoryId) 
{

	isDelete = confirm ("Delete this record?");
	if(isDelete == true) {
		document.forms['showBookings'].action = link;
		document.forms['showBookings'].pageId.value = 'deleteBookings';
		document.forms['showBookings'].deleteId.value = categoryId;
		document.forms['showBookings'].submit();
	} 
	else {
		return false;
	}
}


// ----------------------- object deletion confirmation & link fwd -----------------------//
function deleteMyObject(link, objectId, action_value)
{
	isDelete = confirm ("Delete this record?");
	if(isDelete == true) {
		document.forms['showBookings'].action = link;
		document.forms['showBookings'].pageId.value = action_value;
		document.forms['showBookings'].deleteId.value = objectId;
		document.forms['showBookings'].submit();
	} 
	else {
		return false;
	}
}

// ----------------------- product deletion confirmation & link fwd -----------------------//
function deleteProduct(link, productId) {

	isDelete = confirm ("Delete this product?");
	if(isDelete == true) {
		document.forms['showProducts'].action = link;
		document.forms['showProducts'].pageId.value = 'deleteProduct';
		document.forms['showProducts'].deleteId.value = productId;
		document.forms['showProducts'].submit();
	} else {
		return false;
	}
}

// ----------------------- Download deletion confirmation & link fwd -----------------------//
function deleteDownload(link, downloadId) {
	isDelete = confirm ("Delete this download?");
	if(isDelete == true) {
		document.forms['showDownloads'].action = link;
		document.forms['showDownloads'].downloadId.value = downloadId;
		document.forms['showDownloads'].submit();
	} else {
		return false;
	}
}

// ----------------------- Image Manager stuff -----------------------//
//		Create a new Imanager Manager, needs the directory where the manager is
		//and which language translation to use.
/*
		var manager = new ImageManager('assets/scripts/ImageManager','en');
		
		//Image Manager wrapper. Simply calls the ImageManager
		ImageSelector = 
		{
//This is called when the user has selected a file
//and clicked OK, see popManager in IMEStandalone to 
//see the parameters returned.
update : function(params)
{
	if(this.field && this.field.value != null)
	{
		this.field.value = params.f_file; //params.f_url
	}
},
//open the Image Manager, updates the textfield
//value when user has selected a file.
select: function(textfieldID)
{
	this.field = document.getElementById(textfieldID);
	manager.popManager(this);	
}
		};
*/	
// ----------------------- Check/Uncheck multiple checkboxes -----------------------//

function checkall(formname,checkname,thestate) {
	thestate = eval("document.forms."+formname+"."+thestate);
	// Find all the checkboxes...
	var inputs = document.getElementsByTagName("input");

  	// Loop through all form elements (input tags)
  	for(index = 0; index < inputs.length; index++) {
    	if(inputs[index].name == checkname) {
inputs[index].checked = thestate.checked;
		}

	}
}

 function onDropDownChange()
{
	var myIndex = document.getElementById("navSection").selectedIndex;
	var section = document.getElementById("navSection").options[myIndex].value;
	for(i=1;i<=5;i++)
	{
		HideContent('step'+i);
	}
	ShowContent('step' + section);
}

function HideContent(d) {
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	document.getElementById(d).style.display = "";
	window.location="#groupform";
}
function ReverseContentDisplay(d) {
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
	else { document.getElementById(d).style.display = "none"; }
}
function clearPrePost() {
	document.getElementById('quoteAPreWyd').selectedIndex = '0';
	document.getElementById('quoteAPostWyd').selectedIndex = '0';
	document.getElementById('quoteBPreWyd').selectedIndex = '0';
	document.getElementById('quoteBPostWyd').selectedIndex = '0';
	document.getElementById('quoteCPreWyd').selectedIndex = '0';
	document.getElementById('quoteCPostWyd').selectedIndex = '0';
	document.getElementById('quoteDPreWyd').selectedIndex = '0';
	document.getElementById('quoteDPostWyd').selectedIndex = '0';
}
function validateEmail2(emailStr)
{
	var re=new RegExp("^[\\w.-]+@([0-9a-z][\\w-]+\\.)+[a-z]{2,3}$","i");
 	if(re.test(emailStr))
	{
  		//alert("Valid Email Address");
  		return true;
 	}
 	else
 	{
  		//alert("Invalid Email Address");
  		return false;
 	}
}


function checkSection1()
{
//	return true;
	var result = false;
	var email = document.getElementsByName("email");
	var isAgent1 = document.getElementsByName('isAgent[isAgent]')[1];
	var isAgent0 = document.getElementsByName('isAgent[isAgent]')[0];
	if(email[1]) email = email[1];
	else
		email = email[0];
	if(allTrim(email.value) == '' || validateEmail2(email.value) == false)
	{
		alert('Valid Email must be filled');
		email.focus();
		return result;
	}

	if(isAgent1.checked)
	{
//		alert('isAgent1');
		organizerName = document.getElementsByName('organizerName')[0];
		organizerOrganization = document.getElementsByName('organizerOrganization')[0];
		organizerAddress2 = document.getElementsByName('organizerAddress2')[0];
		organizerState = document.getElementsByName('organizerState')[0];
		organizerCountry = document.getElementsByName('organizerCountry')[0];
		organizerTelephone = document.getElementsByName('organizerTelephone')[0];
		organizerAgencyInRegion = document.getElementsByName('recommendAgencyInRegion[recommendAgencyInRegion]');
		if(allTrim(organizerName.value) == '')
		{
			alert('Please fill Your Name field');
			organizerName.focus();
			return result;
		}
		if(allTrim(organizerOrganization.value) == '')
		{
			alert('Please fill Organisation/Diocese/Parish Name field');
			organizerOrganization.focus();
			return result;
		}
		if(allTrim(organizerAddress2.value) == '')
		{
			alert('Please fill City field');
			organizerAddress2.focus();
			return result;
		}
		if(allTrim(organizerState.value) == '')
		{
			alert('Please fill State field');
			organizerState.focus();
			return result;
		}
		if(organizerCountry.selectedIndex <=0)
		{
			alert('Country must be selected');
			organizerCountry.focus();
			return result;
		}
		if(allTrim(organizerTelephone.value) == '')
		{
			alert('Please fill Telephone field');
			organizerTelephone.focus();
			return result;
		}
		if(organizerAgencyInRegion[0].checked == false && organizerAgencyInRegion[1].checked == false)
		{
			alert('Please select Would you like us to refer you to a WYD travel agency in your country/Region');
			organizerAgencyInRegion[0].focus();
			return result;
		}
	}
	else if(isAgent0.checked)
	{
//		alert('isAgent0');
		agentCompanyName = document.getElementsByName('agentCompanyName')[0];
		agentAddress1 = document.getElementsByName('agentAddress1')[0];
		agentAddress2 = document.getElementsByName('agentAddress2')[0];
		agentState = document.getElementsByName('agentState')[0];
		agentZip = document.getElementsByName('agentZip')[0];
		agentCountry = document.getElementsByName('agentCountry')[0];
		agentLicNo = document.getElementsByName('agentLicNo')[0];
		agentName = document.getElementsByName('agentName')[0];
		agentTelephone = document.getElementsByName('agentTelephone')[0];
		if(allTrim(agentCompanyName.value) == '')
		{
			alert('Please fill Company Name field');
			agentCompanyName.focus();
			return result;
		}
		if(allTrim(agentAddress1.value) == '')
		{
			alert('Please fill Address field');
			agentAddress1.focus();
			return result;
		}
		if(allTrim(agentAddress2.value) == '')
		{
			alert('Please fill City field');
			agentAddress2.focus();
			return result;
		}
		if(allTrim(agentState.value) == '')
		{
			alert('Please fill State field');
			agentState.focus();
			return result;
		}
		if(allTrim(agentZip.value) == '')
		{
			alert('Please fill Zipcode field');
			agentZip.focus();
			return result;
		}
		if(agentCountry.selectedIndex <= 0)
		{
			alert('Please select Country');
			agentCountry.focus();
			return result;
		}
		if(allTrim(agentLicNo.value) == '')
		{
			alert('Please fill Agency License No. field');
			agentLicNo.focus();
			return result;
		}
		if(allTrim(agentName.value) == '')
		{
			alert('Please fill Your Name');
			agentName.focus();
			return result;
		}
		if(allTrim(agentTelephone.value) == '')
		{
			alert('Please fill Telephone field');
			agentTelephone.focus();
			return result;
		}
	}
	else
	{
		alert('You have to choose one Type of organizer');
		isAgent1.focus();
		return result;
	}
	result = true;
	
	
	return result;
}
function checkSection2()
{
//	return true;
	var	result = false;
	groupName = document.getElementsByName('groupName')[0];
	groupCity = document.getElementsByName('groupCity')[0];
	groupState = document.getElementsByName('groupState')[0];
	groupCountry = document.getElementsByName('groupCountry')[0];
	groupTypeID = document.getElementsByName('groupTypeID')[0];
	groupSizeEstimated = document.getElementsByName('groupSizeEstimated')[0];
	groupBudgetID = document.getElementsByName('groupBudgetID')[0];
	groupageBracketID = document.getElementsByName('groupageBracketID')[0];
	if(allTrim(groupName.value) == '')
	{
		alert('Group Name (or Reference) must be filled');
		groupName.focus();
		return result;
	}
	if(allTrim(groupCity.value) == '')
	{
		alert('Please fill City field');
		groupCity.focus();
		return result;
	}
	if(allTrim(groupState.value) == '')
	{
		alert('Please fill State field');
		groupState.focus();
		return result;
	}
	if(groupCountry.selectedIndex <= 0)
	{
		alert('Please select Country');
		groupCountry.focus();
		return result;
	}
	if(groupTypeID.selectedIndex <= 0)
	{
		alert('Please select Type');
		groupTypeID.focus();
		return result;
	}
	if(allTrim(groupSizeEstimated.value) == '')
	{
		alert('Please fill Estimated Group Size field');
		groupSizeEstimated.focus();
		return result;
	}
	if(groupBudgetID.selectedIndex <= 0)
	{
		alert('Please select Group Budget');
		groupBudgetID.focus();
		return result;
	}
	if(groupageBracketID.selectedIndex <= 0)
	{
		alert('Please select General Age Bracket');
		groupageBracketID.focus();
		return result;
	}
	result = true;
	return result;
}

function checkSection3()
{
//	return true;
	var result = false;
	isPrePostWYDTouringRequired = document.getElementsByName('isPrePostWYDTouringRequired[isPrePostWYDTouringRequired]');
	if(isPrePostWYDTouringRequired[0].checked)
	{
		groupSizeEstimatedPrePost = document.getElementsByName('groupSizeEstimatedPrePost')[0];
		accommodationStandardPreference1ID = document.getElementsByName('accommodationStandardPreference1ID')[0];
		mealPlanID = document.getElementsByName('mealPlanID')[0];
		freePlaceRatioID = document.getElementsByName('freePlaceRatioID')[0];
		tourEscortID = document.getElementsByName('tourEscortID')[0];
		encounterParticipation = document.getElementsByName('encounterParticipation[encounterParticipation]');
		if(allTrim(groupSizeEstimatedPrePost.value) == '')
		{
			alert('Estimated Group Size must be filled');
			groupSizeEstimatedPrePost.focus();
			return result;
		}
		if(accommodationStandardPreference1ID.selectedIndex <= 0)
		{
			alert('Accommodation Standard first preference must be selected');
			accommodationStandardPreference1ID.focus();
			return result;
		}
		if(mealPlanID.selectedIndex <= 0)
		{
			alert('Mail Plan must be speficied');
			mealPlanID.focus();
			return result;
		}
		if(freePlaceRatioID.selectedIndex <= 0)
		{
			alert('Free Place Ratio must be speficied');
			freePlaceRatioID.focus();
			return result;
		}
		if(tourEscortID.selectedIndex <= 0)
		{
			alert('Please select Professional Tour Escort');
			tourEscortID.focus();
			return result;
		}
		if(encounterParticipation[0].checked == false && encounterParticipation[1].checked == false)
		{
			alert('Please choose Days in the Diocese');
			encounterParticipation.focus();
			return result;
		}
		
	}
	result = true;
	return result;
}

function checkSection4()
{
//	return true;
	var result = false;
	isSYDAccomRequired = document.getElementsByName('isSYDAccomRequired[isSYDAccomRequired]');
	isSYDCoachRequired = document.getElementsByName('isSYDCoachRequired[isSYDCoachRequired]');
	isSYDSightseeingRequired = document.getElementsByName('isSYDSightseeingRequired[isSYDSightseeingRequired]');
	if(isSYDAccomRequired[0].checked == true)
	{
		sydGroupEstimatedSize = document.getElementsByName('sydGroupEstimatedSize')[0];
	//	sydArrivalDate = document.getElementsByName('sydArrivalDate')[0];
		//		sydDepartureDate = document.getElementsByName('
		sydAccommodationPreference1ID = document.getElementsByName('sydAccomodationPreference1ID')[0];
		sydPreferredLocationID = document.getElementsByName('sydPreferedLocationID')[0];
		sydHotelMealPlanID = document.getElementsByName('sydHotelMealPlanID')[0];
		/*sydFreePlaceRatioID = document.getElementsByName('sydFreePlaceRatioID')[0];*/
		sydArrivalDate = document.getElementsByName('sydArrivalDate[M]')[0];
		if(allTrim(sydGroupEstimatedSize.value) == '')
		{
			alert('Please fill Estimated Group Size');
			sydGroupEstimatedSize.focus();
			return result;
		}
		if(sydArrivalDate.selectedIndex != 6 && sydArrivalDate.selectedIndex !=5)
		{
			alert('Check-in Month could only be "Jun" or "Jul"');
			sydArrivalDate.focus();
			return result;
		}
		if(sydAccommodationPreference1ID.selectedIndex <= 0)
		{
			alert('Please select Accommodation Standard first preference');
			sydAccommodationPreference1ID.focus();
			return result;
		}
		if(sydPreferredLocationID.selectedIndex <= 0)
		{
			alert('Please select Preferred Location');
			sydPreferredLocationID.focus();
			return result;
		}
		if(sydHotelMealPlanID.selectedIndex <= 0)
		{
			alert('Please select Hotel Meal Plan');
			sydHotelMealPlanID.focus();
			return result;
		}
		/*
		if(sydFreePlaceRatioID.selectedIndex <= 0)
		{
			alert('Please select Free Place Ratio');
			sydFreePlaceRatioID.focus();
			return result;
		}*/
	}
	if(isSYDCoachRequired[0].checked == true)
	{
		sydCoachArrivalID = document.getElementsByName('sydCoachArrivalID')[0];
		sydCoachDepartureID = document.getElementsByName('sydCoachDepartureID')[0];
		if(sydCoachArrivalID.selectedIndex <= 0)
		{
			alert('Please select coach for Arrival Sydney Airport');
			sydCoachArrivalID.focus();
			return result;
		}
		if(sydCoachDepartureID.selectedIndex <= 0)
		{	
			alert('Please select coach for Departure Sydney Airport');
			sydCoachDepartureID.focus();
			return result;
		}
	}
	if(isSYDSightseeingRequired[0].checked == true)
	{
	}
	result = true;
	return result;
}

function checkSection5()
{
	//return true;
	var result = false;
	textauthcode = document.getElementsByName("authcode")[0];
	if(allTrim(textauthcode.value) == '')
	{
		alert('Authenticate code must be filled');
		textauthcode.focus();
		return result;
	}
	result = true;
	return result;
}

function checkEditedForm()
{
	if(checkSection1() && checkSection2() && checkSection3() && checkSection4() && checkSection5())
	{
		return true;
	}
	else
	{
		submitbutton = document.getElementById('submitbutton');
		submitbutton.disabled = false;
		return false;
	}
}

function checkAdminSection()
{
	result = false;
	quoteNoAssign = document.getElementsByName('quoteNoAssigned')[0];
	pinNo = document.getElementsByName('pinNo')[0];
	price = document.getElementsByName('quotedPrice')[0];
	actionTaken = document.getElementsByName('actionTaken')[0];
	
//	alert(actionTaken.options[actionTaken.selectedIndex].value);
	if(actionTaken.options[actionTaken.selectedIndex].value == 1)
	{
		if(trimAll(quoteNoAssign.value) == '' || quoteNoAssign.value == 0)
		{
			alert("Quote No must be assigned.");
			quoteNoAssign.focus();
			return result;
		}
		if(trimAll(pinNo.value) == '' || pinNo.value == 0)
		{
			alert("Pin No must be assigned.");
			pinNo.focus();
			return result;
		}
		if(trimAll(price.value) == '' || price.value == 0)
		{
			alert("Please assign a price for this quotation");
			price.focus();
			return result;
		}
	}
	return true;
}

function checkEditedFormForAdmin()
{
	if(checkSection1() && checkSection2() && checkSection3() && checkSection4() && checkAdminSection())
	{
		return true;
	}
	else
	{
		submitbutton = document.getElementById('submitbutton');
		submitbutton.disabled = false;
		return false;
	}
}
// -----------------------  -----------------------//
var accommodationStandardPreference1IDData = "To assist you in selecting the right accommodation category, the following classification may be used as a guide:<br/><br/><strong>Soft Camping</strong> &ndash; Permanent or professionally erected tents, soft mattress, cooking facilities, showers, toilets and screened eating areas (NB: This category is only applicable to certain tours in warmer regions).<br/><br/><strong>Budget Lodgings</strong> &ndash; Multi-share accommodation, possibly with shared shower and toilet facilities. <br/><br/><strong>Two Star</strong> &ndash; Budget motel (mostly with en-suite)<br/><br/><strong>Three Star</strong> &ndash; Moderate class hotel/motel (rooms with en-suite)<br/><br/><strong>Four Star</strong> &ndash; First class hotel (rooms with en-suite)<br/><br/><strong>Five Star</strong> &ndash; Luxury hotel (rooms with en-suite)";
var tourEscortIDData = "<b>Tour Escort Included</b> &ndash; professional guide to accompany group from point of arrival through to point of tour completion. Duties include daily touring commentary and overall co-ordination of the group travel program.<br/><br/> <b>Commentary Driver Only</b> &ndash; English speaking commentary driver will have basic knowledge of each region and provide commentary during touring BUT will not assist with group check-in at accommodation or act as an escort for the group. <br/><br/><b>Provide Tour Escort Surcharge</b> &ndash; supplementary cost to be listed for a full time Tour Escort for your consideration.";
var encounterParticipationData = "The Days in the Diocese Program for World Youth Day offers foreign visitors the chance to experience life in Australia, as well as to see how Australian Catholics live their faith. For 3 or 4 days visiting pilgrims will be hosted in an Australian diocese for a program of spiritual, social and cultural encounter. Australian host parishes and dioceses will welcome youth from other countries into their homes, parishes and communities and be responsible for all arrangements related to receiving foreign visitors, such as lodging, meals and outings. In keeping with the spirit of WYD, dioceses will provide simple accommodation to visitors such as parish halls, schools or family stays. The Days in the Diocese will constitute an integral part of WYD complementing the events in Sydney to provide the full WYD experience for all visiting pilgrims in a spirit of evangelisation, faith and international fellowship. <br/><br/>NB: Operated independently by each dioceses and not by Harvest Youth Tours.";
var sydAccomodationPreference1IDData = "To assist you in selecting the right accommodation category, the following classification may be used as a guide:<br/><br/><strong>Christian Camp Lodgings</strong> &ndash; Multi-share accommodation, possibly with shared shower and toilet facilities in recreational setting. <br/><br/><strong>College/University Rooms</strong> &ndash; Possibly with shared toilet and shower facilities in mainly suburban locations.<br/><br/><strong>Two Star</strong> &ndash; Budget motel (mostly with en-suite)<br/><br/><strong>Three Star</strong> &ndash; Moderate class hotel/motel (rooms with en-suite)<br/><br/><strong>Four Star</strong> &ndash; First class hotel (rooms with en-suite)<br/><br/><strong>Five Star</strong> &ndash; Luxury hotel (rooms with en-suite)<br/><br/><strong>Simple School Lodgings</strong> &ndash; Normally school rooms or parish halls without bed (BYO sleeping bag/mat). You must register directly with www.wyd2008.org";