// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

//Event.observe(window, 'load', function() {
//    $('user_country').observe('change',show_inline_offers);
//});

function mark_for_destroy(element) {
    $(element).next('.should_destroy').value = 1;
    $(element).up('.direct_track_detail').hide();
}

function show_inline_offers(){
	if ($('inline_offers')){
		Effect.Appear('inline_offers');
	}
}

function show_mom_question(){

    if ($('user_mom_with_children_under_18_row') == undefined){
        html = '<tr id="user_mom_with_children_under_18_row">\n';
        html+= '<td colspan="2" id="mother_td" style="display: none; text-align: center;">\n';
        html+= 'Do you have children under age 18? <br />\n';
        html+= '<div id="user_mom_with_children_under_18">\n';
        html+= '<input id="user_mom_with_children_under_18_true" name="user[mom_with_children_under_18]" type="radio" value="true" /> Yes &nbsp;\n';
        html+= '<input id="user_mom_with_children_under_18_false" name="user[mom_with_children_under_18]" type="radio" value="false" /> No\n';
        html+= '</div>\n'
        html+= '</td>\n';
        html+= '</tr>\n';
        
        $('user_gender_row').insert({after:html});
        Effect.Appear($('mother_td'));
    }
    
}

function remove_mom_question(){
	if ($('user_mom_with_children_under_18_row')){
        
		Effect.Fade('user_mom_with_children_under_18_row',{
			duration: .5,
			afterFinish: function(){$('user_mom_with_children_under_18_row').remove();}
			});

    }
}

function remove_validation_error_messages(){

    $$('.validation_errors').each(function(element) {
        element.remove();
    });

}

function add_country(country) {
    cc_fips = country.id.gsub('country_','');

    //alert(cc_fips);
		if($(cc_fips+"_selected") == undefined){
    	html = '<div id="'+cc_fips+'_selected">';
	    html += '<input checked="checked" onclick="$(\'' + cc_fips + '_selected\').remove()" id="demographic_country_ids_" name="demographic[country_ids][]" type="checkbox" value="'+cc_fips+'" />';
	    html += country.innerHTML + "</div>";
    	$('selected_countries').insert({before:html});
		}
}