// ---------- browser detect -----------------------------

var get_browser;
var get_platform;
  
if (navigator.appName == null || navigator.appName == "") {
	get_browser = "other";
	}
	else if (navigator.appName == "Netscape") {
	get_browser = "ns";
	}
	else if (navigator.appName == "Microsoft Internet Explorer") {
	get_browser = "ie";
	}
	else {
	get_browser = "other";
	}
 
if (navigator.platform == null || navigator.platform == "") {
	get_platform = "other";
	}
	else if (navigator.platform.indexOf("Mac") >= 0) {
	get_platform = "mac";
	}
	else if (navigator.platform.indexOf("Win") >= 0) {
	get_platform = "win";
	}
	else if (navigator.platform.indexOf("Unix") >= 0) {
	get_platform = "unix";
	}
	else {
	get_platform = "other";
	}
 
if (get_platform == "win") {
	document.write("<link rel=stylesheet href=\"http://www.fertility-docs.com/styles/styles_pc.css\"type=\"text/css\">");
	}
	
if (get_platform == "mac") {
	document.write("<link rel=stylesheet href=\"http://www.fertility-docs.com/styles/styles_mac.css\"type=\"text/css\">");
	}

// ---------- Tour Window ---------------------------------
	
function openTour() {
	var LeftPosition = (screen.width)  ? (screen.width-540)/2	: 0;
	var TopPosition	 = (screen.height) ? (screen.height-480)/2 : 20;
	var imageWin = window.open("http://www.fertility-docs.com/tour.phtml","FacilityTour","toolbar=0,width=540,height=480,status=0,scrollbars=0,resize=0,menbar=0,top="+TopPosition+",left="+LeftPosition+" ");
}

// ---------- date stamp ---------------------------------

var isnMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var today = new Date();
var years  = today.getYear();
if (years < 1900) years += 1900;

///////////////////////////////
//
// VALIDATE FORM
//
///////////////////////////////
	
