
// Validate Zip Code
function validateMLogin (txtMLogin, txtZipCode) {

	// set var radio_choice to false
	var CheckVal = false;

	//if (document.frmLogin.txtMLogin.value.length > 0 ) {
	if (txtMLogin.value.length > 0 ) {
		//set the Hidden field value based on the Button Click
		// document.frmLogin.CheckSubmit.value = "SbmtMLogin"
		//document.frmLogin.submit()
		CheckVal = true;
	}


	if (!CheckVal)
	{
		// If there were no selections made display an alert box
		alert("Please enter a valid Member Login.")
		return (false);
	}


	//if (document.frmLogin.txtZipCode.value.length == 5) {
	if (txtZipCode.value.length == 5) {
		//set the Hidden field value based on the Button Click
		// document.ProviderList.CheckSubmit.value = "SbmtZC"
		//document.ProviderList.submit()
		return (true);
	}
	else {
		//ProviderList.lblZipCode.style.visibility == 'visible';

		alert("Please enter a valid Five digit Zip Code!")
		return (false);
	}

	//If a Memberid and zipcode is entered then submit the page
	//if (CheckVal)
	//{
		//document.frmLogin.CheckSubmit.value = "SbmtMLogin"
		//document.frmLogin.submit()
	//}

	return (true);


}

// Validate Promo Code
function validatePCode (TxtPC) {

	//if (document.frmPromoCode.TxtPC.value.length > 0) {
	if (TxtPC.value.length > 0) {
		//set the Hidden field value based on the Button Click
		//document.frmPromoCode.CheckSubmit.value = "SbmtPC"
		//document.frmPromoCode.submit()
		return true;
	}
	else {
		alert("Please enter a valid  Promo Code!");
		return false;
	}
}


// Validate Zip Code
function validateZipCode () {

	if (document.ProviderList.txtZipCode.value.length == 5) {
		//set the Hidden field value based on the Button Click
		// document.ProviderList.CheckSubmit.value = "SbmtZC"
		//document.ProviderList.submit()
	}
	else {
		//ProviderList.lblZipCode.style.visibility == 'visible';

		alert("Please enter a valid Five digit Zip Code!")
		return (false);
	}
}




// Validate validateProviderZipCode
function validateProviderZipCode () {

	var strTxtZC=document.frmproviderLst.TxtZC.value.length;

	if (strTxtZC == 5) {
		//set the Hidden field value based on the Button Click
		document.frmproviderLst.CheckSubmit.value = "SbmtProviderList"
		//top.location.href="//http://search1.bestbenefits.com/scripts/provsrch.dll?Zip=" & strZipCode & "&Products=" & strProduct & "&Title=healthplanextras.com";
		document.frmproviderLst.submit()
	}
	else {
		//ProviderList.lblZipCode.style.visibility == 'visible';

		alert("Please enter a valid Five digit Zip Code!")
		//document.frmproviderLst.TxtZC.focus();
		return false ;
	}
}



function getSelectedRadio(buttonGroup) {
	// returns the array number of the selected radio button or -1 if no button is selected
	if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
		for (var i=0; i<buttonGroup.length; i++) {
		    if (buttonGroup[i].checked) {
		    return i
		    }
		}
	} else {
		if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
	}
	// if we get to this point, no radio button is selected
	return -1;
} // Ends the "getSelectedRadio" function



function getSelectedRadioValue(buttonGroup) {
	// returns the value of the selected radio button or "" if no button is selected
	var i = getSelectedRadio(buttonGroup);
	if (i == -1) {
		return "";
	} else {
		if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
		    return buttonGroup[i].value;
		} else { // The button group is just the one button, and it is checked
		    return buttonGroup.value;
		}
	}
} // Ends the "getSelectedRadioValue" function



// Validation for Network radio button and zipcode textbox in  ProvidersList page.
function Validate_ProviderListPage(frm)	{
	// set var radio_choice to false
	var radio_choice = false;



// not working for single radio button 7/27/2005
	// Loop from zero to the one minus the number of radio button selections
//	for (counter = 0; counter <=document.ProviderList.rdNetworkList.length; counter++)
//	{
//		// If a radio button has been selected it will return true
//		// (If not it will return false)
//		if (ProviderList.rdNetworkList[counter].checked)
//			radio_choice = true;
//	}


	//Code added on 7/27/2005 to make it work for single radio button
	var j=0;
	var radio_buttons = new Array();
	var the_form = window.document.forms[0];

	for(var i=0; i<the_form.length; i++) {
		var temp = the_form.elements[i].type;
		if((temp == "radio") && (the_form.elements[i].checked)) {
				radio_buttons[j] = the_form.elements[i].value; j++;
		}

		for(var k=0; k<radio_buttons.length; k++) {
			radio_choice = true;
		}
	}


	if (!radio_choice)
	{
		// If there were no selections made display an alert box
		alert("Please select a Provider.")
		return (false);
	}

	//validate  zipcode
	if (document.ProviderList.txtZipCode.value.length == 5) {

			//document.ProviderList.submit()
		}
		else {
			//ProviderList.lblZipCode.style.visibility == 'visible';

			alert("Please enter a valid Five digit Zip Code")
			return (false);
	}



	//If a radio button is selected then submit the page
	if (radio_choice)
	{
		document.ProviderList.CheckSubmit.value = "SbmtProvider"
		document.ProviderList.submit()
	}

	return (true);
}



function OrderOpenWin(win){
	window.open(win,'myWindow','left=20,top=20,width=850,height=600,toolbar=0,resizable=0,scrollbars=1');
}

function CloseWin(){
	window.close();
}
