﻿function contactRadio_OnClick(sender,args)
{   
    ShowControl(azblue.aspxControls.lblConfirmation, false);
    
    document.getElementById('ctl00_ColumnThreeContent_nameRegexValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_emailAddressTxtCustomValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_emailAddressTxtRegexValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_phoneNumberTxtRegexValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_phoneNumberTxtValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_streetAddressTxtCustomVldtr').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_cityCustomValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_cityRegexValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_stateCustomValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_stateRegexValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_zipCustomValidator').style.display = "none" ;
    document.getElementById('ctl00_ColumnThreeContent_zipRegexValidator').style.display = "none" ;
    var radio = azblue.aspxControls.contactRadio ;
   if (radio[0].checked == true){
      ResetFormFields();      
      ShowEmail(false);
      ShowStreet(false);
      ShowPhone(true); 
   } else if (radio[1].checked == true ) {
      ResetFormFields();
      ShowPhone(false);
      ShowStreet(false);
      ShowEmail(true);      
   } else if (radio[2].checked == true) {
      ResetFormFields();
      ShowPhone(false);
      ShowEmail(false);
      ShowStreet(true);
   }
}
 


function ShowControl(control, show)
{
    if (control!=null)
    {
        if (show) {
            control.style.display = "block";
            //control.style.visibility = "visible";
        } else {
            control.style.display = "none" ;  
            //control.style.visibility = "hidden";
        }
    }
}

function ResetFormFields()
{
    azblue.aspxControls.phoneNumberTxt.value = "" ;
    azblue.aspxControls.emailAddressTxt.value = "" ;
    azblue.aspxControls.streetAddressTxt.value = "" ;
    azblue.aspxControls.cityTxt.value = "" ;
    azblue.aspxControls.stateTxt.value = "" ;
    azblue.aspxControls.zipTxt.value = "" ;
}



function ShowPhone(show)
{
    ShowControl(azblue.aspxControls.phoneNumberTxtRow, show);
}

function ShowEmail(show)
{
    ShowControl(azblue.aspxControls.emailAddressTxtRow, show);
}

function ShowStreet(show)
{
    ShowControl(azblue.aspxControls.streetAddressTxtRow, show);
    //ShowControl(azblue.aspxControls.cityStateZipTxtRow, show);
    //ShowControl(azblue.aspxControls.cityValidatorRow, show);
    //ShowControl(azblue.aspxControls.stateValidatorRow, show);
    //ShowControl(azblue.aspxControls.zipValidatorRow, show);
}

function phoneNumberTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.phoneNumberTxt, radio[0]);
//    if (radio[0].checked)
//    {
//        if (azblue.aspxControls.phoneNumberTxt.value == "")
//        {
//            args.IsValid = false ;
//        }
//        else
//        {
//            args.IsValid = true ;
//        }
//    }
//    else
//    {
//        args.IsValid = true ;
//    }   
}

function emailAddressTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.emailAddressTxt, radio[1]);
}

function streetAddressTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.streetAddressTxt, radio[2]);
}

function cityTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.cityTxt, radio[2]);
}

function stateTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.stateTxt, radio[2]);
}

function zipTxt_ClientValidate(sender, args)
{
    var radio = azblue.aspxControls.contactRadio ;
    args.IsValid = requiredFieldValidate(azblue.aspxControls.zipTxt, radio[2]);
}

function requiredFieldValidate(textField, relatedRadio)
{
    var result ;
    if (relatedRadio.checked)
    {
        if (trim(textField.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 GoToPlan(list)
 {
    
    var divs = [$('plan1'),$('plan2'),$('plan3')];
    
    for (var i = 0; i < divs.length; i++)
    {
      if (divs[i] != null)
         divs[i].style.display = "none";
    }
    
     if(list.options[list.selectedIndex].value == 'Plans for FEP')
     {
     
       list.selectedIndex = 0;
        window.location.href=("http://www.fepblue.org");
     }
    
    if (divs[list.selectedIndex] != null)
       divs[list.selectedIndex].style.display = "block";       
         
 }