var SERVICES = {
    'classical' :           { 'apply' : 'online' },
	'easy' :                { 'apply' : 'online' }, 
	'jobboard_email_feat' : { 'apply' : 'instructions' }, 
	'jobboard_email' :      { 'apply' : 'instructions' }, 
	'jobboard_feat' :       { 'apply' : 'instructions' }, 
	'jobboard' :            { 'apply' : 'instructions' }
};


function chooseApplyType(which) {
    if(which == 'online') {
	    $('online').style.display = 'block';
	    $('instructions').style.display = 'none';
	    $('start').style.display = 'none';
	} else {
	    $('online').style.display = 'none';
	    $('instructions').style.display = 'block';
	    $('start').style.display = 'none';
	}
}



function hookServiceType() {
    // do mode change stuff
	var control = $('service-type-selection');
	
	if(!isUndefinedOrNull(control)) {
	$('online').style.display = 'none';
	$('instructions').style.display = 'none';

	
	    forEach(keys(SERVICES), function(e) {
		    var button = $('service-' + e),
			    applyType = SERVICES[e]['apply'];
				
			button.onclick = function(f) {
			    chooseApplyType(applyType);
		    }
		});
		
		function resetApplyType() {
		    var foundOne = false;
			forEach(keys(SERVICES), function(e) {
				var button = $('service-' + e),
					applyType = SERVICES[e]['apply'];
				
				if (button.checked) { 
				    foundOne = true;
					chooseApplyType(applyType); 
				}
			});
		}
		
		resetApplyType();
    }
}


addLoadEvent(hookServiceType);
