function get_mouse(){
    var mouse   = $('#mouse_me').html();
    return mouse;
    //alert('ok boys: ' + mouse);
}
function tip_me(id,state) {
    var content = $('#email_blast_pjd_'+id).text();
    if (state == 'on') {
        var where_am_i      = get_mouse();
        var left_top        = where_am_i.split(":");
        var left            = left_top[0];
        var top             = left_top[1] - 113;
        var leftp           = left;
        var topp            = top +91;
        $('#pjd_guts').text(content);
        $('#pjd_job_id').text(id);
        $('#pjd_holder').css('top', top +'px');
        $('#pjd_holder').css('left', left + 'px');
        $('#pjd_holder_point').css('top', topp +'px');
        $('#pjd_holder_point').css('left', leftp + 'px');
        $('#pjd_holder_point').fadeIn();
        $('#pjd_holder').fadeIn();
    } else {
        $('#pjd_guts').text('');
        $('#pjd_holder').fadeOut();
        $('#pjd_holder_point').fadeOut();

    }

}
function hilite_me(id, pos) {
    switch (pos) {
        case "on":
            $("." +id).css('backgroundColor', '#EBE1D7');
            break;
        case "off":
            $("." + id).css('backgroundColor', '');
            break;
    }
}
function hide_show_pd(id, pos) {
    switch (pos) {
        case "on":
            $("#pjd_job_id").text( id );
            $("#pjd_guts").text( $('#email_blast_row_' + id + '_pd').text() );
            $("#pjd_holder").fadeIn();
            break;
        case "off":
            $("#pjd_holder").hide();
            //$("#pjd_guts").text('');
            break;
    }
    if ($("#pjd_guts").text() == ""){
        //alert(id);
        $("#pjd_holder").hide();
    }
}
function email_blast_toggle(scope, type, num){
    var state   = $('#all_boxes_status_' + type).val();
    //alert ('state: ' + state);
    switch (scope){
        case "all":
            switch (state) {
                case "1":
                    $('#all_boxes_status_' + type).val('0');
                    $(".email_blast_checkbox_" + type).attr('checked', '');
                    //$("#blast_check_all_" + type).show();
                    //$("#blast_check_none_" + type).hide();
                    break;
                case "0":
                    $('#all_boxes_status_' + type).val('1');
                    $(".email_blast_checkbox_" + type).attr('checked', 'checked');
                    //$("#blast_check_all_" + type).hide();
                    //$("#blast_check_none_" + type).show();
                    break;
            }
            break;
        case "individual":
            if ($("#blast_"  + type + "_checkbox_" + num).attr('checked')) {
               $("#blast_"  + type + "_checkbox_" + num).attr('checked', '');
            } else {
               $("#blast_"  + type + "_checkbox_" + num).attr('checked', 'checked');
            }
            break;
    }
}


function is_one_option_selected(id) {
    var select_box      = document.getElementById(id);
    var options_size    =  select_box.options.length;
    var one_is_selected = false;
    for (var i=0; i<options_size; i++){

        if ( select_box.options[i].selected == true ){
            one_is_selected = true;
        }
    }
    return one_is_selected;
}
function dashboard_client_call_list_select_all(num){
    var select_box      = document.getElementById('search_'+num+'_value');
    var options_size    =  select_box.options.length;
    //alert('we have ' + options_size + ' options');
    // if we are checking the select all box, then select all
    for (var i=0; i<options_size; i++){
        
        if ( $('#client_call_list_select_all_' + num).is(':checked') ){
            //alert ('check_all');
            select_box.options[i].selected = true;
        } else {
            //alert ('uncheck all');
            select_box.options[i].selected = false;
        }
    }
    // get size of options list
    // cycle through the array and select each item
}
function dashboard_update_search_term_type(term) {
    switch (term) {
        case "organization_name":
            $('#search_term_type').html('Enter part of name:');
            break;
        case "state_id":
            $('#search_term_type').html('Select state(s):');
            break;
        case "profession":
            $('#search_term_type').html('Select profession(s):');
            break;
        case "specialty":
            $('#search_term_type').html('Select specialty(ies):');
            break;
        case "contact":
            $('#search_term_type').html('Enter name(s):');
            break;
        case "job_id":
            $('#search_term_type').html('Enter job ID:');
            break;
        case "":
            alert('please select an option');
            break;
    }
}

function get_dashboard(cat,id){
    location.href="my-dashboard.php?cat="+cat+"&id=" + id;
}


function dashboard_create_days_dropdown(month, id2update) {
    var day_value   = "";
    var dropdown    = '<select id="callback_day" name="day">';
    dropdown        += '<option value="">Select</option>';
    var max = 31; // default
    switch (month) {

        case "02":
            max = 29;
            break;
        case "04":
        case "06":
        case "09":
        case "11":
            max = 30;
            break;
    }
    for (var i=1; i<=max; i++) {
        day_value = i;
        if (i < 10) {
            day_value = "0" + i;
        }
        dropdown    += '<option value="' + day_value + '">' + i + '</option>';

    }
    dropdown += "</select>";

    $("#"+id2update).html(dropdown);

}
function dashboard_show_hide_practices_inputs(value) {
	switch (value)	{
	case "all":
		$("#client_practice_info_fields").html('Creating practice input fields...');
		$("#row_client_practice_info_fields").show();
		xajax_Misc.dashboardCreateClientPracticeFields();
		$(".practice_row").hide();
		$("#practice_inputs").html(''); // clear out all previous entries
		$("#num_practices").val('');
		break;
	case "some":
		$("#client_practice_info_fields").html('Creating practice input fields...');
		$("#row_client_practice_info_fields").show();
		xajax_Misc.dashboardCreateClientPracticeFields();
		$(".practice_row").show();
		break;
	case "none":
		$("#client_practice_info_fields").html(''); // clear out all previous entries
		$(".practice_row").show();
		$("#row_client_practice_info_fields").hide();
		break;
	
	}
	
}

function dashboard_client_snapshot_update() {
	var status	= "<div class='module_processing_status'>";
	status		+= "<img src='images/processing_status.gif' width='32' height='32' border='0' class='module_processing_image' />";
	status		+= "</div>";

	//$("#snapshot-client-details-data").html(status);
	$("#snapshot-client-details-data-status").show();
	$(".snapshot_status_ghost").show();
	$(".module_processing").show();
	$("#snapshot-client-details-name").html('Retrieving...');
	//$("#snapshot-client-practices-data").html(status);
	//$("#snapshot-client-contacts-data").html(status);
	//$("#snapshot-client-active-jobs-data").html(status);
	//$("#snapshot-client-inactive-jobs-data").html(status);

}

function do_dashboard_update_contact() {
	$("#dashboard-client-contact-inner").html('<div style="height:250px;">Rebuilding...</div>');
	$("#update-contact-status").show();
	xajax_Misc.dashboardUpdateContact(xajax.getFormValues('form-update-contact') );
	//verify_portal_add_edit('portal-client-add');
}



