
function toggleDiv(divid,extrafieldarray){
var button=divid+'_button';
var testDiv;

var divs_list=['divProblem','divMethod','divClientType','divCredentials','divGender','divPayment','divLanguage'];

//var divs_list= extrafieldarray.split(',');

if(document.getElementById(divid).style.display == 'none'){

document.getElementById(divid).style.display = 'block';
//document.getElementById(button).style.backgroundImage='url("templates/default/images/open-arrow.gif")';
        //run through and close divs that are not the the divid which has been opened and change image to close
        for(i=0; i<divs_list.length; i++){
        button=divs_list[i]+'_button';
         //checks the existence of the div in the array  -- not needed
        if((divs_list[i]!=divid) && (testDiv=document.getElementById(divs_list[i]))){
//        document.getElementById(button).style.backgroundImage = 'url("templates/default/images/closed-arrow.gif")';
        document.getElementById(divs_list[i]).style.display = 'none';
        }
       }


}else{
document.getElementById(divid).style.display = 'none';
//document.getElementById(button).style.backgroundImage='url("templates/default/images/closed-arrow.gif")';
}
}


function updatekeywords(selectnamelist){

if (selectnamelist==""){selectnamelist="Problem,Technique/Methods,Type Of Therapy,Client Type,Payment Type,Language"}
selectnamearray=selectnamelist.split(",");
 var keywords="";
 var output="";
for(i=0;i<selectnamearray.length;i++){

    selectbox=selectnamearray[i];

    opt_ref=document.keywordform.elements[selectbox].options;

    keywords=opt_ref[opt_ref.selectedIndex].value;

    output=output+" "+keywords;
}
document.searchform.elements['keyword'].value=output;


}


function hide_output_select(){
document.getElementById("radios").innerHTML="";
document.searchform.elements['keyword'].style.display="block";
document.getElementById('keyword-label').style.display="block";
document.getElementById('advsearch').style.display="block";

}



