//Go Social Scripts..probably move these off to a file.

/***
 * TWITTER
 ***/
// ------------------------------------------------------
//  does the twitter import
// ------------------------------------------------------
function setTwitterCredentials() {
    //$('twitter-import-spinner').show();

    // post to server and start import
    new Ajax.Request("/ajax/set-twitter-credentials.iggli", {
        method: 'post',
        parameters: {twitterUsername: $F('twitterUsername'), twitterPassword: $F('twitterPassword'), inviteId: $F('inviteId')},
        onSuccess: function(transport) {
			$('go-social-box').update(transport.responseText);
        }
    });

}

function sendGoSocialNetwork(checkBox) {
    var socialNetworkName = $(checkBox).readAttribute('name');
    var inviteId = $(checkBox).readAttribute('inviteId');
    var isOn = $F(checkBox) == "true" ? true : false; //this is either true or null so taking care of that here.
	$('loading').show();
    if (isOn) {
        new Ajax.Request("/ajax/add-twitter-feed.iggli", {method:'post',
            parameters:{inviteId: inviteId},
            onComplete:function(transport) {
            	$('loading').hide();
            	var element = $('twitter-prefs-message');
            	element.show();
            	element.update("");
            	new Effect.Highlight(element);
            	element.update("twitter is on");
            	new Effect.Fade(element);
            	updateMessages(inviteId);
            }
        });

    } else {
        new Ajax.Request("/ajax/remove-twitter-feed.iggli", {method:'post',
            parameters:{inviteId: inviteId},
            onComplete:function(transport) {
            	$('loading').hide();
            	var element = $('twitter-prefs-message');
            	element.show();
            	element.update("");
            	new Effect.Highlight(element);
            	element.update("twitter is off");
            	new Effect.Fade(element);
            	updateMessages(inviteId);
            }
        });

    }


}

function updateMessages(inviteId) {
	new Ajax.Updater('comments-box','/ajax/update-invite-comments.iggli', {
  		parameters: { "inviteId": inviteId} 
  	});
}

function sendGoSocialNetworkOption(checkBox, socialNetworkName) {
    var socialNetworkName = socialNetworkName;//a string I guess.
    var option = $(checkBox).readAttribute('name');
    var isOn = $F(checkBox) == "true" ? true : false; //this is either true or null so taking care of that here.
    //new AJAX request I'm guessing.
}

//A bunch of really specific dom shite in the following functions.
function showFacebookOptions() {
    if ($('facebook-prefs').visible() == false) {
        Effect.BlindDown('facebook-prefs');
        $('facebook-prefs-edit').hide();
        $('facebook-prefs-hide').show();
    }
}

function hideFacebookOptions() {
    if ($('facebook-prefs').visible() == true) {
        Effect.BlindUp('facebook-prefs');
        $('facebook-prefs-hide').hide();
        $('facebook-prefs-edit').show();
    }
}

function showTwitterOptions() {
    if ($('twitter-prefs').visible() == false) {
        Effect.BlindDown('twitter-prefs');
        $('twitter-prefs-edit').hide();
        $('twitter-prefs-hide').show();
    }
}

function hideTwitterOptions() {
    if ($('twitter-prefs').visible() == true) {
        Effect.BlindUp('twitter-prefs');
        $('twitter-prefs-hide').hide();
        $('twitter-prefs-edit').show();
    }
}

function showMySpaceOptions() {
    if ($('myspace-prefs').visible() == false) {
        Effect.BlindDown('myspace-prefs');
        $('myspace-prefs-edit').hide();
        $('myspace-prefs-hide').show();
    }
}
function hideMySpaceOptions() {
    if ($('myspace-prefs').visible() == true) {
        Effect.BlindUp('myspace-prefs');
        $('myspace-prefs-hide').hide();
        $('myspace-prefs-edit').show();
    }


function submitTwitterGoSocial() {
    new Ajax.Updater('')
}



}