//function dashboard_build_practice_contacts_inputs(num, edit, row) {
function dashboard_build_practice_contacts_inputs(num, edit, practice_num) {
	var new_contact	= "";
	if (edit)	{
		new_contact	= " NEW ";
	}

	if (num != "" ){


		//createContactsInputs( $("#num_contacts").val() );

		var content_label_td	= '<td align="right" valign="top" class="content_label">';
		var content_info_td		= '<td align="left" valign="top" class="content_info">';

		var inputs	= "<table cellspacing='0' cellpadding='3' border='0' width='100%'>";

		var contact_fields	= new Array();
		contact_fields[0]	=	'Contact First Name:::practice_'+practice_num+'_contact_first_name:::45';

		contact_fields[1]	=	'Contact Last Name:::practice_'+practice_num+'_contact_last_name:::45';

		contact_fields[2]	=	'Contact Title:::practice_'+practice_num+'_contact_title:::45';

		contact_fields[3]	=	'Contact Email:::practice_'+practice_num+'_contact_email:::60';

		contact_fields[4]	=	'Contact Phone:::practice_'+practice_num+'_contact_phone:::20';

		contact_fields[5]	=	'Contact Fax:::practice_'+practice_num+'_contact_fax:::20';

		contact_fields[6]	=	'Contact Best Time to Call:::practice_'+practice_num+'_contact_best_time_to_call:::45';



		for (var i = 1; i<=num ; i++) {

			inputs += '<tr><td colspan="2" align="left" valign="top" style="border-top: 1px solid #000000;border-bottom: 1px solid #000000;font-weight: bold;font-size:90%;">';
			inputs += 'FIELDS FOR '+ new_contact +' CONTACT #' + i;
			if (edit){
				inputs += "<input type='hidden' id='contact_id_new_" + num + "' name='contact_id[]' value='0' />";
			}
			inputs += "</td></tr>";
			var f	= "";
			var x	= "";
			for (x in contact_fields) {

				f	= contact_fields[x].split(":::");
				inputs += '<!-- ------------------- details row start -------------------------- -->';
				inputs += '<tr>';
				inputs += content_label_td;
				inputs += f[0] + ': ';
				inputs += '</td>';

				inputs += content_info_td;

				inputs += '<input type="text" id="' +f[1]+ '" name="' +f[1]+ '[]" size="' + f[2]+ '" value="" />';
				//inputs += '<input type="text" id="' +f[1]+ '__' + i +'" name="' +f[1]+ '__' + i + '[]" size="' + f[2]+ '" value="" />';

				inputs += '</td>';

				inputs += '</tr>';

			}
		}
		inputs += "</table>";

		$("#practice_contacts_inputs_" + practice_num).html(inputs);

	} else {
		$("#practice_contacts_inputs_" + practice_num).html('');

	}
}













function dashboard_build_contacts_inputs(num, edit, no_client) {
	var new_contact	= "";
	if (edit)	{
		new_contact	= " NEW ";
	}

	if (num != "" ){


		//createContactsInputs( $("#num_contacts").val() );

		var content_label_td	= '<td align="right" valign="top" class="content_label">';
		var content_info_td		= '<td align="left" valign="top" class="content_info">';

		var inputs	= "<table cellspacing='0' cellpadding='3' border='0' width='100%'>";

		var contact_fields	= new Array();
		contact_fields[0]	=	'Contact First Name:::contact_first_name:::45';
		contact_fields[1]	=	'Contact Last Name:::contact_last_name:::45';
		contact_fields[2]	=	'Contact Title:::contact_title:::45';
		contact_fields[3]	=	'Contact Email:::contact_email:::60';
		contact_fields[4]	=	'Contact Phone:::contact_phone:::20';
		contact_fields[5]	=	'Contact Fax:::contact_fax:::20';
		contact_fields[6]	=	'Contact Best Time to Call:::contact_best_time_to_call:::45';



		for (var i = 1; i<=num ; i++) {

			inputs += '<tr><td colspan="2" align="left" valign="top" style="border-top: 1px solid #000000;border-bottom: 1px solid #000000;font-weight: bold;font-size:90%;">';
			inputs += 'FIELDS FOR '+ new_contact +' CONTACT #' + i;
			if (edit){
				inputs += "<input type='hidden' id='contact_id_new_" + num + "' name='contact_id[]' value='0' />";
			}
			inputs += "</td></tr>";
			var f	= "";
			var x	= "";
			for (x in contact_fields) {

				f	= contact_fields[x].split(":::");
				inputs += '<!-- ------------------- details row start -------------------------- -->';
				inputs += '<tr>';
				inputs += content_label_td;
				inputs += f[0] + ': ';
				inputs += '</td>';

				inputs += content_info_td;
				inputs += '<input type="text" id="' +f[1]+ '" name="' +f[1]+ '[]" size="' + f[2]+ '" value="" />';
				inputs += '</td>';

				inputs += '</tr>';

			}
		}
		inputs += "</table>";

		if (no_client) {
                    $("#contacts_inputs_no_client").html(inputs);
                } else {
                    $("#contacts_inputs").html(inputs);
                }

	} else {
		if (no_client) {
                    $("#contacts_inputs_no_client").html(inputs);
                } else {
                    $("#contacts_inputs").html(inputs);
                }
	}
}




