function checked_unchecked_counselor_search(val){document.getElementById("type_counseling").value = val;if(document.getElementById("type_counseling").value == 'in_person'){document.getElementById('in_person2').style.display = 'block';document.getElementById('phone1').style.display = 'block';document.getElementById('email1').style.display = 'block';document.getElementById('text_chat1').style.display = 'block';document.getElementById('video_chat1').style.display = 'block';document.getElementById('in_person1').style.display = 'none';document.getElementById('phone2').style.display = 'none';document.getElementById('email2').style.display = 'none';document.getElementById('text_chat2').style.display = 'none';document.getElementById('video_chat2').style.display = 'none';}else if(document.getElementById("type_counseling").value == 'phone'){document.getElementById('phone2').style.display = 'block';document.getElementById('email1').style.display = 'block';document.getElementById('text_chat1').style.display = 'block';document.getElementById('video_chat1').style.display = 'block';document.getElementById('in_person1').style.display = 'block';document.getElementById('phone1').style.display = 'none';document.getElementById('email2').style.display = 'none';document.getElementById('text_chat2').style.display = 'none';document.getElementById('video_chat2').style.display = 'none';document.getElementById('in_person2').style.display = 'none';}else if(document.getElementById("type_counseling").value == 'email'){document.getElementById('email2').style.display = 'block';document.getElementById('phone1').style.display = 'block';document.getElementById('text_chat1').style.display = 'block';document.getElementById('video_chat1').style.display = 'block';document.getElementById('in_person1').style.display = 'block';document.getElementById('phone2').style.display = 'none';document.getElementById('email1').style.display = 'none';document.getElementById('text_chat2').style.display = 'none';document.getElementById('video_chat2').style.display = 'none';document.getElementById('in_person2').style.display = 'none';}else if(document.getElementById("type_counseling").value == 'text_chat'){document.getElementById('text_chat2').style.display = 'block';document.getElementById('phone1').style.display = 'block';document.getElementById('email1').style.display = 'block';document.getElementById('video_chat1').style.display = 'block';document.getElementById('in_person1').style.display = 'block';document.getElementById('phone2').style.display = 'none';document.getElementById('email2').style.display = 'none';document.getElementById('text_chat1').style.display = 'none';document.getElementById('video_chat2').style.display = 'none';document.getElementById('in_person2').style.display = 'none';}else if(document.getElementById("type_counseling").value == 'video_chat'){document.getElementById('video_chat2').style.display = 'block';document.getElementById('phone1').style.display = 'block';document.getElementById('email1').style.display = 'block';document.getElementById('text_chat1').style.display = 'block';document.getElementById('in_person1').style.display = 'block';document.getElementById('phone2').style.display = 'none';document.getElementById('email2').style.display = 'none';document.getElementById('text_chat2').style.display = 'none';document.getElementById('video_chat1').style.display = 'none';document.getElementById('in_person2').style.display = 'none';}return true;}
function checking_textbox_counselor_search(){if(document.getElementById("type_counseling").value == 'in_person'){if(document.getElementById("text_box").value == ""){alert('Please enter zip code !');return false;}}return true;}
function checking_user_textbox(){if(document.getElementById("type_counseling_in_person").checked == true){if(document.getElementById("text_box").value == ""){alert('Please enter zip code !');return false;}}return true;}
function login_slide_panel(id){
    if (id == 1){
        document.getElementById('close').style.display = 'block';document.getElementById('close1').style.display = 'block';document.getElementById('open').style.display = 'none';document.getElementById('open1').style.display = 'none';
    }else{
        document.getElementById('close').style.display = 'none';document.getElementById('close1').style.display = 'none';document.getElementById('open').style.display = 'block';document.getElementById('open1').style.display = 'block';
    }
}
function counselor_agreement(){
    if(document.getElementById('term_cond').checked == false){
        alert("Please read terms and Conditions");return false;
    }if(document.getElementById('privacy_policy').checked == false){
        alert("Please read Privacy and Policy");return false;
    }if(document.getElementById('agreement').checked == false){
        alert("Please read Agrement");return false;
    }return true;
}
function appointment_agreement(){
    if(document.getElementById('term_cond').checked == false){
        alert("Please read terms and Conditions");return false;
    }if(document.getElementById('privacy_policy').checked == false){
        alert("Please read Privacy and Policy");return false;
    }if(document.getElementById('agreement').checked == false){
        alert("Please read Agrement");return false;
    }document.appointment.submit();return true;
}
function onclick_submit(){
    document.appointment.submit();return true;
}
function fil_upload(){
    if(document.getElementById('resource_type').value == 'Article'){
        document.getElementById('article').style.display = 'block';document.getElementById('audio').style.display = 'none';document.getElementById('video').style.display = 'none';
    }if(document.getElementById('resource_type').value == 'Audio'){
        document.getElementById('article').style.display = 'none';document.getElementById('audio').style.display = 'block';document.getElementById('video').style.display = 'none';
    }if(document.getElementById('resource_type').value == 'Video'){
        document.getElementById('article').style.display = 'none';document.getElementById('audio').style.display = 'none';document.getElementById('video').style.display = 'block';
    }
}
function unhide(data){
    if(document.getElementById(data).style.display=='none'){
        document.getElementById(data).style.display="block";
    }else{
        if(document.getElementById(data).style.display=='block'){
            document.getElementById(data).style.display='none'
        }
    }
}
function fees_support_group_enable(){
    document.getElementById('fee_amount').disabled = false;return true;
}
function fees_support_group_disable(){
    document.getElementById('fee_amount').value = '';document.getElementById('fee_amount').disabled = true;return true;
}
function agreement(){
    if(document.getElementById('terms').checked == false){
        alert('Please read agreement');return false;
    }return true;
}
function type_of_display(){
    document.getElementById('type_of').style.display = 'block';document.getElementById('schedule_appointment').style.display = 'block';document.getElementById('purchase_email_appointment').style.display = 'none';document.getElementById('immidiate_appointment').style.display = 'none';return true;
}
function type_of_hide(){
    document.getElementById('type_of').style.display = 'none';document.getElementById('schedule_appointment').style.display = 'none';document.getElementById('purchase_email_appointment').style.display = 'block';document.getElementById('immidiate_appointment').style.display = 'none';return true;
}
function display_counselor_prefered_date(){
    document.getElementById('counselor_prefered_date').style.display = 'block';return true;
}
function both_hide(){
    document.getElementById('immidiate_appointment').style.display = 'block';document.getElementById('schedule_appointment').style.display = 'none';document.getElementById('purchase_email_appointment').style.display = 'none';document.getElementById('type_of').style.display = 'none';return true;
}
function contact_us(){
    if(document.getElementById('contact_us_name').value == ''){
        alert('Please Enter Your Name');document.getElementById('contact_us_name').focus();return false;
    }if(document.getElementById('contact_us_email').value == ''){
        alert('Please Enter Your Email');document.getElementById('contact_us_email').focus();return false;
    }if(document.getElementById('contact_us_message').value == ''){
        alert('Please Enter Message');document.getElementById('contact_us_message').focus();return false;
    }if(ValidateForm()==false){
        return false;
    }if(ValidateForm()==true){
        return true;
    }return true;
}
function echeck(str){
    var at="@";var dot=".";var lat=str.indexOf(at);var lstr=str.length;var ldot=str.indexOf(dot);if (str.indexOf(at)==-1){
        alert("Invalid E-mail ID");return false;
    }if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        alert("Invalid E-mail ID");return false;
    }if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Invalid E-mail ID");return false;
    }if (str.indexOf(at,(lat+1))!=-1){
        alert("Invalid E-mail ID");return false;
    }if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        alert("Invalid E-mail ID");return false;
    }if (str.indexOf(dot,(lat+2))==-1){
        alert("Invalid E-mail ID");return false;
    }if (str.indexOf(" ")!=-1){
        alert("Invalid E-mail ID");return false;
    }return true;
}
function ValidateForm(){
    var emailID=document.getElementById('contact_us_email');if (echeck(emailID.value)==false){
        emailID.value = "";emailID.focus();return false;
    }return true;
}
function topic_jump(){
    window.location.href='/topics/view_topic?id='+document.getElementById('topic_id').value;
}
function openlogin(){
    document.getElementById('toppanel').style.display = 'block';document.getElementById('panel').style.display = 'block';
}
function change_password(){
    if(document.getElementById('current_password').value == ''){
        alert('Please Enter Your Current Password');document.getElementById('current_password').focus();return false;
    }if(document.getElementById('password').value == ''){
        alert('Please Enter Your New Password');document.getElementById('password').focus();return false;
    }if(document.getElementById('password_confirmation').value == ''){
        alert('Please Re-enter your New Password');document.getElementById('password_confirmation').focus();return false;
    }return true;
}
function fees(){
    if (document.getElementById("support_group_fees_true").checked == true){
        if (document.getElementById('fee_amount').value == ''){
            alert("Please enter Fee Amount.");return false;
        }if (isNumeric(document.getElementById('fee_amount').value) == false){
            alert('Please type Amount as numeric in Fee');document.getElementById('fee_amount').focus();return false;
        }
    }if(document.getElementById('terms').checked == false){
        alert('Please read agreement');return false;
    }return true;
}
function isNumeric(value){
    if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;return true;
}
function appointment_agreement_schedule(){
    if(document.getElementById('term_cond').checked == false){
        alert("Please read terms and Conditions");return false;
    }if(document.getElementById('privacy_policy').checked == false){
        alert("Please read Privacy and Policy");return false;
    }if(document.getElementById('agreement').checked == false){
        alert("Please read Agrement");return false;
    }document.appointment.submit();onclick_submit();return true;
}
function validateAllTopic(){
    if(! hasASelection('ad[topic_ids][]')){
        alert("Please select atleast one Topic !");return false;
    }return true;
}
function hasASelection(groupName){
    var elms = document.getElementsByName(groupName);for(var k=0, elm;elm=elms[k];k++)if(elm.checked) return true;return false;
}
// Password strength JS start
var m_strUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";var m_strLowerCase = "abcdefghijklmnopqrstuvwxyz";var m_strNumber = "0123456789";var m_strCharacters = "!@#$%^&*?_~"
function checkPassword(strPassword)
{
    var nScore = 0;
    if (strPassword.length < 6)
    {nScore += 5;}
    else if (strPassword.length > 5 && strPassword.length < 8)
    {nScore += 10;}
    else if (strPassword.length > 7)
    {nScore += 25;}
    var nUpperCount = countContain(strPassword, m_strUpperCase);
    var nLowerCount = countContain(strPassword, m_strLowerCase);
    var nLowerUpperCount = nUpperCount + nLowerCount;
    if (nUpperCount == 0 && nLowerCount != 0){nScore += 10;}
    else if (nUpperCount != 0 && nLowerCount != 0){nScore += 20;}
    var nNumberCount = countContain(strPassword, m_strNumber);
    if (nNumberCount == 1){nScore += 10;}
    if (nNumberCount >= 3){nScore += 20;}
    var nCharacterCount = countContain(strPassword, m_strCharacters);
    if (nCharacterCount == 1){nScore += 10;}
    if (nCharacterCount > 1){nScore += 25;}
    if (nNumberCount != 0 && nLowerUpperCount != 0){nScore += 2;}
    if (nNumberCount != 0 && nLowerUpperCount != 0 && nCharacterCount != 0){nScore += 3;}
    if (nNumberCount != 0 && nUpperCount != 0 && nLowerCount != 0 && nCharacterCount != 0){nScore += 5;}
    return nScore;
}
function runPassword(strPassword, strFieldID)
{
    var nScore = checkPassword(strPassword);
    var ctlText = document.getElementById(strFieldID + "_text");
    if (!ctlText)
        return;
    if (nScore >= 90 && strPassword.length > 5)
    {
        var strText = "Very secure";
        document.getElementById("mypassword_bar_1").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_2").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_3").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_4").style.backgroundColor = "#4ae817";
    }
    else if (nScore >= 60 && nScore < 90 && strPassword.length > 5)
    {
        var strText = "Secure";
        document.getElementById("mypassword_bar_1").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_2").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_3").style.backgroundColor = "#4ae817";
        document.getElementById("mypassword_bar_4").style.backgroundColor = "white";
    }
    else if (nScore >= 25 && nScore < 60 && strPassword.length > 5)
    {
        var strText = "Weak";
        document.getElementById("mypassword_bar_1").style.backgroundColor = "yellow";
        document.getElementById("mypassword_bar_2").style.backgroundColor = "yellow";
        document.getElementById("mypassword_bar_3").style.backgroundColor = "white";
        document.getElementById("mypassword_bar_4").style.backgroundColor = "white";
    }
    else if (nScore < 25 && strPassword.length > 5)
    {
        var strText = "Too short";
        document.getElementById("mypassword_bar_1").style.backgroundColor = "red";
        document.getElementById("mypassword_bar_2").style.backgroundColor = "white";
        document.getElementById("mypassword_bar_3").style.backgroundColor = "white";
        document.getElementById("mypassword_bar_4").style.backgroundColor = "white";
    }
    else
    {
        var strText = "Too short";
        document.getElementById("mypassword_bar_1").style.backgroundColor = "red";
        document.getElementById("mypassword_bar_2").style.backgroundColor = "white";
        document.getElementById("mypassword_bar_3").style.backgroundColor = "white";
        document.getElementById("mypassword_bar_4").style.backgroundColor = "white";
    }ctlText.innerHTML = "<span style='font:bold 12px Verdana;'>" + strText + "</span>";
}
function countContain(strPassword, strCheck){
    var nCount = 0;for (i = 0; i < strPassword.length; i++){
        if (strCheck.indexOf(strPassword.charAt(i)) > -1){
            nCount++;
        }
        }return nCount;
}
// Password strength JS end
function Pager(tableName, itemsPerPage){
    this.tableName = tableName;this.itemsPerPage = itemsPerPage;this.currentPage = 1;this.pages = 0;this.inited = false;
    this.init = function(){
        var rows = document.getElementById(tableName).rows;var records = (rows.length);this.pages = Math.ceil(records / itemsPerPage);this.inited = true;
    }
    this.showPageNav = function(pagerName, positionId){
        if (! this.inited){
            alert("not inited");return;
        }var element = document.getElementById(positionId);var pagerHtml = '<span onclick="' + pagerName + '.prev();" class="pg-normal"> &#171 Prev </span> | ';for (var page = 1; page <= this.pages; page++){
            pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + page + '</span> | ';
        }pagerHtml += '<span onclick="'+pagerName+'.next();" class="pg-normal"> Next &#187;</span>';element.innerHTML = pagerHtml;
    }
    this.showPage = function(pageNumber){
        if (! this.inited){
            alert("not inited");return;
        }var oldPageAnchor = document.getElementById('pg'+this.currentPage);oldPageAnchor.className = 'pg-normal';this.currentPage = pageNumber;var newPageAnchor = document.getElementById('pg'+this.currentPage);newPageAnchor.className = 'pg-selected';var from = (pageNumber - 1) * itemsPerPage;var to = from + itemsPerPage - 1;this.showRecords(from, to);
    }
    this.showRecords = function(from, to){
        var rows = document.getElementById(tableName).rows;for (var i = 0; i < rows.length; i++){
            if (i < from || i > to){
                rows[i].style.display = 'none';
            }else{
                rows[i].style.display = '';
            }
        }
    }
    this.prev = function(){
        if (this.currentPage > 1){
            this.showPage(this.currentPage - 1);
        }
    }
    this.next = function(){
        if (this.currentPage < this.pages){
            this.showPage(this.currentPage + 1);
        }
    }
}
function valid_article(){
    if((document.getElementById('keyword').value == '') && (document.getElementById('srch_date').value == '')){
        alert('Please Enter Eiher Keyword or Date');return false;
    }return true;
}
function HandleOnClose(evt){
    if (currentElement == "" || (!(currentElement.getAttribute("tag")=="DonotCallSaveonLoad"))){
        var objconfirm = confirm("Would you like to save changes made?");if (objconfirm == true) {
            alert('yes');
        }
    }
}
function FunctiontoCallSaveData(){
    document.getElementById("<%=hdtoSaveData.ClientID %>").value="PageClosed";document.form1.submit();
}
function frm_submit(){
    document.topic_srch.submit();return true;
}
function checkEnter(e){
    var characterCode;if(e && e.which){
        e = e;characterCode = e.which;
    }else{
        e = event;characterCode = e.keyCode;
    }if(characterCode == 13){
        if(document.getElementById('topics').value == ''){
            alert('Please enter value in Search box');return false;
        }
    }else{
        return true;
    }
}
function validate_free_video(form){
    var check = 0;var pass = true;if(! hasASelection('free_video[topic_ids][]')){
        alert("Please select at least one topic !");pass = false;check = 1;
    }return pass;
}
function create_video_validate(form){
    var check = 0;var pass = true;if(! hasASelection('resource[topic_ids][]')){
        alert("Please select at least one topic !");pass = false;check = 1;
    }if(document.getElementById('resource_uploaded_data').value == '' && check == 0){
        alert('Please Select Video');return false;
    }return pass;
}
function create_audio_validate(form){
    var check = 0;var pass = true;if(! hasASelection('resource[topic_ids][]')){
        alert("Please select at least one topic !");pass = false;check = 1;
    }if(document.getElementById('resource_uploaded_data').value == '' && check == 0){
        alert('Please Select Audio');return false;
    }return pass;
}
function validateAll(){
    if(! hasASelection('resource[topic_ids][]')){
        alert("Please select at least one topic !");return false;
    }return true;
}



