/* Pre-loading the images for the tabs */

	// Tab & fade bar rollovers
		tab_home = new Image();
		//tab_news = new Image();
		tab_phys = new Image();
		tab_teammem = new Image();
		tab_provide = new Image();
		tab_members = new Image();
		tab_brokers = new Image();
		tab_contact = new Image();

		//tab_home.src = "/images/tabs/tabs_home.gif";
		//tab_news.src = "/images/tabs/tabs_news.gif";
		//tab_members.src = "/images/tabs/tabs_members.gif";
		//tab_provide.src = "/images/tabs/tabs_provide.gif";
		//tab_brokers.src = "/images/tabs/tabs_brokers.gif";
		//tab_phys.src = "/images/tabs/tabs_phys.gif";
		//tab_contact.src = "/images/tabs/tabs_contact.gif";
		//tab_teammem.src = "/images/tabs/tabs_news.gif";

		tab_home.src = "/images/tabs/tabs_home.png";
		tab_phys.src = "/images/tabs/tabs_phys.png";
		tab_teammem.src = "/images/tabs/tabs_teammem.png";
		tab_provide.src = "/images/tabs/tabs_provide.png";
		tab_members.src = "/images/tabs/tabs_members.png";
		tab_brokers.src = "/images/tabs/tabs_brokers.png";
		tab_contact.src = "/images/tabs/tabs_contact.png";

		fade_home = new Image();
		//fade_news = new Image();
		fade_phys = new Image();
		fade_teammem = new Image();
		fade_provide = new Image();
		fade_members = new Image();
		fade_brokers = new Image();
		fade_contact = new Image();


		//fade_home.src = "/images/fades_top/fade_top_home.gif";
		//fade_news.src = "/images/fades_top/fade_top_news.gif";
		//fade_members.src = "/images/fades_top/fade_top_members.gif";
		//fade_provide.src = "/images/fades_top/fade_top_provide.gif";
		//fade_brokers.src = "/images/fades_top/fade_top_brokers.gif";
		//fade_phys.src = "/images/fades_top/fade_top_phys.gif";
		//fade_contact.src = "/images/fades_top/fade_top_contact.gif";
		//fade_teammem.src = "/images/fades_top/fade_top_news.gif";
		
		fade_home.src = "/images/fades_top/fade_top_home.gif";
		fade_phys.src = "/images/fades_top/fade_top_phys.gif";
		fade_teammem.src = "/images/fades_top/fade_top_teammem.gif";
		fade_provide.src = "/images/fades_top/fade_top_provide.gif";
		fade_members.src = "/images/fades_top/fade_top_members.gif";
		fade_brokers.src = "/images/fades_top/fade_top_brokers.gif";
		fade_contact.src = "/images/fades_top/fade_top_contact.gif";



	// Cycling banner in the upper right_hand corner
		var cornerArray = new Array(5);
			cornerArray[0] = "/images/right_corner/right_corner_boy.jpg";
			cornerArray[1] = "/images/right_corner/right_corner_brokers.jpg";
			cornerArray[2] = "/images/right_corner/right_corner_docs.jpg";
			cornerArray[3] = "/images/right_corner/right_corner_paper.jpg";
			cornerArray[4] = "/images/right_corner/right_corner_xrays.jpg";
		var currentImage = Math.floor(Math.random() * cornerArray.length);



/* Cycling the graphic in the right-hand corner */

function cycleRightHand()	{
	if (currentImage >= (cornerArray.length - 1)) {
		currentImage = 0;
	} else	{
		currentImage++;
	}
			
	document.right_hand_cycling_image.src = cornerArray[currentImage];
	setTimeout("cycleRightHand()", 4 * 1000);	// the multiplier is the # of seconds between cycles as you must give it in milliseconds)
}



/* Validation scripts for the various form submits throughout the site */

function validateAskUs() {
	var optlength = document.form1.employer.length;
	var employergone = true;

	for (i=0; i<optlength; i++) {
		if (document.form1.employer[i].checked == true)	{
			employergone = false;
			break;
		}
	}

	if (employergone || Trim(document.form1.health_topic.value) == '' || Trim(document.form1.email.value) == '') {
		if (employergone) {
			alert("You must enter an employer.\nPlease enter one before submitting.");
			document.form1.employer[0].focus();
			return false;
		}

		if (Trim(document.form1.health_topic.value) == '') {
			alert("You must enter a question/request.\nPlease enter one before submitting.");
			document.form1.health_topic.value = '';
			document.form1.health_topic.focus();
			return false;
		}

		if (Trim(document.form1.email.value) == '') {
			alert("You must enter an email address so we can answer you.\nPlease enter one before submitting.");
			document.form1.email.value = '';
			document.form1.email.focus();
			return false;
		}
	} else {
		return true;
	}
}

function validateContentEdit()	{
	if (Trim(document.edit.title.value) == '') {
		alert("All pages must have a title.\nPlease enter one before submitting.");
		document.edit.title.value = '';
		document.edit.title.focus();
		return false;
	}
	
	var rightsidebar = document.getElementById('thirdcol_text');
		
	if (rightsidebar.value.length > 1000) {
		alert("The max length for the Right Sidebar Text is 1000 characters.  Please enter less than 1000 characters before submitting.");				
		rightsidebar.focus();
		return false;				
	}		
	
	var pgcontent = document.getElementById('content');

	if (pgcontent.value.length > 8000) {
		alert("The max length for Page Content text is 8000 characters.  Please enter less than 8000 characters before submitting.");				
		pgcontent.focus();
		return false;				
	}		

}