function dashboard_build_practice_inputs(num, edit) {

	$("#practice_inputs").html('Generating Add Practice Forms...');

	xajax_Misc.dashboardBuildPracticeInputs(num);

	/*
	var new_practice	= "";
	if (edit)	{
		new_practice	= " NEW ";
	}

	if (num != "" ){


		//createContactsInputs( $("#num_contacts").val() );

		var content_label_td	= '<td align="right" valign="top" class="content_label">';
		var content_info_td		= '<td align="left" valign="top" class="content_info">';

		//var inputs	= "<table cellspacing='0' cellpadding='3' border='0' width='100%'>";
		var inputs	= "";

		var practice_fields	= new Array();
		practice_fields[0]	=	'Practice Name:::practice_organization_name:::text:::60';
		practice_fields[1]	=	'Year Established:::practice_year_established:::text:::8';
		practice_fields[2]	=	'What are the names of the primary doctors in the practice?:::practice_doc_names:::textarea:::50x5';

		practice_fields[3]	=	'Is this a Solo, SSG, MSG or hospital-owned practice?:::practice_practice_type:::textarea:::50x5';

		practice_fields[4]	=	'Is this an outpatient only practice, traditional practice (outpatient and inpatient, consultative only?):::practice_patient_handling:::textarea:::50x3';

		practice_fields[5]	=	'How many locations does the practice have and where are they located?:::practice_locations:::textarea:::50x5';

		practice_fields[6]	=	'What is the call coverage/call rotation (weekdays and weekend, ie. 1 in 4 days, every 4th weekend):::practice_call_coverage:::textarea:::50x5';

		practice_fields[7]	=	'Which hospitals does the practice cover?:::practice_hospitals_covered:::textarea:::50x5';

		practice_fields[8]	=	'What is the primary service area? Secondary service area?:::practice_primary_service_area:::textarea:::50x5';

		practice_fields[9]	=	'How many competing doctors in the primary service area?:::practice_number_of_competing_doctors:::textarea:::50x5';

		practice_fields[10]	=	'What procedures does the practice do and what is the monthly/annual volume of these procedures? (ie. OB/GYN practice - how many deliveries does the practice do each year? IVI, urodynamics, etc.,):::practice_procedures_and_volume:::textarea:::50x5';

		practice_fields[11]	=	'What equipment does the practice have available? (For GI or GS practices, do they have ownership in a surgery center?):::practice_equipment_available:::textarea:::50x5';

		practice_fields[12]	=	'Does the practice or the hospital own the equipment?:::practice_who_owns_equipment:::textarea:::50x5';

		practice_fields[13]	=	'What personnel does the practice have (ie. how many nurses, mid-levels, front office/adminstrative, office manager?):::practice_personnel:::textarea:::50x5';

		practice_fields[14]	=	'What is the approximate overhead (ie. 40%?):::practice_approximate_overhead:::textarea:::50x2';

		practice_fields[15]	=	'What is the payor mix (private pay, Medicaid/Medicare/HMO?):::practice_payor_mix:::textarea:::50x2';

		practice_fields[16]	=	'How many active charts does the practice have? Is there a wait time to get an appointment?:::practice_number_of_active_charts:::textarea:::50x3';

		practice_fields[17]	=	'Type of retirement plan (if 401K, is there a match?):::practice_retirement_plan_type:::textarea:::50x4';

		practice_fields[18]	=	'Health? Dental? Does the practice cover just the physician or the entire family?:::practice_health_dental_insurance:::textarea:::50x4';

		practice_fields[19]	=	'# of weeks vacation?:::practice_number_of_weeks_vacation:::textarea:::50x3';

		practice_fields[20]	=	'Malpractice insurance: Claims made or Tail coverage/occurrence? What are the amounts (ie. $1M/$3M):::practice_malpractice_insurance:::textarea:::50x5';

		practice_fields[21]	=	'Short term Disability:::practice_short_term_visibility:::textarea:::50x3';

		practice_fields[22]	=	'Long Term Disability:::practice_long_term_visibility:::textarea:::50x3'; 

		practice_fields[23]	=	'Life Insurance:::practice_life_insurance:::textarea:::50x3';




		for (var i = 1; i<=num ; i++) {


			inputs	+= "<div style='background: #E9DFD5;border-top: 1px solid #000000;border-bottom: 1px solid #000000;font-weight: bold;font-size:90%;'>";
			inputs += new_practice +' PRACTICE #' + i + ' INFORMATION';

			inputs	+= "</div>";

			inputs	+= "<div style='height: 200px;overflow:auto;margin-bottom:15px;border-bottom: 1px solid #D5C1AD;background: #F9F5F1;'>";
			
			inputs	+= "<table cellspacing='0' cellpadding='3' border='0' width='100%'>";

//			inputs += '<tr><td colspan="2" align="left" valign="top" style="border-top: 1px solid #000000;border-bottom: 1px solid #000000;font-weight: bold;font-size:90%;">';
//			inputs += new_practice +' PRACTICE #' + i + ' INFORMATION';

			inputs += '<tr><td colspan="2" align="left" valign="top">';

			if (edit){
				inputs += "<input type='hidden' id='contact_id_new_" + num + "' name='contact_id[]' value='0' />";
			}
			inputs += "</td></tr>";
			var f	= "";
			var x	= "";
			for (x in practice_fields) {
				var s	= ""; // size

				f	= practice_fields[x].split(":::");
//					f[0]	= display text
//					f[1]	= id/name of html tag
//					f[2]	= html element type (text, textarea...)
//					f[3]	= size of element  - if a textarea, then 
					          split on "x" to get cols= and rows=
				inputs += '<!-- ------------------- details row start -------------------------- -->';
				inputs += '<tr>';
				inputs += content_label_td;
				inputs += f[0] + ': ';
				inputs += '</td>';


				inputs += content_info_td;
				switch (f[2]){
				case "text":
					inputs += '<input type="text" id="' +f[1]+ '" name="' +f[1]+ '[]" size="' + f[3]+ '" value="" />';
					break;

				case "textarea":
					s	= f[3].split("x");
					inputs += '<textarea id="' +f[1]+ '" name="' +f[1]+ '[]" cols="' + s[0]+ '"  rows="' + s[1]+ '"></textarea>';

					break;
				}
				inputs += '</td>';
				inputs += '</tr>';




			}



			inputs += "<tr>";
			inputs += '<td align="right" valign="top" class="content_label">';
			inputs += "Add How Many Contacts for this practice?";
			inputs += "</td>";

			inputs += '<td align="left" valign="top" class="content_info">';
			inputs += '<select id="num_practice_'+ i + '_contacts" name="num_practice_' + i + '_contacts" onchange="dashboard_build_practice_contacts_inputs(this.value, 0, \'' + i + '\');">';

			inputs += '<option value="">Select...</option>';
			inputs += '<option value="">0</option>';
			
			for (var pc=1; pc<11 ; pc++ ){
				inputs += '<option value="' + pc + '">' + pc + '</option>';

			}

			inputs += "</select>";
			inputs += "</td>";
			inputs += "</tr>";

			inputs += "<tr>";

			inputs += '<td align="left" colspan="2" valign="top" id="practice_contacts_inputs_' + i + '">';

			inputs += "</td>";
			inputs += "</tr>";



			inputs += "</table></div>";
		}

		$("#practice_inputs").html(inputs);

	} else {
		$("#practice_inputs").html('');

	}
	*/
}


function show_do_what(value) {
	$(".do_what").hide();
	if (value != ""){
		$("#" + value +"_do_what").show();
	}
	
}
function dashboard_show_work_area(value) {
	$(".work_area").hide();
	$(".dashboard_work_area_search_class").hide();

	switch (value)	{
	case "client_add":
		$("#work_area_client_add").html('<div style="text-align:center"><img src=images/processing_bar.gif width=65 height=17 /> getting add a client form...</div>');
		xajax_Client.dashboardGetClientAddForm();
		break;
	case "client_snapshot":
		break;
	case "client_call_list":
		break;
	case "client_upload_contract":
		break;
	
	}

	if (value != ""){
		$("#work_area_" + value).show();
		if (
			value == "client_add" ||
			value == "practice_add" ||
			value == "job_add" ||
			value == "candidate_add"
		){
			$("#dashboard_work_area_search_" + value).slideUp();
		} else {
			$("#dashboard_work_area_search_" + value).show();
		}
	} else {
		$(".original_stuff").show();

	}
	
}
function show_work_area(value) {
	$(".work_area").hide();
	$(".dashboard_work_area_search_class").hide();
	if (value != ""){
		$("#work_area_" + value).show();
		if (
			value == "client_add" ||
			value == "practice_add" ||
			value == "job_add" ||
			value == "candidate_add"
		){
			$("#dashboard_work_area_search_" + value).slideUp();
		} else {
			$("#dashboard_work_area_search_" + value).show();
		}
	} else {
		$(".original_stuff").show();

	}
	
}
function prep4edit(id, dowhat) {
	var preview		= "existing_comment_" + id + "_preview";
	var btn_prep	= "btn_edit_comment_" + id;
	var textarea	= "edit_existing_comment_"+ id;
	var btn_go		= "btn_edit_comment_" + id + "_go";
	var btn_stop	= "btn_edit_comment_" + id + "_stop";

	if (dowhat == "open"){
		$("#" + textarea).addClass('hilite_it');
		$("#" + textarea).fadeIn();
		$("#" + btn_go).fadeIn();
		$("#" + btn_stop).fadeIn();

		$("#" + preview).fadeOut();
		$("#" + btn_prep).fadeOut();
		$("#edit_comment_results").text('');
	} else {
		$("#" + textarea).removeClass('hilite_it');
		$("#" + textarea).fadeOut();
		$("#" + btn_go).fadeOut();
		$("#" + btn_stop).fadeOut();

		$("#" + preview).fadeIn();
		$("#" + btn_prep).fadeIn();
	}

}

