var reloadHeadElements = function(elements) {
	$.each(elements, function(k,v){
		reloadHeadElement(v);
	})
}

var reloadHeadElement = function(element) {
	$('head').append(element);
}

var tinyMceHelper = {
    scriptLoad: false,
    run: function($selector, config) {
        if(!tinyMceHelper.scriptLoad) {
            $.getScript('/js/tiny_mce/jquery.tinymce.js', function(){
                tinyMceHelper.scriptLoad = true;
                $selector.tinymce(config);
            });
        } else {
            $selector.tinymce(config);
        }
    }
};

var tinyMceConfigs = {
    userProfileContent: {
        script_url : '/js/tiny_mce/tiny_mce.js',
        plugins: "paste",
        theme : "advanced",
        theme_advanced_buttons1 : "bold,italic,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,cut,copy,paste,|,outdent,indent,|,pasteword,pastetext",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    },
   cmsBlock: {
        script_url : '/js/tiny_mce/tiny_mce.js',
        plugins: "advimage",
        theme : "advanced",
        elements : 'abshosturls',
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,link,unlink,|,outdent,indent,|,image,|,code",
        theme_advanced_buttons2 : "backcolor,forecolor,formatselect",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    },
    cmsPage: {
        script_url : '/js/tiny_mce/tiny_mce.js',
        plugins: "kapluszone, kaimage, advimage, paste",
        content_css : "css/default.css",
        theme : "advanced",
        elements : 'abshosturls',
        relative_urls : false,
        remove_script_host : false,
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,link,unlink,|,outdent,indent,|,image,|,code",
        theme_advanced_buttons2 : "backcolor,forecolor,formatselect,|,pasteword,pastetext",
        theme_advanced_buttons3 : "addzone,addkaimage",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    },
    mailing: {
        script_url : '/js/tiny_mce/tiny_mce.js',
        plugins: "advimage",
        theme : "advanced",
        elements : 'abshosturls',
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,cut,copy,paste,|,link,unlink,|,outdent,indent,|,image,|,table,code",
        theme_advanced_buttons2 : "backcolor,forecolor,fontselect,fontsizeselect,formatselect",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    },
    news: {
        script_url : '/js/tiny_mce/tiny_mce.js',
        theme : "advanced",
        elements : 'abshosturls',
        theme_advanced_buttons1 : "bold,italic",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_resizing : false,
        width: "323"
    }
};

var mainTooltip = {
    content: '',
    left: 0,
    top: 0,
    setContent: function(content) {
        this.getObject().html(content);
        
        return this;
    },
    setPositions: function(left, top) {
        this.getObject().css({
            left: left,
            top: top
        });
        
        return this;
    },
    getObject: function() {
        return $('#main-tooltip');
    }
};