function output_select(select_group_names,select_values0,select_values1,select_values2,select_values3,select_values4,select_values5){
var option_colors="";

if (document.getElementById("radios").innerHTML==""){
//define radio_group_ names if not passed as parameters
if(select_group_names==""){var select_group_names="Problem,Technique/Methods,Type Of Therapy,Client Type,Payment Type,Language";}
var selectgroup_array=select_group_names.split(",");
//turne string into array
if(select_values0==""){select_values0="Abuse Victim,Addiction,ADHD or Attention Deficit Disorder,Anxiety,Anger,Bipolar,Divorce,Career Issues,Workplace Issues,Children's Issues,Couples or Marriage,Chronic Pain or Illness,Creativity Enhancement,Cultural Issues,Dating,Depression,Dreams,Eating Disorders,Education,Eldery Family Care,Fitness and Health,Gambling Problem,Gay or Lesbian Issues,Gender Identity,Faith Issues,Grief,Geriatric Issues,Interpersonal Conflict,Impulse or Habit Control,Intimacy Issue,Isolation or Lonliness,Life Balance,Life or Work Burnout,Medication Issues,Motivation Issues,Men's Issues,Obsessive Compulsive Disorder,Parenting,Performance Enhancement,Personality Disorders,Personal Growth or Development,Phobias,Post Traumatic Stress Disorder,Psychological Assessment,Self Esteem,Self Harm,Suicide,Spirituality,Sexuality,Sexual Assault,Smoking Cessation,Social Anxiety,Sleeping Difficulties,Stress Management,Weight Loss,Psychiatric Care,Women's Issues";}
var select_values_array0=select_values0.split(",");
select_values_array0.sort();

if(select_values1==""){select_values1="Acupuncture,Advocacy Service,Energy Work,Body Centered Approaches,Career Counselling,Coaching,Performance Coaching,Cognitive Behavioral Approach,Psychological Assessment,Communication Skills Coaching,Coping Skills,Corporate Wellness Consulting,Dream Work,Educational Evaluation,EFT,Emotion Focused Approaches,EMDR,Employee Assistance,Guided Imagery,Hypnotherapy,Internet Based Counselling,Mediation,Medication Based Treatment,Naturopathy,Mindfulness Based Approach,Meditation,Nutritional Counselling,Orthomolecular Based Approach,Play Based Approach,Relaxation Skills,Faith Based Approach,Spirituality Based Approach,Support Groups,Telephone Counselling,Art,Dance,Music or Sound ,Yoga, Safety or Driving Evaluation,Group Therapy,Writing or Journaling,Stress Management,Physical Fitness";}
var select_values_array1=select_values1.split(",");
select_values_array1.sort();

if(select_values2==""){select_values2="Acceptance and Commitment,Adlerian,Advocacy,Behavioral Analysis,Body Centered,Cognitive Behavioral or CBT,DBT or Dialectical Behavioral,Emotion Focused,Family Systems,Gestalt,Gottman Relationship,Hakomi,Humanistic,Imago Relationship,Interpersonal IPT,Jungian,Logotherapy,Mindfulness,Narrative Based,Neurolinguistic Programming or NLP,Psychoanalysis,Psychodynamic,Satir,Sensorimotor,Solution Focused,Transactional Analysis,Transpersonal,Integrative";}
var select_values_array2=select_values2.split(",");
select_values_array2.sort();


// must update function call with extra blank paramaeter for every select_value list added
if(select_values3==""){select_values3="Adolescent,Adult,Child,Family,Couples,Corporation";}
var select_values_array3=select_values3.split(",");
select_values_array3.sort();

if(select_values4==""){select_values4="Provincial_Health Insurance,Private_Pay,Most Private_Insurance Plans,No_Cost,Voluntary/Donation";}
var select_values_array4=select_values4.split(",");
select_values_array4.sort();


if(select_values5==""){select_values5="English,Arabic,Chinese,French,Hebrew,Hindi,Itaian,Japanese,Pashto,Korean,Konkani,Urdu,Twi,Tamil,Swahili,Spanish,Sign Language,Russian,Romanian,Punjabi,Portugese,Polish";}
var select_values_array5=select_values5.split(",");
select_values_array5.sort();





output="<table width='100%' style='background-color:#ffffff;border:1px solid #000000' cellpadding='0' cellspacing='0'>";
output=output+"<tr><td align='center' colspan='2' style='color:#000000;padding:3px;border-bottom:1px solid #326B9A;font-family:arial;font-size:12px;'><span style='color:#ffffff;background-color:#5D7683;cursor:pointer;width:150px;border:2px solid #4F5C66' onclick='clear_search(\"\")'>Reset Search</span><span style='color:#ffffff;background-color:#5D7683;margin-left:2px;cursor:pointer;width:150px;border:2px solid #4F5C66' onclick='hide_output_select()'>Hide Advanced Search</span>    </td>"
output=output+"<tr><td colspan='2' style='color:#000000;padding:3px;border-bottom:1px solid #000000;font-family:arial;font-size:12px;'><div style='padding-left:10px;padding-bottom:2px;padding-top:2px;border:2px solid #4F5C66'> 1) Select your search criteria from <span style='text-decoration:underline;font-weight:bold;color:#1A4860'>one or more</span> fields listed below.<br><br>2)<span style='font-weight:bold;color:#990000;'> All fields are optional. Only select from those which meet your needs.</span><br><div></td>"


//loop once through each radio_group
for(i=0;i<selectgroup_array.length;i++){
//label_name="label"+selectgroup_array[i];
element_name=selectgroup_array[i];
select_text="Select"+" "+ selectgroup_array[i];
select_values=eval("select_values_array"+i);


output=output+"<tr><td style='padding:2px;border-bottom:1px solid #000000'><label style='color:#262F38;font-family:arial;font-size:14px;font-weight:normal;text-align:center;' for='"+element_name+"'>"+select_text+":</label></td>"
output=output+"<td style='padding:3px;border-bottom:1px solid #326B9A'> <select style='width:230px;background-color:#E4F4FD;color:#000000;'  id='"+element_name+"' name='"+element_name+"' onChange='updatekeywords(\"\")'> ";
output=output+"<optgroup style='background-color:#E4F4FD;color:#990000;'  label='"+select_text +"'><option  style='background-color:#E4F4FD;color:#990000;'   value=''>Not Selected (optional)</option>";

//loop through each value_group for the respect select_group
for(x=0;x<select_values.length;x++){
if(x % 2==0){option_colors="#FFF4CF"}
else{option_colors="#E4F4FD"}
output=output + "<option  style='color:#000000;background-color:"+option_colors+";' value='"+select_values[x]+"'>"+select_values[x]+"</option>";
}

 output=output+"</optgroup></select><td></tr>";
 }
output=output+"</table>";
document.searchform.elements['keyword'].style.display="none";
document.getElementById('keyword-label').style.display="none";
document.getElementById('advsearch').style.display="none";
document.getElementById("radios").innerHTML=output;

}
else{document.getElementById("radios").innerHTML="";
document.searchform.elements['keyword'].style.display="block";
document.getElementById('keyword-label').style.display="block";}

}

function clear_search(select_group_names){
if(select_group_names==""){{var select_group_names="Problem,Technique/Methods,Type Of Therapy,Client Type,Payment Type,Language";}
select_names_array=select_group_names.split(',');
for (i=0;i<select_names_array.length;i++){
document.keywordform.elements[select_names_array[i]].selectedIndex=0;

}
}
document.searchform.elements['keyword'].value="";
 }


  function category_fields(){
 select_cat=document.searchform.elements['category'];
 selected_index=select_cat.selectedIndex;
 selected_text=select_cat[selected_index].text;
 if ((selected_text.indexOf('Counselling')>=0)||selected_text.indexOf('Group')>=0){
 output_select('','','','','','');

 }
 }