function add_comment_textarea(num) {
	var ta = "<textarea class='js_comment' cols='80' rows='4'></textarea>";
	for (i=1 ;i<=num ;i++ ){
		$('.js_comment').after(ta);
	}
	
}
function prepContractUploadButton() {

	var client_guid = $('#contract_client_guid').val();
	var contract_file = $('#contract_file').val();

	if (client_guid != "" && contract_file != "") {
		$('#btn_upload_contract').addClass('go_button');
		$('#btn_upload_contract').removeClass('go_button_disabled');
		$('#btn_upload_contract').attr('disabled','');
	} else {
		$('#btn_upload_contract').addClass('go_button_disabled');
		$('#btn_upload_contract').removeClass('go_button');
		$('#btn_upload_contract').attr('disabled','disabled');
	}
}
function prepCVUploadButton() {

	var candidate_guid = $('#candidate_guid').val();
	var resume_file = $('#resume_file').val();
	if (candidate_guid != "" && resume_file != "") {
		$('#btn_upload_resume').addClass('go_button');
		$('#btn_upload_resume').removeClass('go_button_disabled');
		$('#btn_upload_resume').attr('disabled','');
	} else {
		$('#btn_upload_resume').addClass('go_button_disabled');
		$('#btn_upload_resume').removeClass('go_button');
		$('#btn_upload_resume').attr('disabled','disabled');
	}
}

function show_state_list(region_id, email_blast){
	if (email_blast){
		$("#regions_states_email").slideDown('slow');
		$("#states_list_email").html( $("#region_" + region_id + "_states_email").html() );	
		$("#states_list_email").slideDown('slow');
	} else {
		$("#regions_states").slideDown('slow');
		$("#states_list").html( $("#region_" + region_id + "_states").html() );	
		$("#states_list").slideDown('slow');
	}
}
function check_if_practicing(value){
	$("#practicing_current_earnings_holder").hide('slow');
	if (value == "3"){
		$("#practicing_current_earnings_holder").show('slow');
	}
}
function check_for_other(choice, element){
	if (choice == "999"){
		$("#" + element + "_other_holder").show('fast');
	} else {
		$("#" + element + "_other_holder").hide('slow');
	}
	
}
function show_checkbox_other(id,element){
	if ($("#" + id).is(':checked') ){
		$("#" + element + "_other_holder").show('fast');
	} else {
		$("#" + element + "_other_holder").hide('slow');
	}
	
}

function show_employee_submenu(dowhat,category,menu_id){
	switch (category){
	case "client":
		var menu_ids = new Array(
			'add',
			'edit',
			'search',
			'upload_contract'
		);
		break;
	case "candidate":
		var menu_ids = new Array(
			'add',
			'edit',
			'upload_resume',
			'search'
		);
		break;
	case "employee":
		break;
	}
	switch (dowhat){
	case "open":
		for (i=0;i<menu_ids.length ; i++ )	{
			if (menu_id == menu_ids[i]){
				//alert (menu_id + ' matches ' + menu_ids[i] );
				document.getElementById('portal_'+category+'_'+menu_ids[i]+'_holder').style.display='';
			} else {
				//alert (menu_id + ' doesn\'t match ' + menu_ids[i] );
				document.getElementById('portal_'+category+'_'+menu_ids[i]+'_holder').style.display='none';
			}
		}
		document.getElementById('portal_'+category+'_ui').innerHTML = document.getElementById('portal_'+category+'_'+menu_id+'_form').innerHTML;
		break;
	case "close":
		document.getElementById('portal_'+category+'_'+menu_id+'_holder').style.display='none';
		// clear contents of subarea
		document.getElementById('portal_'+category+'_ui').innerHTML='';
		break;
	
	}
}
	
	
function set_preferred_ids(category) {
	var ids = '';
	var preferred_area_id = "";
	var preferred_area_ids_selected = "";
	switch (category){
		case "client":
			preferred_area_id = 'client_preferred_area_id';
			preferred_area_ids_selected = 'client_preferred_ids_selected';
			break;
		case "candidate":
			preferred_region_id = 'candidate_preferred_region_id';
			preferred_region_ids_selected = 'candidate_preferred_region_ids_selected';
			break;
		case "candidate_submit":
			preferred_region_id = 'candidate_submit_preferred_region_id';
			preferred_region_ids_selected = 'candidate_submit_preferred_region_ids_selected';
			break;
		case "employee":
			break;
	}
	for (i=0; i<document.getElementById(preferred_region_id).options.length; i++) {
		if (document.getElementById(preferred_region_id).options[i].selected == true) {
			ids += i + ":";
		}

		// now kill the last ":"
		//trimmed_ids = ids.substring(0,ids.length-1);
	}

	document.getElementById(preferred_region_ids_selected).value = ids;
	//document.getElementById(preferred_region_ids_selected).value = trimmed_ids;

}



function subnav(section){
	var sections	= new Array(
			'candidates',
			'clients',
			'home'
			);

	switch (section){
		case "off":
		for (i=0;i<sections.length ; i++ )	{
			document.getElementById('sublink_'+sections[i]).style.display = "none";
		}
		break;

		default:
			for (i=0;i<sections.length ; i++ )	{
				if (section == sections[i]){
					document.getElementById('sublink_'+sections[i]).style.display = "";
				} else {
					document.getElementById('sublink_'+sections[i]).style.display = "none";
				}
			}
			break;
	}
}
function do_ie_adjust(passed_version) {
	document.getElementById('sublink_about').style.top = "21px";
	document.getElementById('sublink_candidates').style.top = "21px";
	document.getElementById('sublink_clients').style.top = "21px";
	if( passed_version == "MSIE 6.0" ) {
		alert('passed: '+passed_version);

		document.getElementById('main_nav_holder').style.height = "28px";
		document.getElementById('main_nav').style.height = "24px";
	} else {
		document.getElementById('main_nav_holder').style.height = "28px";
		document.getElementById('main_nav').style.height = "28px";

	}
}

