Icw = {};

Icw.apply = function(o, c, defaults){
    if(defaults){
        // no "this" reference for friendly out of scope calls
        Icw.apply(o, defaults);
    }
    if(o && c && typeof c == 'object'){
        for(var p in c){
            o[p] = c[p];
        }
    }
    return o;
};

(function()
{
    var idSeed = 0;
    var ua = navigator.userAgent.toLowerCase();

    var isStrict = document.compatMode == "CSS1Compat",
        isOpera = ua.indexOf("opera") > -1,
        isSafari = (/webkit|khtml/).test(ua),
        isIE = ua.indexOf("msie") > -1,
        isIE7 = ua.indexOf("msie 7") > -1,
        isGecko = !isSafari && ua.indexOf("gecko") > -1,
        isBorderBox = isIE && !isStrict,
        isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
        isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
        isLinux = (ua.indexOf("linux") != -1),
        isSecure = window.location.href.toLowerCase().indexOf("https") === 0;

	Icw.apply(Icw, 
			{
	        id : function(el, prefix){
            prefix = prefix || "icw-gen";
            el = Icw.getDom(el);
            var id = prefix + (++idSeed);
            return el ? (el.id ? el.id : (el.id = id)) : id;
        	},
 
	         /**
	         * Return the dom node for the passed string (id), dom node, or Ext.Element
	         * @param {String/HTMLElement/Ext.Element} el
	         * @return HTMLElement
	         */
	        getDom : function(el){
	            if(!el){
	                return null;
	            }
	            return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
	        },
	        
	        getWindows : function(title, data , widthIn, heightIn) {
				
				data = base64_decode(data);
				// title = 'Colliers UFG PM&nbsp;-&nbsp;' + title;
				
				if (widthIn)
				{
					width = widthIn ;
				}
				else
				{
					width = 300;
				}
				
				if (heightIn)
				{
					height = heightIn;
				}
				else
				{
					height = 150;
				}
				
				
				
				var o_win = new Window({
					id: Icw.id(), 
					className: "alphacube", 
					title: title, 
					minimizable: true,
					maximizable: true,
					closable : true, 
					draggable:true,
					destroyOnClose: false,
					width: width,
					height: height,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					hideEffectOptions: { duration: 1 },
					showEffectOptions: { duration: 1 }
					});
					
				  
				o_win.setHTMLContent(data);
				
				var gestListner = {
					onFocus: function(eventName, win) { Icw.privChangeWindowsOpacity(win, 1); },
					onBlur: function(eventName, win) { Icw.privChangeWindowsOpacity(win, 0.75); },
					onMinimize: function(eventName, win) { Icw.privChangeWindowsOpacity(win); },
					onMaximize: function(eventName, win) { Icw.privChangeWindowsOpacity(win); }
					//onDestroy: function (eventName, win) { Effect.Fade(win.getId(), { duration: 1 }); alert('ci'); }
						};
				
				Windows.addObserver(gestListner);
				o_win.showCenter();
				 
				 
				 
				 
	        }, //Fin de getWindows
			
				
			privChangeWindowsOpacity: function(oWin, opacity) {
				
				if(opacity === undefined)
				{
					if(oWin.isMinimized())
					{
						opacity = 0.75;
					}
					else
					{
						opacity = 1;
					}
				}
				
				oWin.setOpacity(opacity);
			}, //Fin de privChangeWindowsOpacity
			
 
        /** @type Boolean */
        isOpera : isOpera,
        /** @type Boolean */
        isSafari : isSafari,
        /** @type Boolean */
        isIE : isIE,
        /** @type Boolean */
        isIE7 : isIE7,
        /** @type Boolean */
        isGecko : isGecko,
        /** @type Boolean */
        isBorderBox : isBorderBox,
        /** @type Boolean */
        isWindows : isWindows,
        /** @type Boolean */
        isLinux : isLinux,
        /** @type Boolean */
        isMac : isMac
        
        });
})();