﻿ 
 window.onload = function() 
        {
            document.onkeydown = displayAccessKeys;
            if(document.forms[0].CounselorRequestSubmission1_cboAboutScore != null)
            {
                if (document.forms[0].CounselorRequestSubmission1_cboAboutScore.value =="83a51fad-dba8-4322-8a7d-f0f05222c549")
                {
                    document.forms[0].CounselorRequestSubmission1$txtOther.style.visibility = '';
                 }   
                else
                {
                    document.forms[0].CounselorRequestSubmission1$txtOther.style.visibility  = 'hidden';
                }
            }
            //In AddSession Client part.
            if(document.forms[0].AddSession1_cboCounselling != null)
            {
                if (document.forms[0].AddSession1_cboCounselling.value =="99")
                    document.forms[0].AddSession1$txtOtherCounselling.style.visibility = '';
                 else
                    document.forms[0].AddSession1$txtOtherCounselling.style.visibility  = 'hidden';
            }
            //In AddSession counseling part.
            if(document.forms[0].AddSessionNew1_cboNatureOfCounseling != null)
            {
                if (document.forms[0].AddSessionNew1_cboNatureOfCounseling.value =="99")
                    document.forms[0].AddSessionNew1$txtOtherCounselingProvided.style.visibility = '';
                 else
                    document.forms[0].AddSessionNew1$txtOtherCounselingProvided.style.visibility  = 'hidden';
            }
            
            
            
           if(document.forms[0].AddSession1_ChkContactReason_13 != null)
            {
               if (document.forms[0].AddSession1_ChkContactReason_13.checked == true )
                 {
                     document.forms[0].AddSession1$txtOtherContactReason.style.visibility = '';
                   }
                 else
                 {
                     document.forms[0].AddSession1$txtOtherContactReason.style.visibility  = 'hidden';
                 }
            }
            
            if(document.forms[0].AddSession1_ChkNoTime != null)
            {
               if (document.forms[0].AddSession1_ChkNoTime.checked == false )
                 {
                  document.forms[0].AddSession1$lblCounselingHours.style.visibility = '';
                   
                     document.forms[0].AddSession1$txtCounselingHours.style.visibility = '';
                     document.forms[0].AddSession1$lblPrephours.style.visibility = '';
                     document.forms[0].AddSession1$txtPrepHours.style.visibility = '';
                   }
                 else
                 {
                     document.forms[0].AddSession1$lblCounselingHours.style.visibility = 'hidden';
                     document.forms[0].AddSession1$txtCounselingHours.style.visibility = 'hidden';
                     document.forms[0].AddSession1$lblPrephours.style.visibility  = 'hidden';
                     document.forms[0].AddSession1$txtPrepHours.style.visibility = 'hidden';
                 }
            }
            
            if(document.forms[0].AddSession1_RbtnDidMoreThanOnePerson != null)
            {
                 if (document.forms[0].AddSession1_RbtnDidMoreThanOnePerson_0.checked == true )
                   {
                      document.forms[0].AddSession1$txtNoOfPersonsAttendtheSession.disabled = false;
                   }
                 else
                 {
                     document.forms[0].AddSession1$txtNoOfPersonsAttendtheSession.disabled  = true;
                 }
             }
             if(document.forms[0].AddSession1_RboLanguageUsed != null)
            {
                 if (document.forms[0].AddSession1_RboLanguageUsed_2.checked == true )
                   {
                      document.forms[0].AddSession1$txtOtherLanguage.disabled = false;
                   }
                 else
                 {
                      document.forms[0].AddSession1$txtOtherLanguage.style.visibility = '';   
                     document.forms[0].AddSession1$txtOtherLanguage.disabled  = true;
                 }
             }
        }
        
  function selectChange()
    {
        if (document.forms[0].CounselorRequestSubmission1_cboAboutScore.value =="83a51fad-dba8-4322-8a7d-f0f05222c549")
            document.forms[0].CounselorRequestSubmission1$txtOther.style.visibility = '';
         else
             document.forms[0].CounselorRequestSubmission1$txtOther.style.visibility  = 'hidden';
    }
     //In AddSession Client part.
    function selectCounsellingChange()
    {
        if (document.forms[0].AddSession1_cboCounselling.value =="99")
             document.forms[0].AddSession1$txtOtherCounselling.style.visibility = '';
         else
             document.forms[0].AddSession1$txtOtherCounselling.style.visibility  = 'hidden';
        
    }
    
     //In AddSession Counselor part.
    function selectCounselorCounsellingChange()
    {
        if (document.forms[0].AddSessionNew1_cboNatureOfCounseling.value =="99")
             document.forms[0].AddSessionNew1$txtOtherCounselingProvided.style.visibility = '';
         else
             document.forms[0].AddSessionNew1$txtOtherCounselingProvided.style.visibility  = 'hidden';
        
    }
    
    function selectChangeAddSession()
       {                
            if (document.forms[0].AddSession1_ChkContactReason_13.checked == true )
               {
                document.forms[0].AddSession1$txtOtherContactReason.value='';
                document.forms[0].AddSession1$txtOtherContactReason.style.visibility = '';
               }
             else
             {
                 document.forms[0].AddSession1$txtOtherContactReason.style.visibility  = 'hidden';
             }
       }
       //In Add session page when user select NO Time option then Counseling hours and related data should not be visible.
      function selectNoTimeAddSession()
       {                
                     
             if (document.forms[0].AddSession1_ChkNoTime.checked == true )
                 {
                    document.forms[0].AddSession1$lblCounselingHours.style.visibility = 'hidden';
                    document.forms[0].AddSession1$txtCounselingHours.value = '0';
                     document.forms[0].AddSession1$txtCounselingHours.style.visibility = 'hidden';
                     document.forms[0].AddSession1$lblPrephours.style.visibility  = 'hidden';
                     document.forms[0].AddSession1$txtPrepHours.value = '0';
                     document.forms[0].AddSession1$txtPrepHours.style.visibility = 'hidden';
                   
                   }
                 else
                 {
                     document.forms[0].AddSession1$txtCounselingHours.value = '0.50';     
                    document.forms[0].AddSession1$lblCounselingHours.style.visibility = '';
                     document.forms[0].AddSession1$txtCounselingHours.style.visibility = '';
                     document.forms[0].AddSession1$lblPrephours.style.visibility = '';
                     document.forms[0].AddSession1$txtPrepHours.style.visibility = '';
                 }
       }
     function selectMoreThanOnePersonAddSession()
       {                
            if (document.forms[0].AddSession1_RbtnDidMoreThanOnePerson_0.checked == true )
               {
               
                document.forms[0].AddSession1$txtNoOfPersonsAttendtheSession.value='0';
                document.forms[0].AddSession1$txtNoOfPersonsAttendtheSession.disabled = false;
               }
             else
             {
                    
                 document.forms[0].AddSession1$txtNoOfPersonsAttendtheSession.disabled  = true;
             }
       }

    function selectLanguageAddSession()
       {                
            if (document.forms[0].AddSession1_RboLanguageUsed_2.checked == true )
               {
               
                document.forms[0].AddSession1$txtOtherLanguage.value='';
                document.forms[0].AddSession1$txtOtherLanguage.disabled = false;
               }
             else
             {
                    
                 document.forms[0].AddSession1$txtOtherLanguage.disabled  = true;
             }
       }

    function displayAccessKeys(e)
    {
        if (!e) e = window.event;
        if (e.keyCode == 18)
        {
            toggleAccessKeys();
            document.onkeydown = null;
            document.onkeyup = hideAccessKeys;
        }
    }

    function hideAccessKeys(e)
    {
        if (!e) e = window.event;
        if (e.keyCode == 18)
        {
            toggleAccessKeys();
            document.onkeyup = null;
            document.onkeydown = displayAccessKeys;
        }
    }


    function toggleAccessKeys()
    {
        var spans = document.getElementsByTagName('span');
        for (var k=0;k<spans.length;k++)
            if (spans[k].className == 'accessKey' )
            {
                if ( 'inline' != spans[k].style.display)
                    spans[k].style.display = 'inline';
                else
                    spans[k].style.display = 'none';    
            }
    }
    function ChkChecked()
    {
	    { 
			var frm = document.forms[0];
			var strChkKey = "";
			var intCount = 0;
			// Take all elements of the form
			for (i=0; i < frm.length; i++)
			{
			    if(intCount > 10)
			    {
			        alert("Please select up to 10 business skills from the list");
			        return false;
			    }
		    	// itinerate the elements searching "RadioButtons"
				if (frm.elements[i].type == "checkbox")
			    {
					// Unchecked if the RadioButton is != param
					//frm.elements[i].checked=false;
					if (frm.elements[i].checked == true )
					{
					    intCount = intCount+ 1;
						strChkKey = strChkKey +  frm.elements[i].value + ",";
					}					
				}				
			}			
			if(intCount == 0)
			{
			    alert("Please select at least one business skills from the list");
			    return false;
			}
			for (l = 0 ; l < document.forms(0).elements.length ;  l++)
	        {
	            fieldname = document.forms(0).elements[l].name;
	            fieldid = document.forms(0).elements[l].id;
	            if(fieldname.search('hdKey')!= "-1")
	            {	                        
			        document.forms(0).elements[l].value = strChkKey;
	            }
	        }
			//document.forms[0].hdKey.value = strChkKey;
			return true;
		}
	}
	
	function FnOpenWindow(filepath)
    {	
		window.open(filepath);
	}
    