function zinko9(ba,aa,ap,dl,st,by){
	var a,b,c,aaa,ppp,ds,db,e
	//ba=stuff before the <at>;  //aa=stuff after the <at>;  //ap=stuff after the <period>
	//dl=text to display as link;  //st=subject in case you want to predefine it
	//by=body in case you want to predefine it
	a = '<a href=\"mai'
	c = '\">'
	aaa = '@'
	ppp = '.'
	if (st){
		ds = '?sub'
		ds += 'ject=\''
		ds += st+'\''
		} else {
		ds = ''
	}
	if (by){
		db = '&bo'
		db += 'dy=\''
		db += by+'\''
		} else {
		db = ''
	}
	a += 'lto:'
	a += ba
	a += aaa
	a += aa
	a += ppp
	a += ap
	e='</a>'
	b += aa
	b += '.'
	b += ap
	if (!dl) {
		dl = ba+aaa+aa+ppp+ap
	}
	//document.write(a+ds+db+c+dl+e)

	var zookie9 = a+ds+db+c+dl+e; 
	return zookie9;

///// *********************************////
/// -- DON'T EDIT ANYTHING ABOVE HERE ---//
///// *********************************////

// instructions - inside each '' pair in the zinko9('','','','','',''); below enter
//   first '' pair: the stuff before the <at> symbol in your email address
//   second '' pair: the stuff after the <at> symbol in your email address
//   third '' pair: the stuff after the first <period> in your email address
//   fourth '' pair: what you want as the displayed link - leave blank and your email address will be link
//   fifth '' pair: if you want to have an automatic subject - enter here - otherwise leave the ''
//   sixth '' pair: if you want to have an automatic body - enter here - otherwise leave the ''
// sample below:
// <script>document.write(zinko9('your.name','DomainName','net','Your Name','this is the subject','this is the body'));</script>
}


function reset_cs(){
	var q_ids	= new Array(
			'manual',
			'e_checks',
			'needle',
			'redflag',
			'msds',
			'training',
			'posters',
			'hepb'
		);

	for (i=0;i<q_ids.length ;i++ ){
		document.getElementById(q_ids[i]+'_y').style.borderColor	= ""
		document.getElementById(q_ids[i]+'_y').style.backgroundColor = "";
		document.getElementById(q_ids[i]+'_y').style.padding		= ""
		document.getElementById(q_ids[i]+'_y').style.borderWidth	= ""
		document.getElementById(q_ids[i]+'_y').style.borderStyle	= ""

		document.getElementById(q_ids[i]+'_n').style.borderColor	= ""
		document.getElementById(q_ids[i]+'_n').style.backgroundColor = "";
		document.getElementById(q_ids[i]+'_n').style.padding		= ""
		document.getElementById(q_ids[i]+'_n').style.borderWidth	= ""
		document.getElementById(q_ids[i]+'_n').style.borderStyle	= ""
	}
	//document.getElementById('cs_needed').style.display = "none";
	$('#cs_needed').hide('slow');
}
function check_cs(answer,passed_id){
	var q_ids	= new Array(
			'manual',
			'e_checks',
			'needle',
			'redflag',
			'msds',
			'training',
			'posters',
			'hepb'
		);

	switch (answer){
	case "n":
		document.getElementById(passed_id+'_no').value = "true";

		document.getElementById(passed_id+'_n').style.backgroundColor = "yellow";
		document.getElementById(passed_id+'_n').style.padding		= "1px"
		document.getElementById(passed_id+'_n').style.borderWidth	= "2px"
		document.getElementById(passed_id+'_n').style.borderStyle	= "solid"
		document.getElementById(passed_id+'_n').style.borderColor	= "#4040FF"

		document.getElementById(passed_id+'_y').style.borderColor	= ""
		document.getElementById(passed_id+'_y').style.backgroundColor = "";
		document.getElementById(passed_id+'_y').style.padding		= ""
		document.getElementById(passed_id+'_y').style.borderWidth	= ""
		document.getElementById(passed_id+'_y').style.borderStyle	= ""
		break;
	case "y":
		document.getElementById(passed_id+'_no').value = "false";

		document.getElementById(passed_id+'_y').style.backgroundColor = "yellow";
		document.getElementById(passed_id+'_y').style.padding		= "1px"
		document.getElementById(passed_id+'_y').style.borderWidth	= "2px"
		document.getElementById(passed_id+'_y').style.borderStyle	= "solid"
		document.getElementById(passed_id+'_y').style.borderColor	= "#4040FF"

		document.getElementById(passed_id+'_n').style.borderColor	= ""
		document.getElementById(passed_id+'_n').style.backgroundColor = "";
		document.getElementById(passed_id+'_n').style.padding		= ""
		document.getElementById(passed_id+'_n').style.borderWidth	= ""
		document.getElementById(passed_id+'_n').style.borderStyle	= ""
		break;
	}

	var any_nos	= false;

	for (i=0;i<q_ids.length ;i++ ){
		if (document.getElementById(q_ids[i]+'_no').value == "true"){
			any_nos = true;
		}
	}
	if (any_nos){
		//document.getElementById('cs_needed').style.display = "";
		$('#cs_needed').show('slow');
	} else {
		//document.getElementById('cs_needed').style.display = "none";
		$('#cs_needed').hide('slow');
	}

}

function process_length(p,min,max){
	//var too_short	= false;
	//var too_long	= false;
	var the_length	= "";

	if (p.length > max){
		//too_long = true;
		//too_short = false;
		the_length	= "too_long";
	}
	if (p.length < min){
		//too_short = true;
		//too_long = false;
		the_length	= "too_short";
	}

	return the_length;

}
// check_plength - multi-purpose - pass the id to manipulate
// warning tags containing too-long or too-short warnings
function check_plength(passed_id, is_new){
	if(!is_new){
		is_new = 'false';
	}

//	var password_id = "";
//	if (is_new == "true"){
//		password_id	= "new_password_" + passed_id;
//	} else {
//		var password_id	= "password_" + passed_id;
//	}

	var p			= document.getElementById('password').value;
	var min			= 8; // minimum length
	var max			= 12; // maximum length
	var the_length	= process_length(p,min,max);

	if (p.length > 0){

		if (the_length == "too_short" || the_length == "too_long")		{
				//document.getElementById('btn_' + passed_id).style.display = "none";
				$('#btn_' + passed_id).slideUp('slow');
				//document.getElementById(passed_id + '_fix_password').style.display = "";
				$('#'+passed_id + '_fix_password').slideDown('slow');
				//document.getElementById('good_plength_' + passed_id).style.display = "none";
				$('#good_plength_' + passed_id).slideUp('slow');
			if (the_length == "too_short"){
				//document.getElementById('too_short_length_' + passed_id).style.display = "";
				//document.getElementById('too_long_length_' + passed_id).style.display = "none";
				$('#too_short_length_' + passed_id).slideDown('slow');
				$('#too_long_length_' + passed_id).slideUp('slow');
			}
			if (the_length == "too_long"){
				//document.getElementById('too_long_length_' + passed_id).style.display = "";
				//document.getElementById('too_short_length_' + passed_id).style.display = "none";
				$('#too_short_length_' + passed_id).slideUp('slow');
				$('#too_long_length_' + passed_id).slideDown('slow');
			}
		} else {

//				document.getElementById('good_plength_' + passed_id).style.display = "";
//				document.getElementById('too_short_length_' + passed_id).style.display = "none";
//				document.getElementById('too_long_length_' + passed_id).style.display = "none";
//				document.getElementById('btn_' + passed_id).style.display = "";
//				document.getElementById(passed_id + '_fix_password').style.display = "none";

				$('#good_plength_' + passed_id).slideDown('slow');
				$('#too_short_length_' + passed_id).slideUp('slow');
				$('#too_long_length_' + passed_id).slideUp('slow');
				$('#btn_' + passed_id).slideDown('slow');
				$('#' + passed_id + '_fix_password').slideUp('slow');
		
		}



	} else {

//		document.getElementById('good_plength_' + passed_id).style.display = "none";
//		document.getElementById('too_short_length_' + passed_id).style.display = "none";
//		document.getElementById('too_long_length_' + passed_id).style.display = "none";
//		document.getElementById('btn_' + passed_id).style.display = "";
//		document.getElementById(passed_id + '_fix_password').style.display = "none";


		$('#good_plength_' + passed_id).slideUp('slow');
		$('#too_short_length_' + passed_id).slideUp('slow');
		$('#too_long_length_' + passed_id).slideUp('slow');
		$('#btn_' + passed_id).slideDown('slow');
		$('#' + passed_id + '_fix_password').slideUp('slow');
	}
}


