



//////////////////////////////////////////////////////////////////
//FILE LOAD INDICATOR! DO NOT REMOVE
//////////////////////////////////////////////////////////////////
$iTXT.js.loader["$iTXT.ui.ComponentBase"] = true;
//////////////////////////////////////////////////////////////////


//Loader Function
$iTXT.ui.ComponentBase_Load = function(){
	
	//Speed up access to undefined
	var undefined;

	
    
    $iTXT.ui.ComponentBase = $iTXT.core.Class.create(
	{
		
		
		init: function(_options)
		{
			//default options
			this.options = $iTXT.core.Util.extend(
			{
				
			}
			, _options);
            

        },
        
        
        getHTML: function()
        {
            if (this.rootElement)
            {
                return $iTXT.core.Builder.make("DIV", {}, [this.rootElement]).innerHTML;
		}
            return "";
        }
		
	
	});//end Base class
    
}








//////////////////////////////////////////////////////////////////
//FILE LOAD INDICATOR! DO NOT REMOVE
//////////////////////////////////////////////////////////////////
$iTXT.js.loader["$iTXT.ui.TooltipSlideOut"] = true;
//////////////////////////////////////////////////////////////////


//Loader Function
$iTXT.ui.TooltipSlideOut_Load = function(){
    
    //Speed up access to undefined
    var undefined;

    
    
    $iTXT.ui.TooltipSlideOut = $iTXT.core.Class.create($iTXT.ui.ComponentBase,
    {
        
        
        init: function(_options, $super)
        {
            //default options
            var defOpts = $iTXT.core.Util.extend(
            {
                bgcol: "#545454",
                op: 0.85,
                t: "Advertisement",
                h: 272,
                w: 310,
                d: "r",
                pding: 10,
                content: "",
                duration: 0.5
            }
            , _options);
            
            //call the component base
            $super(defOpts);
            
            //replace all instances of ${REFERER} in the content string
            //for via iframe units
            this.options.content = this.options.content.replace("${REFERER}", escape(document.location.href));
            
            this.isOpen = false;
            this.isOpening = false;
            
            //store builder function in a shortcut var
            var b = $iTXT.core.Builder;
            
            //boolean to indicate the slide out type is vertical if type is top or bottom
            var isVertical = (("t" == this.options.d) || ("b" == this.options.d));
            
            //set the padding value for the side that is going to be
            //behind the tooltip.
            this.pding = this.options.pding;
            
            //set the padding around the advert for the width and height
            //based on the slide out type.
            this.wP = isVertical ? 10 : (10+this.pding);
            this.hP = isVertical ? (22+this.pding) : 22;
            
            //set the actual height and width;
            this.aw = this.options.w;
            this.ah = this.options.h;
            
            //set the content height and width;
            this.cw = this.aw - this.wP;
            this.ch = this.ah - this.hP;
            
            //create a container div for the background
            var bgc = b.make("DIV", { className: "vm_ttso_bg", style: "opacity:" + this.options.op + ";filter: alpha(opacity = " + this.options.op + ");width: " + this.aw + "px; height: " + this.ah + "px;" },
                    [
                     this._header(b),
                     this._middle(b),
                     this._footer(b)
                     ]);
            
            //set the content left and top based on the
            //slide out direction type.
            var cl = ("r" == this.options.d) ? (5+this.pding) : 5;
            var ct = ("b" == this.options.d) ? (5+this.pding) : 17;
            
            //create a container for the slide out content
            var cc = b.make("DIV", { id: "vm_ttso_cnt", style: "left: " + cl + "px; top: " +  ct + "px; width: " + this.cw + "px; height: " + this.ch + "px;"});
            
            //set the title top and left based on the
            //slide out direction type.
            var ttll = ("r" == this.options.d) ? (5+this.pding) : 5;
            var ttlt = ("b" == this.options.d) ? (this.ah-17) : 0;
            
            //create the title div
            var ttl = b.make("DIV", { className: "vm_ttso_ttl", style: "left: " +  ttll + "px; top: " +  ttlt + "px;"}, [this.options.t]);
            
            //set the source for the close button states
            var srcPath = "http://images.intellitxt.com/ast/vmimages/ttso/";
            var onSrc = srcPath + "close_on.gif";
            var offSrc = srcPath + "close_off.gif";
            
            //set the close button top and right based on the
            //slide out direction type.
            var cbtnr = ("l" == this.options.d) ? (5+this.pding) : 5;
            var cbtnt = ("b" == this.options.d) ? (this.ah-17) : 0;
            
            var cBtn = b.make("DIV", { className: "vm_ttso_cbtn", style: "right: " +  cbtnr + "px; top: " +  cbtnt + "px;" }, [b.make("IMG", { src: offSrc, onClick: "$iTXT.core.$(document).itxtFire('$iTXT:ttso:close');", onMouseOver: "this.src='" + onSrc + "'", onMouseOut: "this.src='" + offSrc + "'"})]);                                  
            
            
            //'<div class="vm_std vm_shad" id="ttShadow"><img class="vm_std vm_shad2" src="'+RimC('sh_305x200.png','')+'"/></div>'
            var shad = b.make("DIV", { id: "ttso_shad", style: "width: 0px; height: " + this.ah + "px;"}, [b.make("IMG", { className: "vm_std vm_shad2", src: RimC('sh_305x200.png',''), style: "width: " + this.aw + "px; height: " + this.ah + "px;"})]); 
            
            this.rootElement = b.make("DIV", { id: "vm_ttso"}, [shad, bgc, cc, ttl, cBtn]);           
            
            //set a reference to this element;
            var t = this;
            
            
            $iTXT.core.$(document).itxtSubscribe("$iTXT:ttso:close", 
                    function (e)
                    {
                        if (t.isOpen)
                        {
                            t.close();
                        }
                    });
            
            
            $iTXT.core.$(document).itxtSubscribe("$iTXT:tt:open", 
                    function (e)
                    {
                        if (!t.isOpen)
                        {
                            t.open();
                        }
                    });

        },
        
        
        open: function()
        {
            if (this.options.beforeOpen)
            {
                this.options.beforeOpen();
            }
            
            var dx = 0;
            var dy = 0;
            
            switch (this.options.d)
            {
                case 'r' :
                    dx = (this.aw-this.pding);
                    break;
                case 'l' :
                    dx = -(this.aw-this.pding);
                    break;
                case 't' :
                    dy = -(this.ah-this.pding);
                    break;
                case 'b' :
                    dy = (this.ah-this.pding);
                    break;
            }
            
            //create a function to be called
            //when the open amimation has finished
            var t = this;
            var afFunc = function()
            {
                t.isOpen = true;
                t.isOpening = false;
                $iTXT.core.$("vm_ttso_cnt").innerHTML = t.options.content;                              
            }
            
            t.isOpening = true;
            this._slide(dx, dy, afFunc);
        },
        
        
        close: function()
        {
            var dx = 0;
            var dy = 0;
            
            switch (this.options.d)
            {
                case 'r' :
                    dx = -(this.aw-this.pding);
                    break;
                case 'l' :
                    dx = (this.aw-this.pding);
                    break;
                case 't' :
                    dy = (this.ah-this.pding);
                    break;
                case 'b' :
                    dy = -(this.ah-this.pding);
                    break;
            }
            
            $iTXT.core.$("vm_ttso_cnt").innerHTML = "";
            
            //create a function to be called
            //when the open amimation has finished
            var t = this;
            var afFunc = function()
            {
                t.isOpen = false;                              
            }
            
            
            this._slide(dx, dy, afFunc);
        },
        
        setBounds: function(w, h)
        {
            
        },
        
        _slide: function(dx, dy, afterFinish)
        {
            var t = this;
            //Create a new fx Move effect
            new $iTXT.fx.Move(
                    {
                        target: "vm_ttso", 
                        start: true, 
                        dX: dx, 
                        dY: dy, 
                        duration: this.options.duration,
                        afterFinish: afterFinish,
                        afterUpdate: function(v)
                        {
                            var l = $iTXT.core.$("vm_ttso").offsetLeft;
                            if (l>0)
                            {
                                l += 10;
                            }
                            $iTXT.core.$("ttso_shad").itxtSetStyle({width: l + "px"});                        
                        }
                    });
        },
        
        
        _header: function(b)
        {
            //create background header div
            var crnCont = b.make("DIV", { className: "vm_ttso_hdr" });
            
            //loop through, and create bold elements with varying styles
            //to represent the top curved corners.
            for (var i=0;i<6;i++)
            {
                crnCont.appendChild(
                        b.make("B", 
                        {
                            className: "vm_ttso_tc" + i ,
                            style: "background-color: " + this.options.bgcol + ";"
                        }));
            }
            
            return crnCont;
        },
        
        
        _middle: function(b)
        {
            //create the middle div, with a height equal to the total slide out height, minus 12 pixels for the header and footer.
            var mdlDiv = b.make("DIV", 
                    {
                        className: "vm_ttso_mdl",
                        style: "background-color: " + this.options.bgcol + "; height: " + (this.ah-12) + "px;" 
                    });                       
            
            return mdlDiv;
        },
        
        
        _footer: function(b)
        {
            //create the footer div with a top value equal to the total slide out height, minus 6 pixels
            var crnCont = b.make("DIV", { className: "vm_ttso_ftr", style: "top: " + (this.ah-6) + "px;"});
            
            //loop through, and create bold elements with varying styles
            //to represent the bottom curved corners.
            for (var i=0;i<6;i++)
            {
                crnCont.appendChild(
                        b.make("B", 
                        {
                            className: "vm_ttso_bc" + i ,
                            style: "background-color: " + this.options.bgcol + ";"
                        }));
            }
            
            return crnCont;
        },
        
        
        _content: function(b)
        {
            return "";
        }
        
    
    });//end Base class
    
}









//////////////////////////////////////////////////////////////////
//FILE LOAD INDICATOR! DO NOT REMOVE
//////////////////////////////////////////////////////////////////
$iTXT.js.loader["$iTXT.ui.WindowBase"] = true;
//////////////////////////////////////////////////////////////////


//Loader Function
$iTXT.ui.WindowBase_Load = function(){
	
	//Speed up access to undefined
	var undefined;

	
    
    $iTXT.ui.WindowBase = $iTXT.core.Class.create($iTXT.ui.ComponentBase,
	{
		
		
        init: function(_options, $super)
		{
			//default options
            var defOpts = $iTXT.core.Util.extend(
			{
				
			}
			, _options);
            
            //call the component base
            $super(defOpts);

		}
		
	
	});//end Base class
    
}






