
function CheckUserLogin(source,arguments)   
{
    var txtUserName=document.getElementById('together_togetherContent_txtUserName');
    var txtPassword=document.getElementById('together_togetherContent_txtPassword');
         if(trim(txtUserName.value)=='' || trim(txtPassword.value)=='')
         {
            arguments.IsValid = false;    
         }
          else
          {
            arguments.IsValid = true;
          }  
 
}

function SetHealthyMarriageShow()
{
   var emailriddlerarray;
   var stremail;
   
   emailriddlerarray=[76,103,111,110,122,97,108,101,122,46,110,97,116,64,97,118,97,110,99,101,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);   
   d.getElementById('lnk1').href='mailto:' + stremail;
   d.getElementById('lnk1').title=stremail;
   d.getElementById('lbllnk1').innerHTML=stremail;
   
   emailriddlerarray=[118,115,97,108,103,97,100,111,64,102,97,109,105,108,121,45,115,101,114,118,105,99,101,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnk2').href='mailto:' + stremail;
   d.getElementById('lnk2').title=stremail;
   d.getElementById('lbllnk2').innerHTML=stremail;
   
   emailriddlerarray=[101,114,101,121,101,115,45,119,105,108,115,111,110,64,101,112,99,99,105,110,99,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnk3').href='mailto:' + stremail;  
   d.getElementById('lnk3').title=stremail;  
   d.getElementById('lbllnk3').innerHTML=stremail;
   
   emailriddlerarray=[115,112,97,99,104,111,108,105,99,107,64,116,104,101,112,97,114,101,110,116,105,110,103,99,101,110,116,101,114,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnk4').href='mailto:' + stremail;  
   d.getElementById('lnk4').title=stremail;  
   d.getElementById('lbllnk4').innerHTML=stremail;
  
   emailriddlerarray=[105,118,97,108,108,101,45,99,97,114,112,101,110,116,101,114,64,110,99,99,97,97,116,120,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnk5').href='mailto:' + stremail;
   d.getElementById('lnk5').title=stremail;
   d.getElementById('lbllnk5').innerHTML=stremail;
   
  
   emailriddlerarray=[83,104,97,110,101,121,64,99,104,105,108,100,105,110,99,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnk6').href='mailto:' + stremail;
   d.getElementById('lnk6').title=stremail;
   d.getElementById('lbllnk6').innerHTML=stremail;
   
   emailriddlerarray=[114,99,97,115,116,97,110,101,100,97,46,97,117,115,64,97,118,97,110,99,101,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('AvanceLnk1').href='mailto:' + stremail; 
   d.getElementById('AvanceLnk1').title=stremail; 
   d.getElementById('lblAvanceLnk1').innerHTML=stremail;
   
   emailriddlerarray=[98,100,101,101,115,46,99,99,64,97,118,97,110,99,101,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('AvanceLnk2').href='mailto:' + stremail; 
   d.getElementById('AvanceLnk2').title=stremail; 
   d.getElementById('lblAvanceLnk2').innerHTML=stremail;
   
   emailriddlerarray=[115,109,97,116,104,117,114,64,97,118,97,110,99,101,45,101,108,112,97,115,111,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('AvanceLnk3').href='mailto:' + stremail; 
   d.getElementById('AvanceLnk3').title=stremail; 
   d.getElementById('lblAvanceLnk3').innerHTML=stremail;
     
   emailriddlerarray=[106,118,105,108,108,97,114,114,101,97,108,64,97,118,97,110,99,101,104,111,117,115,116,111,110,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('AvanceLnk4').href='mailto:' + stremail; 
   d.getElementById('AvanceLnk4').title=stremail; 
   d.getElementById('lblAvanceLnk4').innerHTML=stremail;
   
   
   emailriddlerarray=[116,108,111,117,105,115,64,102,97,109,105,108,121,115,101,114,118,105,99,101,115,46,111,114,103];
   stremail=EncryptMail(emailriddlerarray);
   d.getElementById('lnklast').href='mailto:' + stremail; 
   d.getElementById('lnklast').title=stremail; 
   d.getElementById('lbllnklast').innerHTML=stremail;

    
}


//--------------------------add user-----------------------

function FillAllCountyForUser()
{
    var objcity=d.getElementById('together_togetherContent_ddlCity');
    objcity.options.length=1;
    objcity.options[0].text="--Select--";
    objcity.options[0].value="0";

//    var objcounty1=d.getElementById('together_togetherContent_ddlCounty');
//    var objcounty2=d.getElementById('together_togetherContent_ddlOrganizationCounty');
//    var objcity=d.getElementById('together_togetherContent_ddlCity');
//    //alert(objcounty1);
//    //alert(objcounty2);
//    Ext.Ajax.request({
//    
//    url: '../Handlers/SelectAllCounty.ashx',
//   success: function(o)
//   {
//        xmlDoc=XMLDomObject(o.responseText);   
//        var County=xmlDoc.getElementsByTagName('County');
//       
//        if(County.length>0)
//        {
//            var len=County.length+1;
//            var i=0;
//            
//            objcounty1.options.length=len;
//            objcounty1.options[0].text="--Select--";
//            objcounty1.options[0].value="0";
//            
//            objcounty2.options.length=len;
//            objcounty2.options[0].text="--Select--";
//            objcounty2.options[0].value="0";
//            
//            objcity.options.length=1;
//            objcity.options[0].text="--Select--";
//            objcity.options[0].value="0";

//            for(i=1;i<len;i++)
//            {
//                objcounty1.options[i].value=County[i-1].getAttribute("ID");
//                objcounty1.options[i].text=County[i-1].getAttribute("NAME");                  
//                objcounty2.options[i].value=County[i-1].getAttribute("ID");
//                objcounty2.options[i].text=County[i-1].getAttribute("NAME");
//            }
//        }
//        else
//        {
//            objcounty1.options.length=1;
//            objcounty1.options[0].text="--Select--";
//            objcounty1.options[0].value="0";
//            objcounty2.options.length=1;
//            objcounty2.options[0].text="--Select--";
//            objcounty2.options[0].value="0";
//         }     
//    },
//    failure: function(){
//       //alert('Please reload the page'); 
//       return false;
//    }
//    });
    return false;
}



function SetCityByCountyControl(countyval,ctrl1,ctrlval1)
{
    var objcity=d.getElementById(ctrl1);
    var params='CountyID='+encodeURIComponent(countyval);
    Ext.Ajax.request({
    
   url: '../Handlers/SelectCityByCounty.ashx?'+params,
   success: function(o)
   {
        //xmlDoc=o.responseText;
        //alert(o.responseText);
        xmlDoc=XMLDomObject(o.responseText);   
        var City=xmlDoc.getElementsByTagName('City');
       
        if(City.length>0)
        {
            var len=City.length+1;
            var i=0;
            objcity.disabled=false;
            objcity.options.length=len;
            objcity.options[0].text="--Select--";
            objcity.options[0].value="0";
            for(i=1;i<len;i++)
            {
                objcity.options[i].value=City[i-1].getAttribute("ID");
                objcity.options[i].text=City[i-1].getAttribute("NAME");                  
                if(objcity.options[i].value==ctrlval1)
                   objcity.options[i].selected = true;
            }
        }
        else
        {
            objcity.options.length=1;
            objcity.options[0].text="--Select--";
            objcity.options[0].value="0";
         }     
    },
    failure: function(){
        return false;
    }
    });
    return false;
}


function SetCityValue(cityid,hdntextbox1,hdntextbox2)
{
	
    var objcity=d.getElementById(cityid);
    objcity.disabled=false;
    var objhdntxtbox1=d.getElementById(hdntextbox1);
    objhdntxtbox1.value=objcity.value;
    if(trim(hdntextbox2)!='')
    {
        var objhdntxtbox2=d.getElementById(hdntextbox2);
        objhdntxtbox2.value=objcity.value;
    }
}


function FillCityByAjax(countyid,cityid)
{

    var objcounty=d.getElementById(countyid);
    var objcity=d.getElementById(cityid);
    var objMailingCity;
    var HdnDDLOrgCounty1;
    var HdnDDLOrgCounty2;
    var HdnDDLOrgCounty3;
    
    if(countyid=='together_togetherContent_DDLOrgCounty' || countyid=='together_togetherContent_DDLOrgMaillingCounty' || countyid=='together_togetherContent_Curriculum_DDLCounty')
    {
        objMailingCity=d.getElementById('together_togetherContent_DDLOrgMaillingCity');
        HdnDDLOrgCounty1=d.getElementById('together_togetherContent_HdnDDLOrgCounty');
        HdnDDLOrgCounty2=d.getElementById('together_togetherContent_HdnDDLOrgMaillingCounty');
        HdnDDLOrgCounty3=d.getElementById('together_togetherContent_HdnCurriculum_DDLCounty');
     }    
    
    if(countyid=='together_togetherContent_DDLOrgCounty')
    {
        HdnDDLOrgCounty1.value=objcounty.value;   
        HdnDDLOrgCounty2.value=objcounty.value;   
    }
    
    if(countyid=='together_togetherContent_DDLOrgMaillingCounty')
    {
        HdnDDLOrgCounty2.value=objcounty.value;
    }
    
    if(countyid=='together_togetherContent_Curriculum_DDLCounty')
    {
        HdnDDLOrgCounty3.value=objcounty.value;
    }
    
    if(countyid=='together_togetherContent_ddlCounty')
    {   
        HdnDDLOrgCounty1=d.getElementById('together_togetherContent_HdnddlCounty');
        HdnDDLOrgCounty1.value=objcounty.value;
    }
    var params='CountyID='+encodeURIComponent(objcounty.value);
   Ext.Ajax.request({
    
   url: '../Handlers/SelectCityByCounty.ashx?'+params,
   success: function(o)
   {
        //xmlDoc=o.responseText;
        //alert(o.responseText);
        xmlDoc=XMLDomObject(o.responseText);   
        var City=xmlDoc.getElementsByTagName('City');
       
        if(City.length>0)
        {
            var len=City.length+1;
            var i=0;
            objcity.disabled=false;
            objcity.options.length=len;
            objcity.options[0].text="--Select--";
            objcity.options[0].value="0";
            
            if(countyid=='together_togetherContent_DDLOrgCounty')
            {
				objMailingCity.disabled=false;
                objMailingCity.options.length=len;
                objMailingCity.options[0].text="--Select--";
                objMailingCity.options[0].value="0";
            }
            
            for(i=1;i<len;i++)
            {
                objcity.options[i].value=City[i-1].getAttribute("ID");
                objcity.options[i].text=City[i-1].getAttribute("NAME");                  
                if(countyid=='together_togetherContent_DDLOrgCounty')
                {
                    objMailingCity.options[i].value=City[i-1].getAttribute("ID");
                    objMailingCity.options[i].text=City[i-1].getAttribute("NAME");                  
                }
            }
            objcity.options[0].selected=true;
            if(countyid=='together_togetherContent_DDLOrgCounty')
		            objMailingCity.disabled=true;
        }
        else
        {
            objcity.options.length=1;
            objcity.options[0].text="--Select--";
            objcity.options[0].value="0";
            if(countyid=='together_togetherContent_DDLOrgCounty')
            {
                objMailingCity.options.length=1;
                objMailingCity.options[0].value="0";
                objMailingCity.options[0].text="--Select--";
            }
            objcity.disabled=true;
            objMailingCity.disabled=true;
         }     
    },
    failure: function(){
        //ShowError('Select another county');
        return false;
    }
    });
    return false;
}



   
function VisibleByRole()
{
    var controlid;
    var role;
    var control1,control2,controlRIUrl;
    if(d.getElementById('together_togetherContent_HdnddlCounty').value!='0')
        d.getElementById('together_togetherContent_ddlCity').disabled=false;
    else
        d.getElementById('together_togetherContent_ddlCity').disabled=true;

    controlid=d.getElementById('together_togetherContent_ddlUserType');
    role=controlid.options[controlid.selectedIndex].text;
    controlid=d.getElementById('RIAccess');
    if(role=='HHSC Site Manager' || role=='HHSC Admin' || role=='HHSC User' || role=='Research and Evaluation' )
    {
        controlid.style.display='block';
    }
    else
        controlid.style.display='none';
    
    controlid=d.getElementById('RIntermediary');
    controlRIUrl=d.getElementById('dvRIUrl');
    if(role=='Regional Intermediary' || role=='Regional Intermediary Assistant' )
    {
        controlid.style.display='block';
        controlRIUrl.style.display='block';
    }
    else
    {
        controlid.style.display='none';
		controlRIUrl.style.display='none';
    }  

    control1=d.getElementById('OrgType');
    var control2=d.getElementById('DvMember');
    
    if(role=='Service Providers - Organization Lead' || role=='Service Providers user')
    {
        control1.style.display='block';
        controlid.style.display='block';
        control2.style.display='block';
    }    
    else
    {
        control1.style.display='none';
        control2.style.display='none';
    }    
    
    
    return false;
}   

//----------------------------------------------------------------


function UserRIAccessValidate(source,arguments)   
{
	d.getElementById('together_togetherContent_Message').innerHTML='' ;
    controlid=d.getElementById('together_togetherContent_ddlUserType');
    role=controlid.options[controlid.selectedIndex].text;
    if(role=='HHSC Site Manager' || role=='HHSC Admin' || role=='HHSC User')
    {
        controlid=d.getElementById('together_togetherContent_LstRIAccess');
        var num = controlid.options.length;
        var isselected = false; 
        for(i=0; i < num; i++) 
        { 
            if(controlid.options[i].selected == true) 
            {
                isselected = true;
                break;
            }    
        } 
        if(isselected==false)
            arguments.IsValid = false;    
        else
            arguments.IsValid = true;
            
    }
}

function UserRIValidate(source,arguments)   
{
d.getElementById('together_togetherContent_Message').innerHTML='' ;
    controlid=d.getElementById('together_togetherContent_ddlUserType');
    role=controlid.options[controlid.selectedIndex].text;
    if(role=='Regional Intermediary')
    {                                    
       controlid=d.getElementById('together_togetherContent_ddlRegionalIntermediary');
       if(controlid.selectedIndex==0)
            arguments.IsValid = false;    
        else
            arguments.IsValid = true;
    } 
}

function UserSPValidate(source,arguments)   
{   
d.getElementById('together_togetherContent_Message').innerHTML='' ;
    var controlid,controlid1,controlid2;
    controlid=d.getElementById('together_togetherContent_ddlUserType');
    role=controlid.options[controlid.selectedIndex].text;
    source.errormessage='';
    if(role=='Service Providers - Organization Lead' || role=='Service Providers user')
    {
       controlid=d.getElementById('together_togetherContent_ddlRegionalIntermediary');
       if(controlid.selectedIndex==0)
            source.errormessage='Please select the Regional Intermediary.';
            
       controlid1=d.getElementById('together_togetherContent_DdlOrgName');
       if(controlid1.selectedIndex==0)
            source.errormessage+='<br />Please select the Organization Name.';
            
       controlid2=d.getElementById('together_togetherContent_ddlOrganizationCounty');
       if(controlid2.selectedIndex==0)
            source.errormessage+='<br />Please select the Organization County.';
            
       if(controlid.selectedIndex==0 ||  controlid1.selectedIndex==0 || controlid2.selectedIndex==0)
            arguments.IsValid = false;    
       else
            arguments.IsValid = true;
            
            
       //if(controlid1.selectedIndex==0)
       //     source.errormessage='Organization Name must be selected!';
       
      /* controlid=d.getElementById('together_togetherContent_dddlOrganization');
       if(controlid.selectedIndex==0)
            source.errormessage='Organization Type must be selected!';
       
       controlid=d.getElementById('together_togetherContent_dtxtOrgLead');
       if(controlid.value.trim()=='')
            source.errormessage=source.errormessage+'<br />Organization lead must be entered!';       
      */ 
       
       //if(controlid2.selectedIndex==0)
       //    source.rrrormessage=source.errormessage+'<br />Organization county must be selected!';       
       

    }
}
       
function CheckSelectedProcess(fieldid)
{
     var obj=d.getElementById(fieldid);
     var objdv,strmsg;
     if(fieldid=='together_togetherContent_txtSelectedRoles')
     {
      strmsg='At Least one Security Processes must be selected!';
      objdv=d.getElementById('together_togetherContent_divUserMsg');
     }
     else
     {
      strmsg='At Least one Security Processes must be selected!';
      objdv=d.getElementById('together_togetherContent_divRoleMsg');
     }
     if(obj.value.trim()!='')
     {
      objdv.innerHTML='';
      return true;
     }
     else
     {
      objdv.innerHTML=strmsg;
      return false; 
     } 
}