﻿
function BrokerFormRequiredField_ClientValidate(sender, args)
{
    args.IsValid = requiredFieldValidate(args.Value, azblue.aspxControls.groupBrokerRadio[0]);
}

function GroupFormRequiredField_ClientValidate(sender, args)
{
    args.IsValid = requiredFieldValidate(args.Value, azblue.aspxControls.groupBrokerRadio[1]); 
}

function clearGroupTextFields()
{
    groupFields = azblue.aspxControls.groupTable.getElementsByTagName("input");
    
    for (var i = 0 ; i < groupFields.length ; i++)
    {
         groupFields[i].value = "" ;
    }
}

function clearBrokerTextFields()
{
    brokerFields = azblue.aspxControls.brokerTable.getElementsByTagName("input") ;
    
    for (var i = 0 ; i < brokerFields.length ; i++)
    {
       brokerFields[i].value = "" ;
    }

}

function SuppliesRequest_ClientValidate(sender, args)
{
   
    BluePreferredQtyDDL = azblue.aspxControls.BluePreferredQtyDDL ;
    BluePreferredDDL = azblue.aspxControls.BluePreferredDDL;
    BlueSelectQtyDDL = azblue.aspxControls.BlueSelectQtyDDL;
    BlueSelectDDL = azblue.aspxControls.BlueSelectDDL;
    DentalChoiceQtyDDL = azblue.aspxControls.DentalChoiceQtyDDL;
    DentalChoiceDDL = azblue.aspxControls.DentalChoiceDDL;
    DentalPlusQtyDDL = azblue.aspxControls.DentalPlusQtyDDL;
    DentalPlusDDL = azblue.aspxControls.DentalPlusDDL;
    ProviderDirectoriesQtyDDL = azblue.aspxControls.ProviderDirectoriesQtyDDL;
    ProviderDirectoriesDDL = azblue.aspxControls.ProviderDirectoriesDDL;
    
    args.IsValid =(BluePreferredQtyDDL.selectedIndex > 0 && BluePreferredDDL.selectedIndex > 0) ||
                  (BlueSelectQtyDDL.selectedIndex > 0 && BlueSelectDDL.selectedIndex > 0) ||
                  (DentalChoiceQtyDDL.selectedIndex > 0  && DentalChoiceDDL.selectedIndex > 0) ||
                  (DentalPlusQtyDDL.selectedIndex > 0 && DentalPlusDDL.selectedIndex > 0) ||
                  (ProviderDirectoriesQtyDDL.selectedIndex > 0 && ProviderDirectoriesDDL.selectedIndex > 0);
}

function requiredFieldValidate(value, relatedRadio)
{
    var result ;
    if (relatedRadio.checked)
    {
        if (trim(value) == "")
        {
            result = false ;
        }
        else
        {
            result = true ;
        }
    }
    else
    {
        result = true ;
    }
    
    return result ;
}

function trim(someStr)
{
	if (someStr == "") return "";
	return someStr.replace(/^\s*(\S*)\s*$/,"$1");
}


function groupBrokerRadio_onclick()
{
    if (azblue.aspxControls.groupBrokerRadio[0].checked)
    {
        clearGroupTextFields();
        ShowControl(azblue.aspxControls.brokerDiv, true);
        ShowControl(azblue.aspxControls.groupDiv, false );
    }
    else
    {   clearBrokerTextFields();
        ShowControl(azblue.aspxControls.brokerDiv, false);
        ShowControl(azblue.aspxControls.groupDiv, true);
    }  
}

function ShowControl(control, show)
{
   if (show) {
        control.style.display = "block";
   } else {
        control.style.display = "none" ;  
   }
}

function test()
{
        azblue.aspxControls.brokerNumberTxt.value = "78909"
        azblue.aspxControls.brokerLastNameTxt.value = "Allen" 
        azblue.aspxControls.brokerFirstNameTxt.value = "James"
        azblue.aspxControls.brokerAttentionTxt.value = "Jake McLaughlin"
        azblue.aspxControls.brokerAddressTxt.value = "289, Parkway Ave"
        azblue.aspxControls.brokerCityTxt.value =  "Tempe"	
        azblue.aspxControls.brokerStateTxt.value = "AZ"
        azblue.aspxControls.brokerZipTxt.value = "87675"
        azblue.aspxControls.brokerPhoneTxt.value = "480-879-8907"
        azblue.aspxControls.brokerEmailTxt.value = "jakem@gmail.com"
        azblue.aspxControls.brokerEffectiveDateTxt.value = "2007-02-31"
        azblue.aspxControls.brokerGroupNumberTxt.value = "24345"

        azblue.aspxControls.groupNumberTxt.value = "34323"
        azblue.aspxControls.groupNameTxt.value = "Guerta"
        azblue.aspxControls.groupEffectiveDateTxt.value = "2002-02-21"
        azblue.aspxControls.groupRequestorNameTxt.value = "George Crow"
        azblue.aspxControls.groupAddress1Txt.value = "122, W. Ash Ave"
        azblue.aspxControls.groupCityTxt.value = "Tempe"
        azblue.aspxControls.groupStateTxt.value = "AZ"
        azblue.aspxControls.groupZipTxt.value = "85281"
        azblue.aspxControls.groupPhoneTxt.value = "623-309-8909"
        azblue.aspxControls.groupEmailTxt.value = "george.crow@hotmail.com"
}