function get_background_color(){
	var background_color	= "#FFDA56";
	return background_color;
}
function get_border_color(){
	var border_color		= "#153F6F";
	return border_color;
}
function get_border_width(){
	var border_width		= "1px";
	return border_width;
	
}


function validate_cycle(required_inputs){

	var background_color	= get_background_color();
	var border_color		= get_border_color();
	var border_width		= get_border_width();

	var err_found = false;
	for (i=0;i<required_inputs.length;i++){
		document.getElementById(required_inputs[i]).style.backgroundColor = '';
		document.getElementById(required_inputs[i]).style.borderColor = '';
		document.getElementById(required_inputs[i]).style.borderWidth = '';
	}
	for (i=0;i<required_inputs.length;i++)
	{
		if (document.getElementById(required_inputs[i]).value == "") {
			//alert('i: '+ required_inputs[i]);
			err_found = true;
//			document.getElementById(required_inputs[i]).style.zIndex = "9999999";
//			document.getElementById(required_inputs[i]).style.position = "relative";
//			document.getElementById(required_inputs[i]).style.left = "100px";

			//$("#facebox").hide();

			document.getElementById(required_inputs[i]).style.backgroundColor = background_color;
			document.getElementById(required_inputs[i]).style.borderColor = border_color;
			document.getElementById(required_inputs[i]).style.borderWidth = border_width;
		}
	}
	
	return err_found;
}







function verify_add(section){


	$('#processing').show('slow');

	switch (section){
	case "client":
	case "edit_client":
		var required_inputs = new Array();
	/*
		var required_inputs = new Array(
			'company_name',
			'contact_first_name',
			'contact_last_name',
			'contact_title',
			'email',
			'address',
			'city',
			'state_id',
			'zip',
			'phone',
			'fax',
			'website',
			'best_time_to_contact',
			'profile',
			'comments',
			'accept_h1',
			'accept_j1',
			'responsible_employee_guid',
			'active',
			'contract_fee',
			'contract_terms',
			'date_contract_sent',
			'date_contract_received'
		);
		*/
		break;
	case "job":
	case "edit_job":
		var required_inputs = new Array(
			'client_guid',
			'job_title',
			'public_job_description',
			'internal_job_description',
			'start_date',
			'job_profession_id',
			'job_specialty_id',
			'job_type_id',
			'city',
			'job_state_id',
			'active',
			'visa_accepted'
		);
		break;
	case "candidate":
	case "edit_candidate":
		var required_inputs = new Array(
			'first_name_candidate',
			'last_name_candidate'
		);
		break;
	case "candidate_cv":
		var required_inputs = new Array(
			'first_name',
			'last_name',
			'candidate_add_profession_id',
			'candidate_add_specialty_id',
			'address',
			'city',
			'candidate_state_id',
			'zip',
			'email',
			'file_cv',
			'phone',
			'best_time_day_2_call'

		);
		break;
	case "info_request":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'email',
			'city',
			'state',
			'phone',
			'best_time',
			'recruitment_needs'
		);
		break;
	case "candidate_info_request":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'email',
			'city',
			'state',
			'phone',
			'best_time',
			'category'
		);
		break;
	case "employee":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'access_level_id',
			'username',
			'password',
			'phone',
			'email',
			'active'
		);
		break;
	
	case "edit_employee":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'access_level_id',
			'username',
			'phone',
			'email',
			'active'
		);
		break;
	}

	var err_found = false;
	var err_msg = "\n\nto continue, please complete the highlighted entries:\n\n";

	err_found = validate_cycle(required_inputs);

	switch(section){
		case "employee":
			// need to ensure both passwords match
			if ( $('#password').val() != "") {
				if ($('#password').val() != $('#password2').val()  ) {
					err_found = true;
					err_msg += "- also ensure passwords match.\n\n";
				}
			}
			break;
		case "edit_employee":
			// need to ensure both passwords match, but only if a password is entered
			if ( $('#password').val() != "") {
				if ($('#password').val() != $('#password2').val()  ) {
					err_found = true;
					err_msg += "- also ensure passwords match.\n\n";
				}
			}
			break;
		case "candidate_cv":
		case "info_request":
			// need to ensure both emails match
			if ( $('#email').val() != "") {
				if ($('#email').val() != $('#email2').val()  ) {
					err_found = true;
					err_msg += "- also ensure emails match.\n\n";
				}
			}
			break;
	}


	if (err_found) {
		$('#processing').hide('slow');
        $('#add_processing').hide('slow');
		alert(err_msg);
		return false;

	} else {
		switch (section){
		case "client":
			//alert(section);
			xajax_Client.createClient(xajax.getFormValues('form_add_edit_client') );
			break;
		case "edit_client":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Client.updateClient(xajax.getFormValues('form_edit_client') );
			break;
		case "job":
			//alert(section);
			xajax_Job.createJob(xajax.getFormValues('form_add_job') )
			break;
		case "edit_job":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Job.updateJob(xajax.getFormValues('form_edit_job') )
			break;
		case "edit_candidate":
			//alert(section);
			xajax_Candidate.updateCandidate(xajax.getFormValues('form_edit_candidate'), 1 );
			break;
		case "candidate":
			//alert(section);
	        jQuery('#add_processing').show('slow');
			xajax_Candidate.createCandidate(xajax.getFormValues('form_add_edit_candidate'), 1 );
			// the '1' as the last parameter - helps us fix a problem with having specialty_id
			// on the same page of the employee portal - one for search the other for add/
			// edit candidate - this tells createCandidate() to fix by setting it to 
			// specialty_id and unset'ting candidate_add_specialty_id
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			break;
		case "candidate_cv":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#addgonzo').attr("action", "candidates_cv.php");
			$("form:addgonzo").submit();
			break;
		case "info_request":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#form_client_assistance').attr("action", "info_request.php");
			$("form:#form_client_assistance").submit();
			break;
		case "candidate_info_request":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#form_candidate_assistance').attr("action", "info_request_candidate.php");
			$("form:#form_candidate_assistance").submit();
			break;
		case "employee":
			//alert(section);
			xajax_Employee.createEmployee(xajax.getFormValues('form_add_edit_employee'), 1 );
			break;
		case "edit_employee":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Employee.updateEmployee(xajax.getFormValues('form_edit_employee'), 1 );
			break;
		}
	}

}








