/* profile/work */
function fadeandcurrent()
{
  checkbox = $('profile_work_is_current');
  datediv  = $('cd');
  if (checkbox.checked)
  {
  	$('profile_work_ended_at_year').style.display = 'none';
  	$('profile_work_ended_at_month').style.display = 'none';
  	datediv.show();
  }
  else
  {
  	$('profile_work_ended_at_year').style.display = 'inline';
  	$('profile_work_ended_at_month').style.display = 'inline';
  	datediv.hide();
  }

}

function prepareWorkForm(is_current)
{	
    if (is_current == '1' || is_current == 'on')
       fadeandcurrent();
    else $('profile_work_is_current').checked = false;

}

function reloadSubGroup(talentpool_id, field_name)
{
    var AR = new Ajax.Request('/index.php/profile/reloadSubGroup.html',
		{
			asynchronous: false,
			onComplete:   function(request, json)
            {
                var tempArray = json.new_options;
                var counter = 0;
                $(field_name).options.length=0;
                for (var unid in tempArray)
                {
                    $(field_name).options[counter++] = new Option( tempArray[unid], unid);
                }
            },
			parameters: 'talentpool_id='+talentpool_id
		});

	return false;
}

/* now all will have the professional set
function reloadIndustries(talentpool_id, form_name)
{
  if (talentpool_id != '')
  {
        new Ajax.Updater('IndustryFocus', '/index.php/profile/reloadIndustries.html',
    		{
    			asynchronous: false,
    			evalScripts:  false,
    			onComplete:   function(request, json){ },
    			parameters:   'talentpool_id='+talentpool_id+'&form_name='+form_name
    		});

  }
  return false;
}*/

function changeOptions(talentpool_id, field_name, form_name)
{
  reloadSubGroup(talentpool_id, field_name);
  //reloadIndustries(talentpool_id, form_name);
}



/* profile/contact details */
function addScreenName()
{
    if ($('user_profile_new_screen_name_name').value != '')
    {
        new Ajax.Updater('screen_names_list', '/index.php/profile/addScreenName.html',
    		{
    			asynchronous:true,
    			evalScripts:false,
    			insertion:Insertion.Bottom,
    			onLoading: updateGeneralNoticeMessageJQ("Adding screen name..."),
    			onComplete:function(request, json){new Effect.Highlight('screen_names_list', {}); $('user_profile_new_screen_name_name').value='';closeGeneralNoticeJQ();},
    			parameters: 'screen_name='+$('user_profile_new_screen_name_name').value+'&im_type_id='+$('user_profile_new_screen_name_im_type').value
    		});
    }
	return false;
}

/* profile/education */

function reloadUniversities(country_code)
{
    var AR = new Ajax.Request('/index.php/profile/reloadUniversities.html',
		{
			asynchronous: false,
			onComplete:   function(request, json)
            {
                var tempArray = json.new_options;
                var counter = 0;
                $('profile_has_profile_education_profile_education_id').options.length=0;
                for (var unid in tempArray)
                {
                    $('profile_has_profile_education_profile_education_id').options[counter++] = new Option( tempArray[unid], unid);
                }
            },
			parameters: 'country_code='+country_code
		});

	return false;
}

function checkOtherUniversity(val)
{
    if (val == 'other')
    {
        $('profile_has_profile_education_name').show();
    }
    else
    {
        $('profile_has_profile_education_name').hide();
    }
}

function prepareEducationForm(country_code,profile_education_id,other_edu_name)
{
    if (profile_education_id == 'other')
        $('profile_has_profile_education_profile_education_id').value = profile_education_id;
        
    if ($('profile_has_profile_education_profile_education_id').value != 'other')
    {
        $('profile_has_profile_education_name').hide();
    }
}

