/*
	CLIENTSIDE
	
	Set up the hover UI and click events for the list of vacancies
*/
function childcarer_register_Page()
{
	// Hacky bits for odd overseas rules
	var OVERSEAS_ID = '7';
	var accomchanged = false;
	
	var showoverseasfor = {	
		'London': true
	}
	//
	
	this.load = function()
	{		
		$('.prf_form_in_error').highlightFade({speed:2000, end:'#ffffff'});
		
		if($('#IsPostBack').val() != '1' || $('#Area').val() == $('#OVERSEAS_AREA_ID').val())
			$('#prfi_WillingToWorkOverseas').hide();
			
		$('#Area').change(this.areaChanged);
		
		$('#Accommodation input.radio').change(function(e) { accomchanged = true; });
	}
	
	// Various odd specific rules for overseas
	this.areaChanged = function(e)
	{
		var item = this.options[this.selectedIndex];
				
		if(showoverseasfor[item.text])
			$('#prfi_WillingToWorkOverseas').show();
		else
		{
			$('#prfi_WillingToWorkOverseas').hide();
			$('#WillingToWorkOverseas').attr('checked', false);
		}
			
		if(item.value == OVERSEAS_ID)
		{
			$('.roles_Nursery input').attr('disabled', true);
			$('.roles_Nursery input').attr('checked', false);
			$('.roles_Nursery').addClass('disabled');
			
			if(!accomchanged)
				$('#Accommodation_Live-in').attr('checked', true);
		}
		else
		{
			$('.roles_Nursery input').attr('disabled', false);
			$('.roles_Nursery').removeClass('disabled');
			
			if(!accomchanged)
				$('#Accommodation_Live-out').attr('checked', true);
		}
	}
}

HUI.MAIN(childcarer_register_Page);