function validateForm() {

	var re_alpha	= /^[A-Za-z ]+$/;
	var re_email	= /^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4}$/;
	var re_phone	= /^[0-9.() -]+$/;
	var re_num		= /^[0-9]+$/;
	
	// Check for empty FIRST NAME, LAST NAME, E-MAIL or invalid E-MAIL
	if (document.contact_form.first_name.value == "") {
		alert("Please enter your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.first_name.value)) {
		alert("Please enter only letters for your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (document.contact_form.last_name.value == "") {
		alert("Please enter your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.last_name.value)) {
		alert("Please enter only letters for your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (document.contact_form.email.value == "") {
		alert("Please enter your \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	} else if (!re_email.test(document.contact_form.email.value)) {
		alert("Please entered a valid \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	
	// Confirm Email added 7/12/08
	} else if (document.contact_form.emailConfirm.value == "") {
		alert ("Please confirm your \"E-Mail\" address");
		document.contact_form.emailConfirm.focus();
		document.contact_form.emailConfirm.style.background='#ffc';
   } else if (document.contact_form.email.value != document.contact_form.emailConfirm.value ) {
		alert ("The \"E-Mails\" do not match, please try again.");
		//document.contact_form.emailConfirm.focus();
		document.contact_form.email.style.background='#ffc';	
		document.contact_form.emailConfirm.style.background='#ffc'; 
		
	} else if (document.contact_form.daytime_phone.value == "") {
		alert("Please enter your \"Daytime Phone Number\"");
		document.contact_form.daytime_phone.focus();
		document.contact_form.daytime_phone.style.background='#ffc';
	} else if (!re_phone.test(document.contact_form.daytime_phone.value)) {
		alert("Please enter only numbers for your \"Daytime Phone Number\"");
		document.contact_form.daytime_phone.focus();
		document.contact_form.daytime_phone.style.background='#ffc';
	} else if (document.contact_form.treatment_date.value == "") {
		alert("Please enter the \"Approximate Treatment Date Desired\"");
		document.contact_form.treatment_date.focus();
		document.contact_form.treatment_date.style.background='#ffc';
	} else if (document.contact_form.securityKey.value == "") {
		alert("Please enter the \"Security Code\"");
		document.contact_form.securityKey.focus();
		document.contact_form.securityKey.style.background='#ffc';
	} else {
		document.contact_form.submit(); 
	}
}

function validateFormGender() {

	var re_alpha	= /^[A-Za-z ]+$/;
	var re_email	= /^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4}$/;
	var re_phone	= /^[0-9.() -]+$/;
	var re_num		= /^[0-9]+$/;
	
	// Check for empty FIRST NAME, LAST NAME, E-MAIL or invalid E-MAIL
	if (document.contact_form.first_name.value == "") {
		alert("Please enter your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.first_name.value)) {
		alert("Please enter only letters for your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (document.contact_form.last_name.value == "") {
		alert("Please enter your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.last_name.value)) {
		alert("Please enter only letters for your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (document.contact_form.email.value == "") {
		alert("Please enter your \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	} else if (!re_email.test(document.contact_form.email.value)) {
		alert("Please entered a valid \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	
	// Confirm Email added 7/12/08
	} else if (document.contact_form.emailConfirm.value == "") {
		alert ("Please confirm your \"E-Mail\" address");
		document.contact_form.emailConfirm.focus();
		document.contact_form.emailConfirm.style.background='#ffc';
   } else if (document.contact_form.email.value != document.contact_form.emailConfirm.value ) {
		alert ("The \"E-Mails\" do not match, please try again.");
		//document.contact_form.emailConfirm.focus();
		document.contact_form.email.style.background='#ffc';	
		document.contact_form.emailConfirm.style.background='#ffc'; 
		
	} else if (document.contact_form.daytime_phone.value == "") {
		alert("Please enter your \"Daytime Phone Number\"");
		document.contact_form.daytime_phone.focus();
		document.contact_form.daytime_phone.style.background='#ffc';
	} else if (!re_phone.test(document.contact_form.daytime_phone.value)) {
		alert("Please enter only numbers for your \"Daytime Phone Number\"");
		document.contact_form.daytime_phone.focus();
		document.contact_form.daytime_phone.style.background='#ffc';
	
	// Preferred Treatment Location required added 1/13/09
	} else if (document.contact_form.location[0].checked == 0 && 
			   document.contact_form.location[1].checked == 0 &&
			   document.contact_form.location[2].checked == 0 ) {
		alert("Please select the \"Preferred Treatment Location\"");
		document.contact_form.location[0].focus();
	} else if (document.contact_form.treatment_date.value == "") {
		alert("Please enter the \"Approximate Treatment Date Desired\"");
		document.contact_form.treatment_date.focus();
		document.contact_form.treatment_date.style.background='#ffc';
	} else if (document.contact_form.securityKey.value == "") {
		alert("Please enter the \"Security Code\"");
		document.contact_form.securityKey.focus();
		document.contact_form.securityKey.style.background='#ffc';
	} else {
		document.contact_form.submit(); 
	}
}

function validateFormGenderSelect() {

	var re_alpha	= /^[A-Za-z ]+$/;
	var re_email	= /^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4}$/;
	var re_phone	= /^[0-9.() -]+$/;
	var re_num		= /^[0-9]+$/;
	
	// Check for empty FIRST NAME, LAST NAME, E-MAIL or invalid E-MAIL
	if (document.contact_form.first_name.value == "") {
		alert("Please enter your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.first_name.value)) {
		alert("Please enter only letters for your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (document.contact_form.last_name.value == "") {
		alert("Please enter your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.last_name.value)) {
		alert("Please enter only letters for your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (document.contact_form.phone.value == "") {
		alert("Please enter your \"Daytime Phone Number\"");
		document.contact_form.phone.focus();
		document.contact_form.phone.style.background='#ffc';
	} else if (!re_phone.test(document.contact_form.phone.value)) {
		alert("Please enter only numbers for your \"Daytime Phone Number\"");
		document.contact_form.phone.focus();
		document.contact_form.phone.style.background='#ffc';
	} else if (document.contact_form.email.value == "") {
		alert("Please enter your \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	} else if (!re_email.test(document.contact_form.email.value)) {
		alert("Please entered a valid \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	
	// Confirm Email added 7/12/08
	} else if (document.contact_form.emailConfirm.value == "") {
		alert ("Please confirm your \"E-Mail\" address");
		document.contact_form.emailConfirm.focus();
		document.contact_form.emailConfirm.style.background='#ffc';
   } else if (document.contact_form.email.value != document.contact_form.emailConfirm.value ) {
		alert ("The \"E-Mails\" do not match, please try again.");
		//document.contact_form.emailConfirm.focus();
		document.contact_form.email.style.background='#ffc';	
		document.contact_form.emailConfirm.style.background='#ffc'; 

	// Preferred Treatment Location required added 1/13/09
	} else if (document.contact_form.location[0].checked == 0 && 
			   document.contact_form.location[1].checked == 0 &&
			   document.contact_form.location[2].checked == 0 ) {
		alert("Please select the \"Preferred Treatment Location\"");
		document.contact_form.location[0].focus();
	} else if (document.contact_form.treatment_date.value == "") {
		alert("Please enter the \"Approximate Treatment Date Desired\"");
		document.contact_form.treatment_date.focus();
		document.contact_form.treatment_date.style.background='#ffc';
	} else if (document.contact_form.securityKey.value == "") {
		alert("Please enter the \"Security Code\"");
		document.contact_form.securityKey.focus();
		document.contact_form.securityKey.style.background='#ffc';
	} else {
		document.contact_form.submit(); 
	}
}

function validateFormGenderSelectMexico() {

	var re_alpha	= /^[A-Za-z ]+$/;
	var re_email	= /^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4}$/;
	var re_phone	= /^[0-9.() -]+$/;
	var re_num		= /^[0-9]+$/;
	
	// Check for empty FIRST NAME, LAST NAME, E-MAIL or invalid E-MAIL
	if (document.contact_form.first_name.value == "") {
		alert("Please enter your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.first_name.value)) {
		alert("Please enter only letters for your \"First Name\"");
		document.contact_form.first_name.focus();
		document.contact_form.first_name.style.background='#ffc';
	} else if (document.contact_form.last_name.value == "") {
		alert("Please enter your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	} else if (!re_alpha.test(document.contact_form.last_name.value)) {
		alert("Please enter only letters for your \"Last Name\"");
		document.contact_form.last_name.focus();
		document.contact_form.last_name.style.background='#ffc';
	
	} else if (document.contact_form.city.value == "") {
		alert("Please enter your \"City\"");
		document.contact_form.city.focus();
		document.contact_form.city.style.background='#ffc';
		
	} else if (document.contact_form.country.value == "") {
		alert("Please enter your \"Country\"");
		document.contact_form.country.focus();
		document.contact_form.country.style.background='#ffc';
		
		
	} else if (document.contact_form.phone.value == "") {
		alert("Please enter your \"Daytime Phone Number\"");
		document.contact_form.phone.focus();
		document.contact_form.phone.style.background='#ffc';
	} else if (!re_phone.test(document.contact_form.phone.value)) {
		alert("Please enter only numbers for your \"Daytime Phone Number\"");
		document.contact_form.phone.focus();
		document.contact_form.phone.style.background='#ffc';
	} else if (document.contact_form.email.value == "") {
		alert("Please enter your \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	} else if (!re_email.test(document.contact_form.email.value)) {
		alert("Please entered a valid \"E-Mail\"");
		document.contact_form.email.focus();
		document.contact_form.email.style.background='#ffc';
	
	// Confirm Email added 7/12/08
	} else if (document.contact_form.emailConfirm.value == "") {
		alert ("Please confirm your \"E-Mail\" address");
		document.contact_form.emailConfirm.focus();
		document.contact_form.emailConfirm.style.background='#ffc';
   } else if (document.contact_form.email.value != document.contact_form.emailConfirm.value ) {
		alert ("The \"E-Mails\" do not match, please try again.");
		//document.contact_form.emailConfirm.focus();
		document.contact_form.email.style.background='#ffc';	
		document.contact_form.emailConfirm.style.background='#ffc'; 

	// Preferred Treatment Location required added 1/13/09
	} else if (document.contact_form.location[0].checked == 0 && 
			   document.contact_form.location[1].checked == 0 &&
			   document.contact_form.location[2].checked == 0 &&
			   document.contact_form.location[3].checked == 0 ) {
		alert("Please select the \"Preferred Treatment Location\"");
		document.contact_form.location[0].focus();
	} else if (document.contact_form.treatment_date.value == "") {
		alert("Please enter the \"Approximate Treatment Date Desired\"");
		document.contact_form.treatment_date.focus();
		document.contact_form.treatment_date.style.background='#ffc';
	} else if (document.contact_form.securityKey.value == "") {
		alert("Please enter the \"Security Code\"");
		document.contact_form.securityKey.focus();
		document.contact_form.securityKey.style.background='#ffc';
	} else {
		document.contact_form.submit(); 
	}
}