/* FOR CALENDAR POP-UP */
if (expu === undefined ) {
	var expu = {
		coords:{x:0, y:0,sw:0, ww:0, ew:0, dw:0,st:0, wh:0, eh:0, dh:0, ad:''},        
		m_el:null,
		m_div:null,
        m_if:null,
        m_ie:(/\w*MSIE\w*/).test(navigator.appVersion),
        m_margin:0,
        m_prevDivHeight:0,        
        m_html:null,
        m_defaultWidth:368,
		m_arrowIds:['pu-AL','pu-AR'],
		m_images:[
			'images/popLeftArrow.gif', // 0
			'images/popRightArrow.gif',
			'images/popTopLeftCorner.gif',
			'images/popTopRightCorner.gif',
			'images/popClose.gif'	
		],
		m_arrowShowingIdx:-1,
		m_bInited:false,
		init:function()
		{
			if(!this.m_bInited)
			{								
	            this.createDiv();
	            this.createIF();
				this.createArrows();
				this.m_bInited = true;
			}
		},
		cacheImage:function()
		{
			for(var i =0; i < this.m_images.length; i++)
			{
				var img = new Image();
				img.src = this.m_images[i];				
			}			
		},
        de:function(id){return document.getElementById(id);},
        createDiv:function()
        {            
            if(this.m_div == null)
            {
                this.m_div = document.createElement('div');
                this.m_div.id = 'pu-div';
                this.m_div.style.zIndex = '9999';
                this.m_div.style.display = 'none';
                this.m_div.style.position= 'absolute';                
                document.body.appendChild(this.m_div);
            }
        },
        createIF:function()
        {
            if(this.m_ie && this.m_if == null)
            {
                this.m_if = document.createElement('iframe');
                this.m_if.id='pu-if';
                this.m_if.src='';
                this.m_if.style.zIndex='9998';
                this.m_if.style.display='none';
                this.m_if.style.position='absolute';
                this.m_if.style.top = 0;
                this.m_if.style.left = 0;
                this.m_if.frameBorder=0;
                this.m_if.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
                document.body.appendChild(this.m_if);			
            }
        },
		createArrows:function()
		{		
			for(var i = 0; i < this.m_arrowIds.length; i++)
			{
				var div = document.createElement('div');	
				div.id = this.m_arrowIds[i];
				div.style.position = 'absolute';
				div.style.zIndex = '10000';				
				div.style.visibility = "hidden";
				document.body.appendChild(div);
			}
		},		
		displayArrow:function(idx,t,l)
		{
			this.hideArrow();
			if (idx > -1 && idx < this.m_arrowIds.length)
			{
				var arrow = this.de(this.m_arrowIds[idx]);
				arrow.style.top = t+'px';
				arrow.style.left = l+'px';
				arrow.style.visibility = "visible";
				arrow.innerHTML = ['<img src="',this.m_images[idx],'" alt="" />'].join('');								
				this.m_arrowShowingIdx = idx;
			}
		},
		showArrow:function()
		{
			var mt = -12;
			var ml = -17;			
			var mx = -20;
			var my = -16;			
			var arrowPos = {t:0, l:0};

			switch(this.coords.ad)
			{
				case 'TR':
					arrowPos.t = this.coords.x + mt*2;
					arrowPos.l = this.coords.y + this.coords.dw + ml;
					this.coords.x += mx * 4;
					this.coords.y += my;															
					break;
				case 'BR':
					arrowPos.t = this.coords.x + this.coords.dh + mt;
					arrowPos.l = this.coords.y + this.coords.dw + ml;
					this.coords.x -= mx * 4;
					this.coords.y += my;									
					break;
				case 'TL':
					arrowPos.t = this.coords.x + mt*2;
					arrowPos.l = this.coords.y - (my * 5);
					this.coords.x += mx * 4;
					this.coords.y -= my * 6;
					break;
				case 'BL':
					arrowPos.t = this.coords.x + this.coords.dh + mt;
					arrowPos.l = this.coords.y - (my * 5);
					this.coords.x -= mx * 4;
					this.coords.y -= my * 6;									
					break;												
				default:
					this.hideArrow();		
					break;
			}
			
			if (this.coords.ad == 'TR' || this.coords.ad == 'BR' )
			{ 
				this.displayArrow(1, arrowPos.t, arrowPos.l );
			}
			else
			{
				this.displayArrow(0, arrowPos.t, arrowPos.l );				
			}
												
		},
		hideArrow:function()
		{			
			if (this.m_arrowShowingIdx > -1 && this.m_arrowShowingIdx < this.m_arrowIds.length)
			{
				this.de(this.m_arrowIds[this.m_arrowShowingIdx]).style.visibility = 'hidden';
				this.m_arrowShowingIdx = -1;				
			}
		},
        gethtml:function(h,b,w)
        { 
            return [
                '<div id="pu-js-all" style="float:left;display:block;width:',
                    w,
                    'px;max-width:',
                    w,
                    'px;">',
                    '<div style="float:left;">',
                        '<table border="0" cellpadding="0" cellspacing="0" style="width:100%;" id="header">',
                        '<tr><td style="width:100%">',
							'<table border="0" cellpadding="0" cellspacing="0" style="width:100%;height:4px;"><tr>',
                            '<td style="width:4px;"><img src="',
							this.m_images[2], // X/images/TP_TipHead_TL.gif
							'" alt="" /></td>',
                            '<td style="background:#f1f4f7;width:100%;height:4px;"></td>',
                            '<td style="width:4px;"><img src="',
							this.m_images[3], // X/images/TP_TipHead_TR.gif
							'" alt="" /></td>',
							'</tr></table>',
                        '</td></tr>',
                        '<tr>',
                        '<td style="background:#f1f4f7;width:100%;text-align:center;height:28px;color:#fff;">',
                        '<div style="margin-bottom:4px;">',
                            '<div class="pu-close" style="float:right;margin:2px 7px 0 0;cursor:pointer;cursor:hand;"><img onclick="event.cancelBubble=true;expu.hide();" src="',
							this.m_images[4], // X/images/TP_TipHead_X.gif
							'" alt="" /></div>',
                            '<h2 style="margin:0;font-family:Arial;font-size:16px;line-height: 22px;" id="pu-header">',
                            h,// 14 <!-- header -->
                            '</h2>',
                        '</div>',
                        '</td>',
                        '</tr>',
                        '<tr>',
                        '<td style="background:#f1f4f7;width:100%;border:solid 1px #7694bf;border-top-width:0;">',
                        b,// 21 <!-- content -->
                        '<div id="pu-body"></div>',
                        '</td>',
                        '</tr>',
                        '</table>',
                    '</div>',
                '</div>'
                ].join('');
        },
        gST:function()
        {
            if(document.documentElement.scrollTop)
            {
                return document.documentElement.scrollTop;
            }            
            if(document.body.scrollTop)
            {
                return document.body.scrollTop;
            }            
            if(window.pageYOffset)
            {
                return window.pageYOffset;
            }            
            return 0;
        },
        gSL:function()
        {
            if(document.documentElement.scrollWidth)
            {
                return document.documentElement.scrollWidth;
            }            
            if(document.body.scrollWidth)
            {
                return document.body.scrollWidth;
            }            
            if(window.pageXOffset)
            {				
                return window.pageXOffset;				
            }            
            return 0;
        },        
        gWH:function()
        {			
            if(window.innerHeight)
            {				
                return window.innerHeight;
            }			
			
            if(document.documentElement.clientHeight)
            {				
                return document.documentElement.clientHeight;
            }
			
            if(document.body.clientHeight)
            {
				
                return document.body.clientHeight;
            }
            
            return 0;
        },        
        gWW:function()
        {
            if(window.innerWidth)
            {
                return window.innerWidth;
            }
            
            if(document.documentElement.clientWidth)
            {
                return document.documentElement.clientWidth;
            }
            
            if(document.body.clientWidth)
            {
                return document.body.clientWidth;
            }
            
            return 0;
        },            
        setCoors:function()
        {
            var x= 0;
            var y= 0;
			var yGap = 10;
			var ad = ''; 			
            var el = this.m_el;            

            while (el != null)
            {
                x += el.offsetTop;
                y += el.offsetLeft;
                el = el.offsetParent; 
            }
			
            this.coords.sw = this.gSL();
            this.coords.ww = this.gWW();
            this.coords.ew = this.m_el.offsetWidth;            
            this.coords.dw = this.m_div.offsetWidth;
			
			if ( (y - this.coords.dw) < yGap )
			{				
				ad = 'L';		
			}   
			else
			{
				y = y - this.coords.dw;
				ad = 'R';
			}                 

            this.coords.st = this.gST();
            this.coords.wh = this.gWH();                        
            this.coords.eh = this.m_el.offsetHeight;
            this.coords.dh = this.m_prevDivHeight = this.m_div.offsetHeight;
                                  
                                            
            if(((x-this.coords.dh)>this.coords.st)&&((x+this.coords.eh+this.coords.dh)>=(this.coords.wh+this.coords.st)))
            {
                x = x - this.coords.dh;
                ad = 'B' + ad;                
            }
            else
            {				
                x = x + this.coords.eh;
                ad = 'T' + ad;                
            }

            this.coords.x = x;
            this.coords.y = y;
			this.coords.ad = ad;  
        },  
        check:function()
        {
            var newOFHeight = this.m_div.offsetHeight;
            if (this.m_prevDivHeight != newOFHeight)
            {
                this.show();
            }
             
        },     
        show:function()
        {           
            this.setCoors();      
			this.showArrow();			

            var _top = this.coords.x + 'px';
            var _left = this.coords.y + 'px';						
            
            this.m_div.style.top = _top;
            this.m_div.style.left = _left;		
			this.m_div.style.visibility ='hidden';	
            this.m_div.style.display = 'block';			            
            
            if (this.m_ie)
            {
                this.m_if.style.width = this.m_div.offsetWidth+'px';
                this.m_if.style.height = this.m_div.offsetHeight+'px';
                this.m_if.style.top = _top;            
                this.m_if.style.left = _left;
                this.m_if.style.display = 'block';
            }
            
            this.check();			
			this.m_div.style.visibility ='visible';
        },       
        pop:function(el,header,body,width)
        {
			this.init();
            this.m_el = el;            
            this.m_div.innerHTML = this.gethtml(header,body,width);
            this.show();
        },
        popid:function(el,hid,bid,width)
        {
            this.pop(el,this.de(hid).innerHTML,this.de(bid).innerHTML,width);
        },
        popbid:function(el,header,bid)
        {
						this.pop(el,header,this.de(bid).innerHTML,this.m_defaultWidth);
        },        
        popbidw:function(el,header,bid,width)
        {
            this.pop(el,header,this.de(bid).innerHTML,width);
        },
        hide:function()
        {   
            if (this.m_div != null)this.m_div.style.display = 'none';
            if (this.m_if != null && this.m_ie ) this.m_if.style.display = 'none';
			this.hideArrow();
        }
    };    
}
expu.cacheImage();