function counselor_signup()
{
    if(document.getElementById('user_login').value == ''){
        alert("Login can't be empty");
        document.getElementById('user_login').focus();
        return false;
    }
    if(document.getElementById('user_email').value == ''){
        alert("Email can't be empty");
        document.getElementById('user_email').focus();
        return false;
    }
    if(document.getElementById('user_password').value == ''){
        alert("Password can't be empty");
        document.getElementById('user_password').focus();
        return false;
    }
    if(document.getElementById('user_password_confirmation').value == ''){
        alert("Confirm Password can't be empty");
        document.getElementById('user_password_confirmation').focus();
        return false;
    }

    if(document.getElementById('user_password').value!=document.getElementById('user_password_confirmation').value){
        alert("Passwor and Confirm Password doesn't match");
        return false;
    }
    if(document.getElementById('counselor_profile_first_name').value == ''){
        alert("First Name can't be empty");
        document.getElementById('counselor_profile_first_name').focus();
        return false;
    }
    if(document.getElementById('counselor_profile_state_id').value == ''){
        alert("Please select State");
        document.getElementById('counselor_profile_state_id').focus();
        return false;
    }
    if(document.getElementById('counselor_profile_mobile_phone').value == ''){
        alert("Mobile Number can't be empty");
        document.getElementById('counselor_profile_mobile_phone').focus();
        return false;
    }
    if(document.getElementById('counselor_profile_mobile_provider_id').value == ''){
        alert("Please select a Mobile Provider");
        document.getElementById('counselor_profile_mobile_provider_id').focus();
        return false;
    }
    if(document.getElementById('license_number').value == ''){
        alert("License Number can't be empty");
        document.getElementById('license_number').focus();
        return false;
    }
    if(document.getElementById('counselor_day_of_week_slot_time_slot_from').value == ''){
        alert("Please select Time From");
        document.getElementById('counselor_day_of_week_slot_time_slot_from').focus();
        return false;
    }
    if(document.getElementById('counselor_day_of_week_slot_time_slot_to').value == ''){
        alert("Please select Time To");
        document.getElementById('counselor_day_of_week_slot_time_slot_to').focus();
        return false;
    }
    if(document.getElementById('counselor_profile_package_type_id').value == ''){
        alert("Please select Package");
        document.getElementById('counselor_profile_package_type_id').focus();
        return false;
    }

    if(counselor_agreement() == false)
    {
        return false;
    }
    return true;
}




 function user_signup()
{
    if(document.getElementById('user_login').value == ''){
        alert("Login can't be empty");
        document.getElementById('user_login').focus();
        return false;
    }
    if(document.getElementById('user_email').value == ''){
        alert("Email can't be empty");
        document.getElementById('user_email').focus();
        return false;
    }
    if(document.getElementById('user_password').value == ''){
        alert("Password can't be empty");
        document.getElementById('user_password').focus();
        return false;
    }
    if(document.getElementById('user_password_confirmation').value == ''){
        alert("Confirm Password can't be empty");
        document.getElementById('user_password_confirmation').focus();
        return false;
    }

    if(document.getElementById('user_password').value!=document.getElementById('user_password_confirmation').value){
        alert("Passwor and Confirm Password doesn't match");
        return false;
    }
    if(document.getElementById('user_profile_first_name').value == ''){
        alert("First Name can't be empty");
        document.getElementById('user_profile_first_name').focus();
        return false;
    }
    if(document.getElementById('user_profile_state_id').value == ''){
        alert("Please select State");
        document.getElementById('user_profile_state_id').focus();
        return false;
    }

    return true;

}