<!--//
	function dvgAddCustomerValidation(f) {
                if (f.companyName.selectedIndex == 0) {
                      alert("Select a Position");
                      f.companyName.focus();
                      return(false);
                }

                if (f.firstName.value.length < 1) {
                      alert("You must specify a First Name");
                      f.firstName.focus();
                      return(false);
                }

                if (f.surname.value.length < 1) {
                      alert("You must specify a Surname");
                      f.surname.focus();
                      return(false);
                }

		/*
		if (f.address.value.length < 1) {
                      alert("You must specify an Address");
                      f.address.focus();
                      return(false);
                }

		if (f.city.value.length < 1) {
                      alert("You must specify a Suburb/City");
                      f.city.focus();
                      return(false);
                }

		if (f.state.value.length < 1) {
                      alert("You must specify a State");
                      f.state.focus();
                      return(false);
                }

		if (f.postcode.value.length < 1) {
                      alert("You must specify a Postcode");
                      f.postcode.focus();
                      return(false);
                }

		if (f.phone.value.length < 1) {
			if (f.mobile.value.length < 1) {
				alert("You must specify a Contact Number");
				return(false);
			}
                }
		*/

		/*
		if (f.emergencycontactname.value.length < 1) {
                      alert("You must specify an Emergency Contact Name");
                      f.emergencycontactname.focus();
                      return(false);
                }

		if (f.emergencycontactnumber.value.length < 1) {
                      alert("You must specify an Emergency Contact Number");
                      f.emergencycontactnumber.focus();
                      return(false);
                }
		*/

		if (f.certificationid.selectedIndex == 0) {
                	alert("You must specify a Certification Agency");
                	f.certificationid.focus();
                	return(false);
		} else {
			if (f.certificationNumber.value.length < 1) {
			          if (f.certificationid.value != 1) {
				          if (f.certificationid.value != 13) {
					          if (f.certificationid.value != 14) {
						          if (f.certificationid.value != 38) {
							          if (f.certificationid.value != 40) {
        					        	          alert("You must specify a Certification Number");
        				        		          f.certificationNumber.focus();
                						          return(false);
								  }
							  }
						  }
				          }
			          }
			}
		}

	}

	function shopAddCustomerValidation(f) {
                if (f.companyName.selectedIndex == 0) {
                      alert("Select a Position");
                      f.companyName.focus();
                      return(false);
                }

                if (f.firstName.value.length < 1) {
                      alert("You must specify a First Name");
                      f.firstName.focus();
                      return(false);
                }

                if (f.surname.value.length < 1) {
                      alert("You must specify a Surname");
                      f.surname.focus();
                      return(false);
                }

		if (f.address.value.length < 1) {
                      alert("You must specify an Address");
                      f.address.focus();
                      return(false);
                }

		if (f.city.value.length < 1) {
                      alert("You must specify a Suburb/City");
                      f.city.focus();
                      return(false);
                }

		if (f.state.value.length < 1) {
                      alert("You must specify a State");
                      f.state.focus();
                      return(false);
                }

		if (f.postcode.value.length < 1) {
                      alert("You must specify a Postcode");
                      f.postcode.focus();
                      return(false);
                }

		if (f.phone.value.length < 1) {
			if (f.mobile.value.length < 1) {
				alert("You must specify a Contact Number");
				return(false);
			}
                }

		/*
		if (f.emergencycontactname.value.length < 1) {
                      alert("You must specify an Emergency Contact Name");
                      f.emergencycontactname.focus();
                      return(false);
                }

		if (f.emergencycontactnumber.value.length < 1) {
                      alert("You must specify an Emergency Contact Number");
                      f.emergencycontactnumber.focus();
                      return(false);
                }
		*/

		if (f.certificationid.selectedIndex == 0) {
                	alert("You must specify a Certification Agency");
                	f.certificationid.focus();
                	return(false);
		} else {
			if (f.certificationNumber.value.length < 1) {
			          if (f.certificationid.value != 1) {
				          if (f.certificationid.value != 13) {
					          if (f.certificationid.value != 14) {
						          if (f.certificationid.value != 38) {
							        if (f.certificationid.value != 40) {
        					        		alert("You must specify a Certification Number");
        				        		        f.certificationNumber.focus();
                						        return(false);
								}
							}
						  }
				          }
			          }
			}
		}

		if(f.dob_month.selectedIndex != null && f.dob_day.selectedIndex!=null && f.dob_year.selectedIndex!=null) {
                	thisForm="myForm";
                        thisyear="dob_year";
                        thismonth="dob_month";
                        thisday="dob_day";

                        var month=f.dob_month.selectedIndex;
                        var monthname=f.dob_month.options[month].text;
                        var monthvalue=f.dob_month.options[month].value;

                        var day=f.dob_day.selectedIndex;
                        var dayname=f.dob_day.options[day].text;
                        var dayvalue=f.dob_day.options[day].value;

                        var year=f.dob_year.selectedIndex;
                        var yearname=f.dob_year.options[year].text;
                        var yearvalue=f.dob_year.options[year].value;

			yearmod=yearvalue%4;

                        if (monthvalue==1 || monthvalue==3 || monthvalue==5 || monthvalue==7 || monthvalue==8 || monthvalue==10 || monthvalue==12) {
                        	if (dayvalue>31) {
                              		alert (" "+monthname+" does not have "+dayvalue+" days!")
	                              	document.forms[thisForm][thisday].focus()
                              		return false
                              	}
                        } else	{
                              	if (monthvalue==4 || monthvalue==6 || monthvalue==9 || monthvalue==11) {
                              		if (dayvalue > 30) {
                              			alert (" "+monthname+" does not have "+dayvalue+" days!")
                              			document.forms[thisForm][thisday].focus()
                              			return false
                              		}
                              	} else {
                              		if (monthvalue==2) {
                              			if ((dayvalue>29) || ((dayvalue>28) && (yearmod!=0))) {
                              				alert (" "+monthname+" does not have "+dayvalue+" days!")
                              				document.forms[thisForm][thisday].focus()
                              				return false
                              			}
                              		}
                              	}
                    	}

		}

		var start = new Date();
		start = Date.parse(start) / 1000;
	}


