// This function is used for changing the appearance of each form element when it GETS focus
function element_format_onfocus(element_id) {
    var element = document.getElementById(element_id);
    element.style.backgroundColor='#E2F3E2';
    element.style.borderColor='#77AB1F';
}


// This function is used for changing the appearance of each form element when it LOSTS focus
function element_format_onblur(element_id) {
    var element = document.getElementById(element_id);
    element.style.backgroundColor='#fff';
}



// This function is used for verifying that the user has entered data in a required ( 5 ) fields of a form in order to submitting it
// and we can add more required fields if it was more than 5 as shown in the function
function verify_required_data( id_of_form_to_submit, id_of_error_to_display, id_of_required_field_1, id_of_required_field_2, id_of_required_field_3, id_of_required_field_4, id_of_required_field_5 ) {
    var missing_data = false;
    if ( typeof id_of_required_field_1 != 'undefined' && document.getElementById( id_of_required_field_1 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_1 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_1 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_2 != 'undefined' && document.getElementById( id_of_required_field_2 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_2 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_2 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_3 != 'undefined' && document.getElementById( id_of_required_field_3 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_3 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_3 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_4 != 'undefined' && document.getElementById( id_of_required_field_4 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_4 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_4 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_5 != 'undefined' && document.getElementById( id_of_required_field_5 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_5 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_5 ).style.borderColor = '#FF5E7E';
    }

    if ( missing_data == false ) {
        document.getElementById( id_of_form_to_submit ).submit();
    } else {
        document.getElementById( id_of_error_to_display ).style.visibility = 'visible';
    }
}



function verify_required_banner_data( hint_id, id_of_form_to_submit, id_of_required_field_1, id_of_required_field_2, id_of_required_field_3, id_of_required_field_4, id_of_required_field_5 ) {
    var missing_data = false;
    if ( typeof id_of_required_field_1 != 'undefined' && document.getElementById( id_of_required_field_1 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_1 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_1 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_2 != 'undefined' && document.getElementById( id_of_required_field_2 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_2 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_2 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_3 != 'undefined' && document.getElementById( id_of_required_field_3 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_3 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_3 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_4 != 'undefined' && document.getElementById( id_of_required_field_4 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_4 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_4 ).style.borderColor = '#FF5E7E';
    }
    if ( typeof id_of_required_field_5 != 'undefined' && document.getElementById( id_of_required_field_5 ).value == '' ) {
        missing_data = true;
        document.getElementById( id_of_required_field_5 ).style.backgroundColor = '#F7D7D9';
        document.getElementById( id_of_required_field_5 ).style.borderColor = '#FF5E7E';
    }

    if ( missing_data == false ) {
        document.getElementById( id_of_form_to_submit ).submit();
    } else {
        document.getElementById( hint_id ).style.visibility = 'visible';
    }
}




function show_fixed_topic_form( form_to_display ) {
    document.getElementById( 'section_1' ).style.display = 'none';
    document.getElementById( 'section_2' ).style.display = 'none';
    document.getElementById( 'section_3' ).style.display = 'none';
    document.getElementById( 'section_4' ).style.display = 'none';
    document.getElementById( 'section_5' ).style.display = 'none';
    document.getElementById( form_to_display ).style.display = 'block';
}



function check_pr_window(){
    window.open("check-pr-pop-up.html", "check_pr_window", "scrollbars=yes, resizable=yes, width=800, height=600");
}




function display_banner_form(form_to_display, form_to_hide_1, form_to_hide_2) {
    document.getElementById( form_to_display ).style.display = 'block';
    document.getElementById( form_to_hide_1 ).style.display = 'none';
    document.getElementById( form_to_hide_2 ).style.display = 'none';
}

