function showSection(clicked, section)
{
    var s = $(section);
    var showing = ('none' === s.style['display']) ? false : true;
    if (showing) {
        //clicked.removeClassName('accordion_toggle_active');
        new Effect.BlindUp(s, {
            duration:0.5
        });
    } else {
        //clicked.addClassName('accordion_toggle_active');
        new Effect.BlindDown(s, {
            duration:0.5
        });
    }
}

var url = '/demo/rpc.php';

function post_info( sub ) {

    new Ajax.Request(url, {
        postBody: 'action=postinfo' +
        '&practice_name=' + $F( 'info_practice_name' + sub ) +
        '&contact_fname=' + $F( 'info_contact_fname' + sub ) +
        '&contact_lname=' + $F( 'info_contact_lname' + sub ) +
        '&specialty=' + $F( 'info_specialty' + sub ) +
        '&email_address=' + $F( 'info_email_address' + sub ) +
        '&phone_number=' + $F( 'info_phone_number' + sub ) +
        '&state=' + $F( 'info_state' + sub ) +
        '&zipcode=' + $F( 'info_zipcode' + sub ) +
        '&promo_code=' + $F( 'info_promo_code' + sub ),
        
        onSuccess: function(transport, json) {

            // respone to user
            alert( json.message );

            // clear if sucessfull
            if ( json.sucess == true ) {
                $( 'info_practice_name' + sub ).clear();
                $( 'info_contact_fname' + sub ).clear();
                $( 'info_contact_lname' + sub ).clear();
                $( 'info_specialty' + sub ).selectedIndex = 0;
                $( 'info_email_address' + sub ).clear();
                $( 'info_phone_number' + sub ).clear();
                $( 'info_state' + sub ).selectedIndex = 0;
                $( 'info_zipcode' + sub ).clear();
                $( 'info_promo_code' + sub ).clear();

                pageTracker._trackPageview('/demo/advancewithchase/post_info');
            }            
        }
    });
}

function post_login() {

    new Ajax.Request(url, {
        postBody: 'action=postlogin' +
        '&provider_id=' + $F( 'login_provider_id' ) +
        '&practice_name=' + $F( 'login_practice_name' ) +
        '&contact_fname=' + $F( 'login_contact_fname' ) +
        '&contact_lname=' + $F( 'login_contact_lname' ) +
        '&state=' + $F( 'login_state' ) +
        '&zipcode=' + $F( 'login_zipcode' ) +
        '&phone_number=' + $F( 'login_phone_number' ),

        onSuccess: function(transport, json) {

            // Show the videos if authenticated correctly.
            if ( json.sucess == true ) {
                parent.window.location = parent.window.location + '?x=' + json.session_id

            } else {
                alert( json.message );
            }
        }
    });
}

function clear_login() {
    $( 'login_provider_id' ).clear();
    $( 'login_practice_name' ).clear();
    $( 'login_contact_fname' ).clear();
    $( 'login_contact_lname' ).clear();
    $( 'login_phone_number' ).clear();
    $( 'login_state' ).selectedIndex = 0;
    $( 'login_zipcode' ).clear();
}

function show_login(){
    
    new lightwindow().activateWindow({
	        href: 'login.htm',
            title: '',
	        width:367,
            height:500
	   });
	}

function post_feedback() {

    new Ajax.Request(url, {
        postBody: 'action=postfeedback' +
        '&provider_id=' + $F( 'feedback_provider_id' ) +
        '&contact_fname=' + $F( 'feedback_contact_fname' ) +
        '&contact_lname=' + $F( 'feedback_contact_lname' ) +
        '&specialty=' + $F( 'feedback_specialty' ) +
        '&phone_number=' + $F( 'feedback_phone_number' ) +
        '&email_address=' + $F( 'feedback_email_address' ) +
        '&feedback=' + $F( 'feedback_feedback' ),

        onSuccess: function(transport, json) {

            if ( json.sucess == true ) {
                window.location = 'thanks.htm' + window.location.search;
            
            } else {
                alert( json.message );
            }
        } 
    });
}