function validateHealthProgramInquiry() {
	var optlength = document.form1.Program.length;
	var programgone = true;

	for (i=0; i<optlength; i++) {
		if (document.form1.Program[i].checked == true)	{
			programgone = false;
			break;
		}
	}

	if (Trim(document.form1.Last_Name.value) == '' || Trim(document.form1.First_Name.value) == '' || Trim(document.form1.Phone.value) == '' || Trim(document.form1.email.value) == '' || programgone) {
		if (Trim(document.form1.Last_Name.value) == '') {
			alert("You must enter a last name.\nPlease enter one before submitting.");
			document.form1.Last_Name.value = '';
			document.form1.Last_Name.focus();
			return false;
		}

		if (Trim(document.form1.First_Name.value) == '') {
			alert("You must enter a first name.\nPlease enter one before submitting.");
			document.form1.First_Name.value = '';
			document.form1.First_Name.focus();
			return false;
		}

		if (Trim(document.form1.Phone.value) == '') {
			alert("You must enter a phone to assist us in answering your inquiry.\nPlease enter one before submitting.");
			document.form1.Phone.value = '';
			document.form1.Phone.focus();
			return false;
		}

		if (Trim(document.form1.email.value) == '') {
			alert("You must enter an email to assist us in answering your inquiry.\nPlease enter one before submitting.");
			document.form1.email.value = '';
			document.form1.email.focus();
			return false;
		}

		if (programgone) {
			alert("You must enter a program.\nPlease enter one before submitting.");
			document.form1.Program[0].focus();
			return false;
		}
	} else {
		return true;
	}
}

function validateNewsEdit() {
	if (Trim(document.edit.title1.value) == '') {
		alert("You must enter a title.\nPlease add one before submitting.");
		document.edit.title1.value = '';
		document.edit.title1.focus();
		return false;
	} else {
		return true;
	}
}

function validatePhysFinderSearch1() {
	var optlength = document.ChooseForm.plan.length;
	var plangone = true;

	for (i=0; i<optlength; i++) {
		if (document.ChooseForm.plan[i].checked == true)	{
			plangone = false;
			break;
		}
	}

	if (plangone) {
		alert("You must choose a plan.\nPlease select one before continuing.");
		document.ChooseForm.plan[0].focus();
		return false;
	} else {
		return true;
	}
}

function validateSatSurvey() {
	if (Trim(document.form1.Name_of_physician_or_facility.value) == '') {
		alert("You must enter a physician or facility.\nPlease enter one before submitting.");
		document.form1.Name_of_physician_or_facility.value = '';
		document.form1.Name_of_physician_or_facility.focus();
		return false;
	}
	else {
		return true;
	}
}


/* Verify the deletion of a record used in the edit content section */
function verifyDeleteContent()	{
	var DontDelete = confirm('Do you really wish to delete this page?')
	if (!DontDelete) {
		return false;
	}
}



/* Other scripts used throughout the site */

function Trim(s) {
	// Remove leading spaces and carriage returns
  
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))	{
		s = s.substring(1,s.length);
	}

	// Remove trailing spaces and carriage returns

	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))	{
		s = s.substring(0,s.length-1);
	}

	return s;
}



/* Other scripts either not used or not yet used in the portion of the site that I've handled */

function validate()	{
	if (Trim(document.edit.first.value) == '' || Trim(document.edit.last.value) == '')	{
		alert("This record will not display properly without both a first name and a last name.\nPlease enter both a first name and a last name before submitting.");
		if (Trim(document.edit.first.value) == '') {
			document.edit.first.value = '';
			document.edit.first.focus();
			return false;
		}
		else {
			document.edit.last.value = '';
			document.edit.last.focus();
			return false;
		}
		return false;
	}
}



// This is the script that handles adding specialties to the specialty lists
function AddOption(SelectBox, promptString, MaxLen)  {
	// Define a new string
		var NewOpt = new String;
		NewOpt = "";
	
	// Prompt for the New Option and store it in NewOpt 
		do {
			NewOpt = prompt(promptString, NewOpt);
			if (NewOpt == null) return;
			if (NewOpt.length > MaxLen) {
				alert("You may not enter a value longer than " + MaxLen + " characters.");
			}
		} while (NewOpt.length > MaxLen);
		
	// If NewOpt is empty (no new option), then stop processing and make no changes
		if (NewOpt == null) return;
		NewOpt = Trim(NewOpt);
		if (NewOpt.length == 0) return;
		
	// If it gets here, NewSpec is *not* blank, so add it to the bottom of the specialty list SpecList
		NewOption = new Option(NewOpt, NewOpt);
		SelectBox.options[SelectBox.length] = NewOption;
	
	// Make the new option the Selected option
		SelectBox.options[SelectBox.length - 1].selected = true;
		SelectBox.focus();

	// Now return control to the user
		return;
}