var __rc_def_version$ = "0.0.0.0";
var __rc_def_id$ = "_blank_id_";
var __rc_def_ws_url$ = (document.domain.substr(0, 3) == "dev") ? "dev.service" : "service";
var __rc_def_protocol = (document.location.protocol == "https:") ? "https://" : "http://";

function auto_link_button() {
    $(".UIbtn_ORG_link").hover(
        function() {
            $(this).removeClass('UIbtn_ORG_link');
            $(this).addClass('UIbtn_ORG_hover');
        },
        function() {
            $(this).removeClass('UIbtn_ORG_hover');
            $(this).addClass('UIbtn_ORG_link');
        }
    );

    $(".UIbtn_ORG_link").mousedown(
        function() {
            $(this).removeClass('UIbtn_ORG_hover');
            $(this).addClass('UIbtn_ORG_down');
        }
    );

    $(".UIbtn_ORG_link").mouseup(
        function() {
            $(this).removeClass('UIbtn_ORG_down');
            $(this).addClass('UIbtn_ORG_hover');
        }
    );

    $(".UIbtn_PROF_link").hover(
        function() {
            $(this).removeClass('UIbtn_PROF_link');
            $(this).addClass('UIbtn_PROF_hover');
        },
        function() {
            $(this).removeClass('UIbtn_PROF_hover');
            $(this).addClass('UIbtn_PROF_link');
        }
    );

    $(".UIbtn_PROF_link").mousedown(
        function() {
            $(this).removeClass('UIbtn_PROF_hover');
            $(this).addClass('UIbtn_PROF_down');
        }
    );

    $(".UIbtn_PROF_link").mouseup(
        function() {
            $(this).removeClass('UIbtn_PROF_down');
            $(this).addClass('UIbtn_PROF_hover');
        }
    );


    $(".UIbtn_GRAY_link").hover(
        function() {
            $(this).removeClass('UIbtn_GRAY_link');
            $(this).addClass('UIbtn_GRAY_hover');
        },
        function() {
            $(this).removeClass('UIbtn_GRAY_hover');
            $(this).addClass('UIbtn_GRAY_link');
        }
    );

    $(".UIbtn_GRAY_link").mousedown(
        function() {
            $(this).removeClass('UIbtn_GRAY_hover');
            $(this).addClass('UIbtn_GRAY_down');
        }
    );

    $(".UIbtn_GRAY_link").mouseup(
        function() {
            $(this).removeClass('UIbtn_GRAY_down');
            $(this).addClass('UIbtn_GRAY_hover');
        }
    );

    $(".UIbtn_BLUE_link").hover(
        function() {
            $(this).removeClass('UIbtn_BLUE_link');
            $(this).addClass('UIbtn_BLUE_hover');
        },
        function() {
            $(this).removeClass('UIbtn_BLUE_hover');
            $(this).addClass('UIbtn_BLUE_link');
        }
    );

    $(".UIbtn_BLUE_link").mousedown(
        function() {
            $(this).removeClass('UIbtn_BLUE_hover');
            $(this).addClass('UIbtn_BLUE_down');
        }
    );

    $(".UIbtn_BLUE_link").mouseup(
        function() {
            $(this).removeClass('UIbtn_BLUE_down');
            $(this).addClass('UIbtn_BLUE_hover');
        }
    );
}

//class Extend
$Class = function() {};
$Class.prototype.__init = function() {};
$Class.extend = function(def) {
    var classDef = function() {
        if(arguments[0] !== $Class) { this.__init.apply(this, arguments); }
    }

    var proto = new this($Class);
    var _superClass = this.prototype;

    for(var n in def) {
        var item = def[n];

        if(item instanceof Function) {
            item.$ = _superClass;
            item.$self = proto;
        }
        proto[n] = item;
    }
    classDef.prototype = proto;

    classDef.extend = this.extend;
    return classDef;
}

//core
if(typeof mayn == "undefined") mayn = $Class.extend({
    __version : __rc_def_version$,
    __id : __rc_def_id$,

    getVersion : function() { return this.__version; },
    getClassId : function() { return this.__id; }
});

if(typeof mayn.Core == "undefined") mayn.Core = mayn.extend({});

//portlet
if(typeof mayn.Portlet == "undefined") mayn.Portlet = mayn.extend({
    _DoGet : function(a_cmd, a_additinal, a_callback) {
        if(typeof a_additinal == "undefined")
            a_additinal = "";

        if(typeof a_callback == "function")
            $.get("/data/index/" + this.getClassId() + "/" + this.getVersion() + "/" + a_cmd + a_additinal, a_callback);
        else
            $.get("/data/index/" + this.getClassId() + "/" + this.getVersion() + "/" + a_cmd + a_additinal);
    },

    _DoPost : function(a_cmd, a_additinal, a_callback) {
        if(typeof a_additinal != "object") {
            alert('parameter must be object type');
            return;
        }

        if(typeof a_callback == "function")
            $.post("/data/index/" + this.getClassId() + "/" + this.getVersion() + "/" + a_cmd, a_additinal, a_callback);
        else
            $.post("/data/index/" + this.getClassId() + "/" + this.getVersion() + "/" + a_cmd, a_additinal);
    }
});