function verify_portal_add_edit(section){


	$('#portal_processing').show('slow');

	switch (section){
	case "portal-client-add":
	case "portal-client-edit":
	case "edit_client":
		var required_inputs = new Array();
	/*
		var required_inputs = new Array(
			'company_name',
			'contact_first_name',
			'contact_last_name',
			'contact_title',
			'email',
			'address',
			'city',
			'state_id',
			'zip',
			'phone',
			'fax',
			'website',
			'best_time_to_contact',
			'profile',
			'comments',
			'accept_h1',
			'accept_j1',
			'responsible_employee_guid',
			'active',
			'contract_fee',
			'contract_terms',
			'date_contract_sent',
			'date_contract_received'
		);
		*/
		break;
	case "job":
	case "edit_job":
		var required_inputs = new Array(
			'client_guid',
			'job_title',
			'public_job_description',
			'internal_job_description',
			'start_date',
			'job_profession_id',
			'job_specialty_id',
			'job_type_id',
			'city',
			'job_state_id',
			'active',
			'visa_accepted'
		);
		break;
	case "candidate":
	case "edit_candidate":
		var required_inputs = new Array(
			'first_name_candidate',
			'last_name_candidate'
		);
		break;
	case "candidate_cv":
		var required_inputs = new Array(
			'first_name',
			'last_name',
			'candidate_add_profession_id',
			'candidate_add_specialty_id',
			'address',
			'city',
			'candidate_state_id',
			'zip',
			'email',
			'file_cv',
			'phone',
			'best_time_day_2_call'

		);
		break;
	case "info_request":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'email',
			'city',
			'state',
			'phone',
			'best_time',
			'recruitment_needs'
		);
		break;
	case "candidate_info_request":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'email',
			'city',
			'state',
			'phone',
			'best_time',
			'category'
		);
		break;
	case "employee":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'access_level_id',
			'username',
			'password',
			'phone',
			'email',
			'active'
		);
		break;
	
	case "edit_employee":
		var required_inputs = new Array(
			'title',
			'first_name',
			'last_name',
			'access_level_id',
			'username',
			'phone',
			'email',
			'active'
		);
		break;
	}

	var err_found = false;
	var err_msg = "\n\nto continue, please complete the highlighted entries:\n\n";

	err_found = validate_cycle(required_inputs);

	switch(section){
		case "employee":
			// need to ensure both passwords match
			if ( $('#password').val() != "") {
				if ($('#password').val() != $('#password2').val()  ) {
					err_found = true;
					err_msg += "- also ensure passwords match.\n\n";
				}
			}
			break;
		case "edit_employee":
			// need to ensure both passwords match, but only if a password is entered
			if ( $('#password').val() != "") {
				if ($('#password').val() != $('#password2').val()  ) {
					err_found = true;
					err_msg += "- also ensure passwords match.\n\n";
				}
			}
			break;
		case "candidate_cv":
		case "info_request":
			// need to ensure both emails match
			if ( $('#email').val() != "") {
				if ($('#email').val() != $('#email2').val()  ) {
					err_found = true;
					err_msg += "- also ensure emails match.\n\n";
				}
			}
			break;
	}


	if (err_found) {
		$('#processing').hide('slow');
        $('#add_processing').hide('slow');
		alert(err_msg);
		return false;

	} else {
		switch (section){
		case "portal-client":
			//alert(section);
			xajax_Client.portalAddClient(xajax.getFormValues('form_portal_client_add') );
			break;
		case "edit_client":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Client.updateClient(xajax.getFormValues('form_edit_client') );
			break;
		case "job":
			//alert(section);
			xajax_Job.createJob(xajax.getFormValues('form_add_job') )
			break;
		case "edit_job":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Job.updateJob(xajax.getFormValues('form_edit_job') )
			break;
		case "edit_candidate":
			//alert(section);
			xajax_Candidate.updateCandidate(xajax.getFormValues('form_edit_candidate'), 1 );
			break;
		case "candidate":
			//alert(section);
	        jQuery('#add_processing').show('slow');
			xajax_Candidate.createCandidate(xajax.getFormValues('form_add_edit_candidate'), 1 );
			// the '1' as the last parameter - helps us fix a problem with having specialty_id
			// on the same page of the employee portal - one for search the other for add/
			// edit candidate - this tells createCandidate() to fix by setting it to 
			// specialty_id and unset'ting candidate_add_specialty_id
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			break;
		case "candidate_cv":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#addgonzo').attr("action", "candidates_cv.php");
			$("form:addgonzo").submit();
			break;
		case "info_request":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#form_client_assistance').attr("action", "info_request.php");
			$("form:#form_client_assistance").submit();
			break;
		case "candidate_info_request":
			//alert(section);
			//xajax_User.createCandidate(xajax.getFormValues('form_add_candidate') )
			$('#form_candidate_assistance').attr("action", "info_request_candidate.php");
			$("form:#form_candidate_assistance").submit();
			break;
		case "employee":
			//alert(section);
			xajax_Employee.createEmployee(xajax.getFormValues('form_add_edit_employee'), 1 );
			break;
		case "edit_employee":
			//alert(section);
		    $("#edit_processing").show('slow');
			xajax_Employee.updateEmployee(xajax.getFormValues('form_edit_employee'), 1 );
			break;
		}
	}

}

function testfill() {
// simply used to save time when testing adding a candidate
	var fields = new Array(
	"title",
	"first_name",
	"last_name",
	"degree",
	"residency",
	"sub_specialty",
	"other_info",
	"area_of_interest",
	"desired_city",
	"when_available",
	"email",
	"phone",
	"address",
	"city",
	"zip",
	"cell_phone",
	"pager",
	"work_status",
	"call_schedule",
	"salary_expectations",
	"interview_activity",
	"my_references",
	"notes",
	"source",
	"internal_description",
	"public_description",
	"additional_contact_info",
	"best_time_day_2_call",
	"significant_other_name",
	"significant_other_need_job",
	"family_resides",
	"citizenship_status",
	"foreign_language_info",
	"esl_skill",
	"current_practice_setup_call_coverage",
	"why_leaving_present_job",
	"location_preferences",
	"why_did_choose_location",
	"desired_community",
	"desired_compensation_package",
	"any_license_privilege_problems",
	"any_malpractice_suits",
	"past_drug_alcohol_abuse_treatment",
	"national_practitioner_dbase_report",
	"profile",
	"comments"
	);

	for (var i=0;i<fields.length;i++){
			document.getElementById(fields[i]).value = fields[i];
	}
}




///////////////////// NEW PORTAL FUNCTIONS ///////////////////////////


function check_practice_type(type, practice_num) {
	// if we're working with a practice (we passed practice_num)
	// then we need to indicate the correct practice
	var pn	= "";
	if (practice_num){
		pn	= "practice_" + practice_num + "_";
	}
	if (type != ""){
		if (type == "1"){ // other
			$("#"+pn+"practice_type_other").val('');
			$("#"+pn+"practice_type_other_holder").slideDown();
			$("#"+pn+"hospital_beds_holder").slideUp();
		} else if (type == "10")	{ // hospital
			$("#"+pn+"beds").val('');
			$("#"+pn+"academic_affiliation").val('');
			$("#"+pn+"practice_type_other_holder").slideUp();
			$("#"+pn+"hospital_beds_holder").slideDown();
		} else {
			$("#"+pn+"practice_type_other").val('');
			$("#"+pn+"beds").val('');
			$("#"+pn+"academic_affiliation").val('');
			$("#"+pn+"practice_type_other_holder").slideUp();
			$("#"+pn+"hospital_beds_holder").slideUp();

		}
	} else {
	}
}


