﻿socialControl = function() { };

socialControl.prototype.o_container = null;
socialControl.prototype.o_pop_features = 'scrollbars=yes,directories=0,height=420,location=0,menubar=0,status=0,titlebar=0,toolbar=0,width=840';
socialControl.prototype.v_url = null;
socialControl.prototype.v_title = null;

socialControl.prototype.init = function() {
    this.o_container = $('#' + arguments[0]);
};

socialControl.prototype.set_url = function() {
    this.v_url = 'http://' + window.location.hostname + arguments[0];
};

socialControl.prototype.set_title = function() {
    this.v_title = arguments[0];
};

socialControl.prototype.render_control = function() {
    var s = this;
    this.o_container.find('a').each(function() {
        var aclass = $(this).attr('class');
        switch (aclass) {
            case 'facebook':
                $(this).click(function() { s.share_facebook(); return false; });
                break;
            case 'twitter':
                $(this).click(function() { s.share_twitter(); return false; });
                break;
            case 'myspace':
                $(this).click(function() { s.share_myspace(); return false; });
                break;
            case 'bebo':
                $(this).click(function() { s.share_bebo(); return false; });
                break;
        }
    });
};

socialControl.prototype.share_facebook = function() {
    var url = 'http://www.facebook.com/sharer.php?u=' + this.v_url;
    window.open(url, null, this.o_pop_features, false);
};

socialControl.prototype.share_twitter = function() {
    var url = 'http://twitter.com/home?status=' + this.v_url;
    window.open(url, null, this.o_pop_features, false);
};

socialControl.prototype.share_myspace = function() {
    var url = 'http://www.myspace.com/Modules/PostTo/Pages/?u=' + this.v_url + '&t=' + this.v_title + '&c=' + this.v_title;
    window.open(url, null, this.o_pop_features, false);
};

socialControl.prototype.share_bebo = function() {
    var url = 'http://www.bebo.com/c/share?Url=' + this.v_url + '&Title=' + this.v_title;
    window.open(url, null, this.o_pop_features, false);
};