function shopAddCustomerValidation_noadd(f) {
                if (f.companyName.selectedIndex == 0) {
                      alert("Select a Position");
                      f.companyName.focus();
                      return(false);
                }

                if (f.firstName.value.length < 1) {
                      alert("You must specify a First Name");
                      f.firstName.focus();
                      return(false);
                }

                if (f.surname.value.length < 1) {
                      alert("You must specify a Surname");
                      f.surname.focus();
                      return(false);
                }
		if (f.certificationid.selectedIndex == 0) {
                	alert("You must specify a Certification Agency");
                	f.certificationid.focus();
                	return(false);
		} else {
			if (f.certificationNumber.value.length < 1) {
			          if (f.certificationid.value != 1) {
				          if (f.certificationid.value != 13) {
					          if (f.certificationid.value != 14) {
						          if (f.certificationid.value != 38) {
							        if (f.certificationid.value != 40) {
        					        		alert("You must specify a Certification Number");
        				        		        f.certificationNumber.focus();
                						        return(false);
								}
							}
						  }
				          }
			          }
			}
		}

		if(f.dob_month.selectedIndex != null && f.dob_day.selectedIndex!=null && f.dob_year.selectedIndex!=null) {
                	thisForm="myForm";
                        thisyear="dob_year";
                        thismonth="dob_month";
                        thisday="dob_day";

                        var month=f.dob_month.selectedIndex;
                        var monthname=f.dob_month.options[month].text;
                        var monthvalue=f.dob_month.options[month].value;

                        var day=f.dob_day.selectedIndex;
                        var dayname=f.dob_day.options[day].text;
                        var dayvalue=f.dob_day.options[day].value;

                        var year=f.dob_year.selectedIndex;
                        var yearname=f.dob_year.options[year].text;
                        var yearvalue=f.dob_year.options[year].value;

			yearmod=yearvalue%4;

                        if (monthvalue==1 || monthvalue==3 || monthvalue==5 || monthvalue==7 || monthvalue==8 || monthvalue==10 || monthvalue==12) {
                        	if (dayvalue>31) {
                              		alert (" "+monthname+" does not have "+dayvalue+" days!")
	                              	document.forms[thisForm][thisday].focus()
                              		return false
                              	}
                        } else	{
                              	if (monthvalue==4 || monthvalue==6 || monthvalue==9 || monthvalue==11) {
                              		if (dayvalue > 30) {
                              			alert (" "+monthname+" does not have "+dayvalue+" days!")
                              			document.forms[thisForm][thisday].focus()
                              			return false
                              		}
                              	} else {
                              		if (monthvalue==2) {
                              			if ((dayvalue>29) || ((dayvalue>28) && (yearmod!=0))) {
                              				alert (" "+monthname+" does not have "+dayvalue+" days!")
                              				document.forms[thisForm][thisday].focus()
                              				return false
                              			}
                              		}
                              	}
                    	}

		}

		var start = new Date();
		start = Date.parse(start) / 1000;
	}


	function countDown() {
		var now = new Date();
		now = Date.parse(now) / 1000;

		var x = parseInt(counts - (now - start), 10);

		document.getElementById('cntDown').innerHTML = x + ' seconds';

		if(x > 0)
			timerID = setTimeout('countDown()', 100)
		else {
			document.getElementById('cntDown').innerHTML = 'standby';
			start = new Date();
			start = Date.parse(start) / 1000;
		}
	}


	function center(DivName, DivWidth, DivHeight) {
		var esNS = document.getElementById && !document.all

		if (window.innerHeight) {
			posY = window.pageYOffset;
			posX = window.pageXOffset;

		} else if (document.documentElement && document.documentElement.scrollTop) {
			posY = document.documentElement.scrollTop;
			posX = document.documentElement.scrollLeft;

		} else if (document.body){
			posY = document.body.scrollTop;
			posX = document.body.scrollLeft;
		}

		PixX = (screen.availWidth - DivWidth) / 2;
		PixY = (screen.availHeight - DivHeight) / 2;

		if (esNS){
			document.getElementById(DivName).style.left = parseInt(posX + PixX) +'px';
			document.getElementById(DivName).style.top  = parseInt(posY + PixY) +'px';
		} else {
			document.getElementById(DivName).style.pixelLeft = parseInt(posX + PixX);
			document.getElementById(DivName).style.pixelTop = parseInt(posY + PixY);
		}
	}


	function ow(url, w, h) {
		var win = window.open(url, "newWindow", "width=" + w + ",height=" + h + ",status=no,toolbar=no,menubar=no,scrollbars=no");
	}

	var nChecked = 0;

	function limitSeatBooksToAvail(obj, nAvailableSeats) {
		var placekeeperObj = document.getElementById('placekeeper');
		
		if (placekeeperObj == null) {
			var placekeeper = 0;
		} else {
			var placekeeperIdx = placekeeperObj.selectedIndex;
			var placekeeper    = placekeeperObj.options[placekeeperIdx].value;
		}

		if (obj.name != 'placekeeper') {
        		nChecked = (obj.checked) ? nChecked=nChecked + 1 : nChecked = nChecked - 1;
		}

		remainingSeats = nAvailableSeats;
		remainingSeats = (remainingSeats - placekeeper);

	        if((parseInt(nChecked) + parseInt(placekeeper)) > nAvailableSeats) {
        	        alert('You can only select ' + nAvailableSeats + ' diver(s). (Seats Available on Boat)');
                	obj.checked = false;
	                nChecked = nChecked - 1;
        	}

       		remainingSeats = (remainingSeats - nChecked);

	        document.getElementById("remainingSeats").innerHTML = remainingSeats;

	        //if (remainingSeats == nAvailableSeats)
        	//        document.bulkBooking.cmd.disabled = true;
	        //else
        	//        document.bulkBooking.cmd.disabled = false;

	}

	function specialPurpose(obj) {
       		nChecked = (obj.checked) ? nChecked=true : nChecked = false;

		if (nChecked)
			offset = parseInt(document.getElementById("remainingSeats").innerHTML) + 1;
		else
			offset = parseInt(document.getElementById("remainingSeats").innerHTML) - 1;

	        document.getElementById("remainingSeats").innerHTML = offset;
	}
	

	var nIDs 	= 0;
	//var minNum 	= 1;
	//var maxNum 	= 55;
	var ids 	= new Array();
	var dts 	= new Array();
	var lts 	= new Array();
	var tms 	= new Array();
	var book	= new Array();
	var boat	= new Array();

	function init(bOn) {
		if (bOn) {
			for ( var a = minNum; a <= maxNum; a++) {
				if (typeof(document.dtl.elements['d' + a]) != 'undefined') {
					ids[ids.length] = a;
					dts[dts.length] = document.dtl.elements['d' + a].value;
					lts[lts.length] = document.dtl.elements['l' + a].value;
					tms[tms.length] = document.dtl.elements['t' + a].value;
					boat[boat.length] = document.dtl.elements['b' + a].value;
					book[book.length] = false;
				}
			}

			var e, i = 0;
			while (e = document.getElementsByName ('spcrew[]')[i++]) {
				e.disabled = true;
			}
			var e, i = 0;
			while (e = document.getElementsByName ('dc[]')[i++]) {
				e.disabled = true;
			}
			var e, i = 0;
			while (e = document.getElementsByName ('inst[]')[i++]) {
				e.disabled = true;
			}
		}
	}

	function checkOverlap(obj, bOn) {
		var $bFail = 0;

		if (bOn) {
			bChecked = (obj.checked) ? bChecked=true : bChecked = false;

			if (bChecked) {
				var e, i = 0;
				while (e = document.getElementsByName ('spcrew[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}
				var e, i = 0;
				while (e = document.getElementsByName ('dc[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}
				var e, i = 0;
				while (e = document.getElementsByName ('inst[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}

				for ( var a = 0; a <= ids.length; a++) {
					if (obj.value == ids[a]) {
						book[a] = true;
						if (typeof(document.dtl.elements[a]) == 'undefined') {
							alert('previous is not selected');
						} else {
							if (book[a] == book[a - 1]) {
								if (dts[a] == dts[a - 1]) {
									// date is the same
									// compare the current start time with the previous end time
									if (book[a - 1]) {
                                                                                if (tms[a] == lts[a-1]) {
                                                                                        alert('Back To Back Dives');
                                                                                }
										if(tms[a] < lts[a-1]) {
											$bFail++;
										}
									}
								} // else the date is different therefore safe
							}

							if (book[a] == book[a + 1]) {
								if (dts[a] == dts[a + 1]) {
									// date is the same
									// compare the current end time with the next start time
									if (book[a + 1]) {
                                                                                if (tms[a+1] == lts[a]) {
                                                                                        alert('Back To Back Dives');
                                                                                }

									        if (book[a + 1]) {
										        if (tms[a+1] < lts[a]) {
											        $bFail++;
										        }
									        }
                                                                        }
								}

								// else the date is different therefore safe
							}

							if ($bFail > 0) {
                                                                for ( var a = 0; a <= ids.length; a++) {
					                                if (obj.value == ids[a]) {
						                                book[a] = false;
									}
				                                }
								var e, i = 0;
								while (e = document.getElementsByName ('spcrew[]')[i++]) {
									if (obj.value == e.value) {
										e.disabled = true;
										break;
									}
								}
								var e, i = 0;
								while (e = document.getElementsByName ('dc[]')[i++]) {
									if (obj.value == e.value) {
										e.disabled = true;
										break;
									}
								}
								var e, i = 0;
								while (e = document.getElementsByName ('inst[]')[i++]) {
									if (obj.value == e.value) {
										e.disabled = true;
										break;
									}
								}
                                                                obj.checked = false;

								alert('Trip Starts Before You Get Back');
                                                        }
						}
					}
				}
			} else {
				for ( var a = 0; a <= ids.length; a++) {
					if (obj.value == ids[a])
						book[a] = false;
				}
				var e, i = 0;
				while (e = document.getElementsByName ('spcrew[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}
				var e, i = 0;
				while (e = document.getElementsByName ('dc[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}
				var e, i = 0;
				while (e = document.getElementsByName ('inst[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}
			}

			//alert("ids: " + ids + "\ndts:" + dts + "\ntms: " + tms + "\nlts: " + lts + "\nbook: " + book);

		}

	}



	function bulkBookingInit (bOn) {
		//document.bulkBooking.cmd.disabled = true;

		if (bOn) {
			var e, i = 0;
			while (e = document.getElementsByName ('spcrew[]')[i++]) {
				e.disabled = true;
			}
			var e, i = 0;
			while (e = document.getElementsByName ('dc[]')[i++]) {
				e.disabled = true;
			}
			var e, i = 0;
			while (e = document.getElementsByName ('inst[]')[i++]) {
				e.disabled = true;
			}
		}
	}



	function bulkBookingGearCheck(obj, bOn, remainingSeats) {
		limitSeatBooksToAvail(obj, remainingSeats);

		if (bOn) {
			bChecked = (obj.checked) ? bChecked=true : bChecked = false;

			if (bChecked) {
				var e, i = 0;
				while (e = document.getElementsByName ('spcrew[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}
				
				var e, i = 0;
				while (e = document.getElementsByName ('dc[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}

				var e, i = 0;
				while (e = document.getElementsByName ('inst[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = false;
						break;
					}
				}
			} else {
				var e, i = 0;
				while (e = document.getElementsByName ('spcrew[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}

				var e, i = 0;
				while (e = document.getElementsByName ('dc[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}

				var e, i = 0;
				while (e = document.getElementsByName ('inst[]')[i++]) {
					if (obj.value == e.value) {
						e.disabled = true;
						break;
					}
				}
			}
		}
	}



	function deleteDiver() {
		if (confirm("Are you sure you want to delete the diver from the dive?"))
			return true;
		else
			return false;
	}

	function assignDiver() {
		if (confirm("Are you sure you want to Assign this Customer?"))
			return true;
		else
			return false;
	}


	function resendBookingEmailConf() {
		if (confirm("Are you sure you want to resend the confirmation email for this booking?"))
			return true;
		else
			return false;
	}


	function deleteCustomer() {
		if (confirm("Are you sure you want to delete the Customer? \n\n\nAll History related to this Customer will be deleted. \n If you wish to keep the history set the customer to inactive instead."))
			return true;
		else
			return false;
	}

	function bchConfirm(str) {
		if (confirm(str))
			return true;
		else
			return false;

	}


	function checkNum(obj, n) {
		var cnt = 0;

		for (i = 0; i < obj.length; i++){
			if (obj[i].selected == true) {
				cnt++;
			}
		}

		if (cnt > n) {
			alert("You have selected more than " + n + " crew members.");
			return false;
		} else {
			return false;
		}
	}



































function validateEmail(addr, man, db) {
    if (addr == '' && man) {
       if (db) alert('Email Address Is Mandatory');
       return false;
    }

    if (addr == '' && !man)
        return true;


    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
    for (i = 0; i < invalidChars.length; i++) {
       if (addr.indexOf(invalidChars.charAt(i), 0) > -1) {
          if (db) alert('email Address Contains Invalid Characters');
          return false;
       }
    }

    for (i = 0; i<addr.length; i++) {
       if (addr.charCodeAt(i)>127) {
          if (db) alert('Email Address Contains Non ASCII Characters.');
          return false;
       }
    }

    var atPos = addr.indexOf('@', 0);
    if (atPos == -1) {
       if (db) alert('Email Address Must Contain An @');
       return false;
    }

    if (atPos == 0) {
       if (db) alert('email Address Must Not Start With @');
       return false;
    }

    if (addr.indexOf('@', atPos + 1) > - 1) {
       if (db) alert('Email Address Must Contain Only One @');
       return false;
    }

    if (addr.indexOf('.', atPos) == -1) {
       if (db) alert('Email Address Must Contain a Full Stop In the Domain Name');
       return false;
    }

    if (addr.indexOf('@.',0) != -1) {
       if (db) alert('Full Stop Must Not Immediately Follow @ In Email Aaddress');
       return false;
    }

    if (addr.indexOf('.@',0) != -1){
       if (db) alert('full Stop Must Not Immediately Precede @ In Email Address');
       return false;
    }

    if (addr.indexOf('..',0) != -1) {
       if (db) alert('Two Full Stops Must Not Be Adjacent In Email Address');
       return false;
    }

    var suffix = addr.substring(addr.lastIndexOf('.')+1);
    if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
       if (db) alert('Invalid Primary Domain In Email Address');
       return false;
    }
    return true;
}


/*
onmouseover="setPointer(this, 1, 'over', '#E5E5E5', '#CCFFCC', '#FFCC99');"
onmouseout="setPointer(this, 1, 'out', '#E5E5E5', '#CCFFCC', '#FFCC99');"
onmousedown="setPointer(this, 1, 'click', '#E5E5E5', '#CCFFCC', '#FFCC99');
*/
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
	var theCells = null;

	if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') {
		return false;
	}

	if (typeof(document.getElementsByTagName) != 'undefined') {
		theCells = theRow.getElementsByTagName('td');

	} else if (typeof(theRow.cells) != 'undefined') {
		theCells = theRow.cells;

	} else {
		return false;
	}

	var rowCellsCnt	 = theCells.length;
	var domDetect	 = null;
	var currentColor = null;
	var newColor	 = null;

	if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
		currentColor = theCells[0].getAttribute('bgcolor');
		domDetect    = true;
	} else {
		currentColor = theCells[0].style.backgroundColor;
		domDetect    = false;
	}

	if (currentColor.indexOf("rgb") >= 0) {
		var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
             	currentColor.indexOf(')'));
		var rgbValues = rgbStr.split(",");
		currentColor = "#";
		var hexChars = "0123456789ABCDEF";

		for (var i = 0; i < 3; i++) {
			var v = rgbValues[i].valueOf();
			currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
		}
	}

	if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
		if (theAction == 'over' && thePointerColor != '') {
			newColor = thePointerColor;

		} else if (theAction == 'click' && theMarkColor != '') {
			newColor = theMarkColor;
			marked_row[theRowNum] = true;
		}

	} else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
		if (theAction == 'out') {
			newColor = theDefaultColor;

		} else if (theAction == 'click' && theMarkColor != '') {
			newColor = theMarkColor;
			marked_row[theRowNum] = true;
		}

	} else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
		if (theAction == 'click') {
			newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor;
			marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) ? true : null;
		}
	}

	if (newColor) {
		var c = null;
		if (domDetect) {
			for (c = 0; c < rowCellsCnt; c++) {
				theCells[c].setAttribute('bgcolor', newColor, 0);
			}
		} else {
			for (c = 0; c < rowCellsCnt; c++) {
				theCells[c].style.backgroundColor = newColor;
			}
		}
	}

	return true;
}

function pageLoad() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('pageloading').style.visibility = 'hidden';
	} else {
		if (document.layers) {	// Netscape 4
			document.pageloading.visibility = 'hidden';
		} else {  // IE 4
			document.all.pageloading.style.visibility = 'hidden';
		}
	}
}

function checkSelect(obj) {
	obj.checked = true;
}

function showSearch() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('searchBar').style.display = 'block';
	} else {
		document.all.searchBar.style.display = 'block';
	}
}


function proceedOnStudentCertification(qry) {
	if (confirm("The certification of this diver is 'Student'. Click OK if they are on course?")) {
		location.href = qry;
	} else {
		alert('You need to update their certification level before proceeding');	
	}
	
}

function updateMandatoryDetailsIgnoredMsg(msg) {
	alert("You neglected to update all the required details and the following are still missing: " + msg + "\n\nYou must update these details before proceeding.\n\nNote: it is a legal requirement that we have all customer details on file");
}

function updateDetailsRequired(mandatory, isshop, msg, qry, qry2) {
        if (isshop == 1 ) {
                if (mandatory > 0) {
                        alert("The following details are missing: " + msg + "\n\nYou must update these details before proceeding.\n\nNote: it is a legal requirement that we have all customer details on file");
                        location.href = qry;
                } else {
                        updateDetailsRequiredConfirm(msg, qry, qry2);
                }
        } else {
                updateDetailsRequiredConfirm(msg, qry, qry2);
        }
}


function updateDetailsRequiredConfirm(msg, qry, qry2) {
        if (confirm("The following details are missing: " + msg + "\n\nClick OK to continue booking this customer on a dive without updating their details\n\nNote: it is a legal requirement that we have all customer details on file")) {
	        alert('You will be prompted to update their information next time you book them on a dive');
	        location.href = qry2;
        } else {
	        location.href = qry;
        }
}

// start prepop functions
a=new Array(99);

function relate(formName, elementName, j) {
	with (document.getElementById(elementName)) {
		for(i = options.length - 1; i > 0; i--) options[i] = null; // null out in reverse order (bug workarnd)
	        for(i = 0; i < a[j].length; i++){
			options[i] = new Option(a[j][i].text, a[j][i].value);
		}
	        options[0].selected = true;
	}
}

function getFormNum (formName) {
	var formNum =-1;

	for (i=0;i<document.forms.length;i++){
		tempForm = document.forms[i];
		if (formName == tempForm) {
			formNum = i;
			break;
		}
	}
	return formNum;
}

var catsIndex = -1;
var itemsIndex;


function newCat(){
	catsIndex++;
	a[catsIndex] = new Array();
	itemsIndex = 0;
}

function O(txt,url) {
	a[catsIndex][itemsIndex]=new myOptions(txt,url);
	itemsIndex++;
}

function myOptions(text, value){
	this.text = text;
	this.value = value;
}

// end prepop functions


// ajax livesearch stuff
function autocompletefn() {
	new Ajax.Autocompleter("fn", "autocompletefn_choices", "livesearch.php", {paramName: "firstname", minChars: 1});
}

function autocompletesn() {
	new Ajax.Autocompleter("sn", "autocompletesn_choices", "livesearch.php", {paramName: "surname", minChars: 1});
}

function check_availability_nocid(objid, msgid) {
	var obj = document.getElementById(objid);
	var qstr = "./livesearch.php?email=" + obj.value;
	checkIfExist(qstr, msgid);
}

function check_availability(objid, msgid, cid) {
	var obj = document.getElementById(objid);
	var qstr = "./livesearch.php?email=" + obj.value + "&cid=" + cid;
	checkIfExist(qstr, msgid);
}

function check_address(objid, msgid) {
	var obj = document.getElementById(objid);
        var sn = document.getElementById('surname');
	var qstr = "./livesearch.php?address=" + obj.value + "&surname=" + sn.value;
	checkIfExist(qstr, msgid)
}

function checkValid(fld1, hdnfld1, fld2, hdnfld2, fld3) {
	var obj1 = document.getElementById(fld1);
	var hdnobj1 = document.getElementById(hdnfld1);
	var obj2 = document.getElementById(fld2);
	var hdnobj2 = document.getElementById(hdnfld2);
	var obj3 = document.getElementById(fld3);
        
       /*
        if (hdnobj1.value == 0) {
                obj3.disabled = true;
                return;
        }
        
        if (hdnobj2.value <= 0) {
                obj3.disabled = true;
                return;
        }
        
        obj3.disabled = false;
       */
}

function checkIfExist(url, c_id) {		
	var xmlhttp = false;
	
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	xmlhttp.open('GET', url, true);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && (xmlhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
		//if (xmlhttp.readyState == 4) {
			document.getElementById(c_id).innerHTML = xmlhttp.responseText
		}
	}

	xmlhttp.send(null);
	return;
}


function toggleLayer( whichLayer ) {
	var elem, vis;
  
  	if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  	else if( document.all ) // this is the way old msie versions work
      		elem = document.all[whichLayer];
  	else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  	
  	vis = elem.style;
  		
  	// if the style.display value is blank we try to figure it out here
  	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
 		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  
  	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}


function getDiveSite(dsid) {
	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open('GET', 'getDiveSiteInfo.php?dsid=' + dsid, true);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			var t = xmlhttp.responseText;
			if(t) {
				document.getElementById('dsInfo').innerHTML = t;
			}
		}
	}

	xmlhttp.send(null);
	return;
}

function getDiveSiteList(dtid) {
	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open('GET', 'getDiveSiteList.php?dtid=' + dtid, true);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			var t = xmlhttp.responseText;
			if(t) {
				document.getElementById('dsList').innerHTML = t;
			}
		}
	}

	xmlhttp.send(null);
	return;
}

-->


