1 define([],
  2 // module definition function
  3 // dependencies (foo and bar) are mapped to function parameters
  4 function() {
  5 	/**
  6 	 * @description UiUtil is teh util class helps to calculate or evaluate some util functions.
  7 	 * @name UIUtil
  8 	 * @class UIUtil
  9 	 * @example require('UIUtil')
 10 	 * @exports UIUtil
 11 	 * @version 1.0
 12 	 * @module UIUtil
 13 	 **/
 14 	var UIUtil = {
 15 		/**
 16 		 * @name randomColor					 
 17 		 * @memberOf UIUtil
 18 		 * @method 
 19 		 * @description method to randomly select one color out of teh given set of colurs.
 20 		 * @return color A Random color is returned.
 21 		 * @function
 22 		 */
 23 		randomColor : function() {
 24 			colors = ["red", "lime", "green", "purple", "maroon", "Aqua", "BlueViolet", "BlueViolet", "cyan", "darkcyan", "DarkMagenta", "Fuchsia", "GreenYellow", "DeepSkyBlue"];
 25 			var rand = Math.floor(Math.random() * colors.length);
 26 			return colors[rand];
 27 		},
 28 		/**
 29 		 * @name lightenDarkenColor					 
 30 		 * @memberOf UIUtil
 31 		 * @method 
 32 		 * @description method to mathematically lighten the color
 33 		 * @param {Object} col
 34 		 * @param {Object} amt +ve the color will be lighter, if -ve the result will be darker
 35 		 * @return color A lighten color is returned.
 36 		 * @function
 37 		 */
 38 		lightenDarkenColor : function(col, amt) {
 39 			col = require('UIUtil').colorToHex(col);
 40 			if (!amt)
 41 				amt = 150;
 42 			var usePound = false;
 43 			if (col[0] == "#") {
 44 				col = col.slice(1);
 45 				usePound = true;
 46 			}
 47 			var num = parseInt(col, 16);
 48 			var r = (num >> 16) + amt;
 49 			if (r > 255) {
 50 				r = 255;
 51 			} else if (r < 0) {
 52 				r = 0;
 53 			}
 54 			var b = ((num >> 8) & 0x00FF) + amt;
 55 			if (b > 255) {
 56 				b = 255;
 57 			} else if (b < 0) {
 58 				b = 0;
 59 			}
 60 			var g = (num & 0x0000FF) + amt;
 61 			if (g > 255) {
 62 				g = 255;
 63 			} else if (g < 0) {
 64 				g = 0;
 65 			}
 66 			return ( usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
 67 		},
 68 		/**
 69 		 * @name colorToHex					 
 70 		 * @memberOf UIUtil
 71 		 * @method 
 72 		 * @description Returns the predefined hex color for the color it is coming in the UI part.
 73 		 * @param {Object} color, the color name
 74 		 * @return Hex code for the color is returned.
 75 		 * @function
 76 		 */
 77 		colorToHex : function(color) {
 78 			colors = [];
 79 			colors["red"] = "#FF0000";
 80 			colors["lime"] = "#00FF00";
 81 			colors["green"] = "#008000";
 82 			colors["purple"] = "#800080";
 83 			colors["maroon"] = "#800000";
 84 			colors["Aqua"] = "#00FFFF";
 85 			colors["BlueViolet"] = "#8A2BE2";
 86 			colors["BlueViolet"] = "#8A2BE2";
 87 			colors["cyan"] = "#00FFFF";
 88 			colors["darkcyan"] = "#008B8B";
 89 			colors["DarkMagenta"] = "#8B008B";
 90 			colors["Fuchsia"] = "#FF00FF";
 91 			colors["GreenYellow"] = "#ADFF2F";
 92 			colors["DeepSkyBlue"] = "#00BFFF";
 93 			if (colors[color])
 94 				return colors[color];
 95 			return colors[color];
 96 		},
 97 		/**
 98 		 * @name lightenColor					 
 99 		 * @memberOf UIUtil
100 		 * @method 
101 		 * @description method to lighten the color with predefined light colors
102 		 * @param {Object} col
103 		 * @return color A lighten color is returned.
104 		 * @function
105 		 */
106 		lightenColor : function(color) {
107 			colors = [];
108 			colors["red"] = "#EBB9B9";
109 			colors["lime"] = "#AFFAAF";
110 			colors["green"] = "#BBF2BB";
111 			colors["purple"] = "#FAC8FA";
112 			colors["maroon"] = "#F5BFBF";
113 			colors["Aqua"] = "#CAFAFA";
114 			colors["BlueViolet"] = "#DED3E8";
115 			colors["BlueViolet"] = "#D7C5E8";
116 			colors["cyan"] = "#CDFAFA";
117 			colors["darkcyan"] = "#C5E3E3";
118 			colors["DarkMagenta"] = "#E8CFE8";
119 			colors["Fuchsia"] = "#F2D3F2";
120 			colors["GreenYellow"] = "#E2F0CE";
121 			colors["DeepSkyBlue"] = "#D3E8F0";
122 			if (colors[color])
123 				return colors[color];
124 			return colors[color];
125 		}
126 	};
127 	return UIUtil;
128 });