jQuery.fn.mygtukas_isjungti = function() {
    jQuery(this).find(".caption").attr("innerHTML", jQuery(this).attr("onclicktext"));
}

jQuery.fn.mygtukas_ijungti = function() {
    jQuery(this).find(".caption").attr("innerHTML", jQuery(this).attr("originaltext"));
}

jQuery.fn.mygtukas_ar_ijungtas = function() {
    
    if (jQuery(this).find(".caption").attr("innerHTML") == jQuery(this).attr("originaltext"))
        return true;
    else return false;
}

jQuery.fn.mygtukai = function() {

    var image = new Image();
    image.src = "http://img.draugas.lt/images/mygtukas_kairedesine.gif";

    if (image.complete) {
        _loaded();
    } else {
        image.onload = function() {
            _loaded();
        }
    }

    function _loaded() {

        jQuery.each(jQuery("div.mygtukas"), function(i, j) {

            var content = '\
                        <div style="display: inline; height: 20px; width: auto;"> \
                            <div class="left"></div> \
                            <div class="caption">' + jQuery(j).attr("innerHTML") + '</div> \
                            <div class="right"></div> \
                        </div> \
                        <div style="clear: both;"></div> \
                    ';

            jQuery(j).attr("originaltext", jQuery(j).attr("innerHTML"));
            jQuery(j).attr("innerHTML", content);

            /*jQuery( j ).foo() {
            alert("#");
            };*/

	    if ( jQuery(this).attr("invisible") == undefined )
            jQuery(j).show();
        });

        jQuery(".mygtukas").live("click", function() {

            if (jQuery(this).attr("onclicktext") != "" && jQuery(this).attr("autodisable") == undefined) {
                
                jQuery(this).find(".caption").attr("innerHTML", jQuery(this).attr("onclicktext"));

            }
        });

    }

}