/**
 * 	
 *  Copyright(c) 2009: Mantecao / Grupo Alion C.A.
 *  url: www.mantecao.com.ve/licensing
 *  email: licensing@mantecao.com.ve   
 *  author: Alexander Cabezas / Carlos Mantilla 
 * 
 */

 if (typeof(core) == "undefined") { core = {}; }

 core.ui = {};
 core.ui= {  dom: {}};
 
 core.ui.register = function(ui_name, ui_dom){
 	core.ui.dom[ui_name] = ui_dom;
 }

/**
 * @requires javascripts/jquery/jquery.qtip-1.0.0-rc3.min.js
 * @param {Object} ui_name
 * @param {Object} options
 */
 core.ui.localize = function(ui_name,options){
 	var options = options || {};
 	$(core.ui.dom[ui_name]).show();
	
	// Destroy currrent tooltip if present
    if($(core.ui.dom[ui_name]).data("qtip")) $(core.ui.dom[ui_name]).qtip("destroy");
	else $(core.ui.dom[ui_name]).data("qtip",0);
		
	$(core.ui.dom[ui_name]).qtip({
		content: options.msg, // Set the tooltip content to the current corner
           position: {
              corner: {
                 tooltip: options.tooltip, // Use the corner...
                 target: options.target // ...and opposite corner
              }
           },
           show: {
              when: false, // Don't specify a show event
              ready: true // Show the tooltip when ready
           },
           hide: { delay: options.delay ? options.delay : 500 }, // Don't specify a hide event
           style: {
              border: {
                 width: 3,
                 radius: 10
              },
              padding: 10, 
              textAlign: 'center',
              tip: true, // Give it a speech bubble tip with automatic corner detection
              name: options.style_name ? options.style_name : 'dark' // Style it according to the preset 'cream' style
         }
	});
	
 }