function build_contacts_inputs(num, edit) {
	var new_contact	= "";
	if (edit)	{
		new_contact	= " NEW ";
	}

	if (num != "" ){


		//createContactsInputs( $("#num_contacts").val() );

		var content_label_td	= '<td align="right" valign="top" class="content_label">';
		var content_info_td		= '<td align="left" valign="top" class="content_info">';

		var inputs	= "<table cellspacing='0' cellpadding='3' border='0' width='100%'>";

		var contact_fields	= new Array();
		contact_fields[0]	=	'Contact First Name:::contact_first_name:::45';
		contact_fields[1]	=	'Contact Last Name:::contact_last_name:::45';
		contact_fields[2]	=	'Contact Title:::contact_title:::45';
		contact_fields[3]	=	'Contact Email:::contact_email:::60';
		contact_fields[4]	=	'Contact Phone:::contact_phone:::20';
		contact_fields[5]	=	'Contact Fax:::contact_fax:::20';
		contact_fields[6]	=	'Contact Best Time to Call:::contact_best_time_to_call:::45';



		for (var i = 1; i<=num ; i++) {

			inputs += '<tr><td colspan="2" align="left" valign="top" style="border-top: 1px solid #000000;border-bottom: 1px solid #000000;font-weight: bold;font-size:90%;">';
			inputs += 'FIELDS FOR '+ new_contact +' CONTACT #' + i;
			if (edit){
				inputs += "<input type='hidden' id='contact_id_new_" + num + "' name='contact_id[]' value='0' />";
			}
			inputs += "</td></tr>";
			var f	= "";
			var x	= "";
			for (x in contact_fields) {

				f	= contact_fields[x].split(":::");
				inputs += '<!-- ------------------- details row start -------------------------- -->';
				inputs += '<tr>';
				inputs += content_label_td;
				inputs += f[0] + ': ';
				inputs += '</td>';

				inputs += content_info_td;
				inputs += '<input type="text" id="' +f[1]+ '" name="' +f[1]+ '[]" size="' + f[2]+ '" value="" />';
				inputs += '</td>';

				inputs += '</tr>';

			}
		}
		inputs += "</table>";

		$("#contacts_inputs").html(inputs);

	} else {
		$("#contacts_inputs").html('');

	}
}

function get_portal_specialities(pid, update_id, sids) {
	if ($('#profession_' + pid + ':checked' ).attr('checked') ) {
		$('#specialties_by_profession_' + pid + 'status').show();
		xajax_Misc.getPortalSpecialties(pid,0,1,0,update_id, sids);
	} else {
		$('#specialties_by_profession_' + pid ).hide();
	}
}

function dashboard_get_practice_specialities_by_pid(pid, practice_num, update_id, sids) {

	if ($('#practice_'+practice_num+'_profession_' + pid + ':checked' ).attr('checked') ) {
		$('#practice_'+practice_num+'_specialties_by_profession_' + pid + 'status').show();
		xajax_Misc.getPortalSpecialties(pid,0,1,0,update_id, sids, practice_num);
	} else {
		$('#practice_'+practice_num+'_specialties_by_profession_' + pid ).hide();
	}
}


function HOLDget_portal_specialities(pid, update_id, sids) {
	var uid	= "";
	if (update_id != ""){
		uid	= update_id;
	}

	if ($('#'+uid+'profession_' + pid + ':checked' ).attr('checked') ) {
		$('#'+uid+'specialties_by_profession_' + pid + 'status').show();
		xajax_Misc.getPortalSpecialties(pid,0,1,0,update_id, sids);
	} else {
		$('#'+uid+'specialties_by_profession_' + pid ).hide();
	}
}


// ################## jQuery ################################

// STUFF THAT AUTOMATICALLY LOADS WHEN DOC IS READY TO BE MANIPULATE
$(document).ready(function(){

	// loading the email blast preview
	$("#btn_email_blast_preview").click(function() {
		$("#email_blast_preview_holder").text('Generating Preview ...');
		$("#email_blast_inputs").fadeOut();
		$("#email_blast_preview_holder").fadeIn();
		$("#fix_send_buttons").fadeIn();
		$("#email_blast_send_results").text('');
		xajax_Misc.generateEmailBlastPreview(xajax.getFormValues('form_email_blaster') )
	});


	// loading the email blast preview
//	$("btn_email_blast").click(function() {
//		$("email_blast_send_results").text('Processing ...');
//		xajax_Misc.generateEmailBlast(xajax.getFormValues('form_email_blaster') )
//	});




//// let's do a quick precheck in the email blaster to see how many recipients
//// there will be based on changes to / selection of profession, specialty, region

	$("#email_blast_candidate_add_profession_id").change(function () {
		xajax_Misc.calcBlastRecipients(xajax.getFormValues('form_email_blaster') );

	});

//	$("#email_blast_candidate_specialty_id").change(function () {
//		alert('specialtyidval: ' + $("#email_blast_candidate_specialty_id").val() );
//		xajax_Misc.calcBlastRecipients(xajax.getFormValues('form_email_blaster') );
//
//	});
//

	$(".regions_checkbox").click(function () {
		xajax_Misc.calcBlastRecipients(xajax.getFormValues('form_email_blaster') );

	});



///// NEW PORTAL ACTIONS



	$("#btn_portal_client_client_add").click(function() {
		$("#processing").show('slow');
		verify_portal_add_edit('portal-client-add');
        //alert('here');
	});


	$("#btn_portal_client_client_edit").click(function() {
		$("#processing").show('slow');
		verify_portal_add_edit('portal-client-edit');
        //alert('here');
	});

});

/* deprecated

	$("#num_contactsaaa").change(function () {
		if ($("#num_contacts").val() != "" ){

			alert ('yo');

			//createContactsInputs( $("#num_contacts").val() );

			var content_label_td	= '<td align="right" valign="top" class="content_label">';
			var content_info_td		= '<td align="left" valign="top" class="content_info">';

			var inputs	= "<table cellspacing='0' cellpadding='3' border='1'>";
			var contact_fields	= new Array(
				'Contact First Name:::contact_first_name:::45',
				'Contact Last Name:::contact_last_name:::45',
				'Contact Title:::contact_title:::45',
				'Contact Email:::contact_email:::60',
				'Contact Phone:::contact_phone:::20',
				'Contact Fax:::contact_fax:::20',
				'Contact Best Time to Call:contact_best_time_to_call:::45'
				);



			for (var i = 1; i<=$("#num_contacts").val() ; i++) {

				for (x in contact_fields) {

					var f	= x.split(":::");
					inputs += '<!-- ------------------- details row start -------------------------- -->';
					inputs += '<tr>';
					inputs += content_label_td;
					inputs += f[0] + ': ';
					inputs += '</td>';

					inputs += content_info_td;
					inputs += '<input type="text" id="' +f[1]+ '" name="' +f[1]+ '[]" size="' + f[2]+ '" value="" />';
					inputs += '</td>';

					inputs += '</tr>';

				}
			}
			inputs += "</table>";

			$("#contacts_inputs").html(inputs);

		}

	});
*/


