function Validate() {
//alert(document.ApptForm.cboLocation.value + ":" + document.ApptForm.txtDay.value + ":" + document.ApptForm.txtTime.value);
//return false
	// ----------------------	
	if (document.ApptForm.cboService.value == "") {
		alert("Please select a service.");
		document.ApptForm.cboService.focus(); 
		return false}
	// ----------------------	
	if (!(document.ApptForm.txtLastPeriod.value == "")) {
		if (isDate(document.ApptForm.txtLastPeriod.value)==false) {
			document.ApptForm.txtLastPeriod.focus(); 
			return false;
		}
	}		
	// ----------------------						
	if (document.ApptForm.cboLocation.value == "") {
		alert("Please select a location.");
		document.ApptForm.cboLocation.focus(); 
		return false}
	// ----------------------	
	if (document.ApptForm.txtDay.value == "") {
		alert("Please select a preferred appointment day.");
		return false}
	// ----------------------			
	if (document.ApptForm.txtTime.value == "") {
		alert("Please select a preferred appointment time.");
		return false}		
	// ----------------------		
	if (document.ApptForm.txtFirstName.value == "") {
		alert("Please enter your first name.");
		document.ApptForm.txtFirstName.focus(); 
		return false}
	// ----------------------			
	if (document.ApptForm.txtLastName.value == "") {
		alert("Please enter your last name.");
		document.ApptForm.txtLastName.focus(); 
		return false}		
	// ----------------------		
	if (document.ApptForm.txtDOB.value == "") {
		alert("Please enter your date of birth.");
		document.ApptForm.txtDOB.focus(); 
		return false}		
	// ----------------------			
	if (isDate(document.ApptForm.txtDOB.value)==false){
		document.ApptForm.txtDOB.focus(); 
		return false}		
	// ----------------------		
		if (document.ApptForm.cboGender.value == "") {
		alert("Please select a gender.");
		document.ApptForm.cboGender.focus(); 
		return false}
	// ----------------------			
	if (document.ApptForm.cboLanguage.value == "") {
		alert("Please select a preferred language.");
		document.ApptForm.cboLanguage.focus(); 
		return false}		
	// ----------------------	
	if ((document.ApptForm.rdoPreference(0).checked || document.ApptForm.rdoPreference(1).checked) == false ){
		alert("Please select a contact preference.");
		document.ApptForm.rdoPreference(0).focus(); 
		return false}
	// ----------------------	
		if ((document.ApptForm.rdoIdentify(0).checked || document.ApptForm.rdoIdentify(1).checked || document.ApptForm.rdoIdentify(2).checked || document.ApptForm.rdoIdentify(3).checked) == false ){
		alert("Please select a preferred way we should identify ourselves if we call you.");
		document.ApptForm.rdoIdentify(0).focus(); 
		return false}
	// ----------------------
	if (document.ApptForm.rdoPreference(0).checked == true ) {
		if (document.ApptForm.txtEmail.value == "") {
			alert("Please enter your email address.");
			document.ApptForm.txtEmail.focus(); 
			return false}
		if (!checkEmail(document.ApptForm.txtEmail)) {
			alert("Email address is not a valid format.");
			document.ApptForm.txtEmail.focus(); 
			return false}
		if (!(document.ApptForm.txtPhone.value == "")) {			
			if (!checkPhone(document.ApptForm.txtPhone)) {
				alert("Phone number is not a valid format.");
				document.ApptForm.txtPhone.focus(); 
				return false
			}				
		}
	} else {	
		if (document.ApptForm.txtPhone.value == "") {
			alert("Please enter your phone number.");
			document.ApptForm.txtPhone.focus(); 
			return false}		
		if (!checkPhone(document.ApptForm.txtPhone)) {
			alert("Phone number is not a valid format.");
			document.ApptForm.txtPhone.focus(); 
			return false}			
		if (!(document.ApptForm.txtEmail.value == "")) {
			if (!checkEmail(document.ApptForm.txtEmail)) {
				alert("Email address is not a valid format.");
				document.ApptForm.txtEmail.focus(); 
				return false
			}
		}
	}	
	// ----------------------	
	if (document.ApptForm.cboHowHeard.value == "") {
		alert("Please tell us how you heard about our web site.");
		document.ApptForm.cboHowHeard.focus(); 
		return false}				
	// ----------------------				
	return true;
}
// ====================================
function Validate2() {
	if (document.ApptForm.rdoPreference.value == "E-Mail") {
	 	if (document.ApptForm.chkAuthorize.checked == true) {
			//alert("Email would be sent to clinic and thank you page displayed...");
			return true;
		} else {
			alert("Since your contact preference is e-mail, please check the authorization box.");
			document.ApptForm.chkAuthorize.focus(); 
			return false;
		}
	} else {
		//alert("Email would be sent to clinic and thank you page displayed...");
		return true;
	}
}
// ====================================
function chgDays() {
	if (document.ApptForm.cboLocation.value == ""){
		showDays("DaysNone");
	} else {
		if (document.ApptForm.cboLocation.value == "Long Beach") {
			showDays("DaysFour");
		} else {
			if (document.ApptForm.cboLocation.value == "Orange") {
				showDays("DaysThree");
			} else {
				showDays("DaysFive");
			}
		}
	}
	showTimes("TimesNone");
}
// ====================================
function chgTimes(theControl) {
	cboName = document.getElementById(theControl);
	document.ApptForm.txtDay.value = cboName.value;
	document.ApptForm.txtTime.value = "";
	var strDay = cboName.value;
	switch(strDay.substring(0,3)) {
	case '':
		showTimes("TimesNone");
		break;
	case 'Mon':
		switch(document.ApptForm.cboLocation.value) {
		case "Long Beach":
			showTimes("Times_130_530");
			break;
		case "Napa":
			showTimes("Times_9_5");
			break;			
		default:			
			showTimes("Times_10_530");
			break;
		}
		break;
	case 'Tue':
		switch(document.ApptForm.cboLocation.value) {
		case "Long Beach":
			showTimes("Times_1_530");
			break;	
		case "Orange":
			showTimes("Times_10_5");
			break;			
		case "Napa":
			showTimes("Times_9_7"); 
			break;						
		default:			
			showTimes("Times_10_530");
			break;
		}
		break;	
	case 'Wed':
		switch(document.ApptForm.cboLocation.value) {
		case "Long Beach":
			showTimes("Times_9_5");
			break;	
		case "Orange":
			showTimes("Times_10_5");
			break;			
		case "Napa":
			showTimes("Times_9_7"); 
			break;						
		default:			
			showTimes("Times_10_530");
			break;
		}
		break;	
	case 'Thu':
		switch(document.ApptForm.cboLocation.value) {
		case "Irvine":
			showTimes("Times_10_630");
			break;
		case "Mission Viejo":
			showTimes("Times_10_530");
			break;
		case "Placentia":
			showTimes("Times_10_630");
			break;
		case "Santa Ana":
			showTimes("Times_10_530");
			break;
		case "Long Beach":
			showTimes("Times_9_5");
			break;	
		case "Napa":
			showTimes("Times_9_5"); 
			break;							
		default:			
			showTimes("TimesNone");
			break;
		}
		break;
	case 'Fri':
		switch(document.ApptForm.cboLocation.value) {
		case "Irvine":
			showTimes("Times_10_4");
			break;
		case "Mission Viejo":
			showTimes("Times_10_4");
			break;
		case "Placentia":
			showTimes("Times_10_3");
			break;
		case "Santa Ana":
			showTimes("Times_10_3");
			break;
		case "Orange":
			showTimes("Times_10_5");
			break;	
		case "Napa":
			showTimes("Times_9_1"); 
			break;				
		default:			
			showTimes("TimesNone");
			break;
		}
		break;				
	case 'Sat':
		showTimes("TimesNone");
		break;							
	default:
		showTimes("TimesNone");
		break;
	}
}
// ====================================
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion; this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	//alert(navigator.appVersion + "::" + navigator.userAgent);
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom)
	return this
}
// ====================================
var bw=new lib_bwcheck() //Making browsercheck object
// ====================================
function xyOff1(){
	var obj= (bw.ns4)?document.images.mLocator1:(bw.ie4)?document.all.mLocator1:document.getElementById("mLocator1");
	if(bw.ns4){this.x= obj.x; this.y= obj.y}
	else if(bw.ns5){this.x= obj.offsetLeft; this.y= obj.offsetTop}
	else {
		this.x= obj.offsetLeft;
		this.prnt= obj;
		while((this.prnt=this.prnt.offsetParent)){
			this.x+= this.prnt.offsetLeft;
		}
		this.y= obj.offsetTop;
		this.prnt= obj;
		while((this.prnt=this.prnt.offsetParent)){
			this.y+= this.prnt.offsetTop;
		}		
	}
}
function xyOff2(){
	var obj= (bw.ns4)?document.images.mLocator2:(bw.ie4)?document.all.mLocator2:document.getElementById("mLocator2");
	if(bw.ns4){this.x= obj.x; this.y= obj.y}
	else if(bw.ns5){this.x= obj.offsetLeft; this.y= obj.offsetTop}
	else {
		this.x= obj.offsetLeft;
		this.prnt= obj;
		while((this.prnt=this.prnt.offsetParent)){
			this.x+= this.prnt.offsetLeft;
		}
		this.y= obj.offsetTop;
		this.prnt= obj;
		while((this.prnt=this.prnt.offsetParent)){
			this.y+= this.prnt.offsetTop;
		}		
	}
}
// ===================================================
function showDays(LayerName) {
	hideLayer("DaysStart");
	hideLayer("DaysNone");
	hideLayer("DaysFive");
	hideLayer("DaysSix");
	hideLayer("DaysFour");	
	hideLayer("DaysFourTF");		
	hideLayer("DaysThree");	
	off = new xyOff1();
	if (document.getElementById) { 
  		menustyle = document.getElementById(LayerName).style; 
  	} else {
		var doc = document.layers; 
		var style = '';
	    menustyle = eval('doc.' + LayerName + style);
	}
	menustyle.top = off.y;
	menustyle.left = off.x+3;
   	menustyle.visibility = 'visible'; 
	document.getElementById("cbo" +LayerName).selectedIndex = 0;
}
// ===================================================
function showTimes(LayerName) {
	hideLayer("TimesStart");
	hideLayer("TimesNone");
	hideLayer("Times_10_530");
	hideLayer("Times_10_630");
	hideLayer("Times_10_4");
	hideLayer("Times_10_3");
	hideLayer("Times_10_2");		
	hideLayer("Times_9_5");
	hideLayer("Times_9_7");	
	hideLayer("Times_10_5");	
	hideLayer("Times_130_530");
	hideLayer("Times_1_530");	
	hideLayer("Times_12_4");			
	hideLayer("Times_9_1");	
	hideLayer("Times_12_8");		
	off = new xyOff2();
	//alert(off.x);
	if (document.getElementById) { 
  		menustyle = document.getElementById(LayerName).style; 
  	} else {
		var doc = document.layers; 
		var style = '';
	    menustyle = eval('doc.' + LayerName + style);
	}
	menustyle.top = off.y;
	menustyle.left = off.x+3;
   	menustyle.visibility = 'visible';
	document.getElementById("cbo" + LayerName).selectedIndex = 0; 
}
// ===================================================
function hideLayer(LayerName) {
	if (document.getElementById) { 
  		menustyle = document.getElementById(LayerName).style; 
  	} else {
		var doc = document.layers; 
		var style = '';
	    menustyle = eval('doc.' + LayerName + style);
	}
   	menustyle.visibility='hidden';
}
// ====================================
function isDigit (c){   
	return ((c >= "0") && (c <= "9"))
}
// ====================================
function isInteger (s) {   
	var i;
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    return true;
}
// ====================================
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
// ====================================
function checkPhone (theField){  
	var normalizedPhone = stripCharsInBag(theField.value, "()- ");
    return (isInteger(normalizedPhone) && normalizedPhone.length == 10);
}
// ====================================
function checkEmail(theField) {
	return (theField.value.indexOf("@") + "" != "-1" &&
  		theField.value.indexOf(".") + "" != "-1" &&
  		theField.value != "") 
	}
// ====================================
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
// ====================================
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
// ====================================
function isDate(dtStr){
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
// ====================================