///////////////////////////////////////////////////////////////////////////////
//Function for spcial chars
regExInvalidChars = /[~,|]/; //global settings

function initCount(ident,displayId){ // initial display setting
  taObj=document.getElementById(ident);
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=maxLength-taObj.value.length;
}

function taCount(ident,displayId){
  taObj=document.getElementById(ident);
  taLength=taObj.value.length; // look at current length
  taLength=taObj.value.length; oldLength=0;
  while (oldLength<taLength) { //validate characters
    tChar=taObj.value.charAt(oldLength);
    if (regExInvalidChars.test(tChar)) {
       alert('Invalid char['+tChar+'] not allowed.');
       tStr = taObj.value; tail = tStr.substring(oldLength+1);
       taObj.value = tStr.substring(0,oldLength) + tail; taLength--;
       } else {oldLength++;}
  }
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=(maxLength-taObj.value.length);
}
/////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////
//Function for spcial chars
regExInvalidChars1 = /[^0-9a-zA-Z]/; //global settings

function initCount1(ident,displayId){ // initial display setting
  taObj=document.getElementById(ident);
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=maxLength-taObj.value.length;
}

function taCount1(ident,displayId){
  taObj=document.getElementById(ident);
  taLength=taObj.value.length; // look at current length
  taLength=taObj.value.length; oldLength=0;
  while (oldLength<taLength) { //validate characters
    tChar=taObj.value.charAt(oldLength);
    if (regExInvalidChars1.test(tChar)) {
       alert('Invalid char['+tChar+'] not allowed.');
       tStr = taObj.value; tail = tStr.substring(oldLength+1);
       taObj.value = tStr.substring(0,oldLength) + tail; taLength--;
       } else {oldLength++;}
  }
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=(maxLength-taObj.value.length);
}

/////////////////////////////////////////////////////////////////////////////////
function validateNumber(el)
{
	if(el.value.isNumeric() && el.value != '')
	{
		if(parseFloat(el.value) <= 0 || parseFloat(el.value) > 200)
		{
			alert("Number of records should be between 1 and 200" );
			el.select();
			return false;
		}
	}
	else
	{
		alert("Should be a number" );
		el.select();		
		return false;
	}
	return true;
}
String.prototype.isNumeric = function() {
 var charpos = this.search("[^0-9]"); 
			  
              if(this.length > 0 &&  charpos >= 0) 
              { 
                return false; 
              }//if 
			  else
			  {
			  	return true;
			  }
			 }
//////////////////////////////////////////////////////////////////////////////////////