var popup=function(){
    var id = 'ttpopup';
	var top = 3;
	var left = 3;
	var maxw = 330;
	var speed = 50;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,d,b,h;
	var ie = document.all ? true : false;
	var closeSrc = '';
	return{	    
		show:function(objSrc,popupClass,popuptop,popupleft,popupwidth,popupHeight, jsURL, w){
			if(tt == null){
			    closeSrc = objSrc;
				tt = jsURL != '' ? window.parent.document.createElement('div') : window.document.createElement('div');
				tt.setAttribute('id',id);
				tt.setAttribute('style', 'background-color:white');
				tt.style.backgroundColor = 'white';
				tt.style.border = '1px';
				tt.style.borderStyle = 'outset';
				tt.style.borderColor = 'black';
				tt.style.position = 'absolute';
				
				tt.className = popupClass;
				}
				
			   if(t == null){
				t = jsURL != '' ? window.parent.document.createElement('div') : window.document.createElement('div');
				t.setAttribute('id',id + 'top');
				}
				
			   if(c == null){
				//t.className = 'tt-top';
				c = jsURL != '' ? window.parent.document.createElement('div') : window.document.createElement('div');
				c.setAttribute('id',id + 'cont');
				}
				
			   if(b == null){	
				//c.className = 'tt-content';		
				b = jsURL != '' ? window.parent.document.createElement('div') : window.document.createElement('div');
				b.setAttribute('id',id + 'bot');
				}
				
			   if(d == null){
			    d = jsURL != '' ? window.parent.document.createElement('script') : window.document.createElement('script');
				d.setAttribute('type', 'text/javascript');
				d.setAttribute('src', jsURL);
				}
				tt.innerHTML = '';
				//b.className = 'tt-bottom';
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				jsURL != '' ? tt.appendChild(d) : "";
				jsURL != '' ? window.parent.document.body.appendChild(tt) : window.document.body.appendChild(tt);   
//				tt.style.opacity = 0;
//				tt.style.filter = 'alpha(opacity=0)';
		
			    tt.onmouseover = function(){popup.retainPos(true)};
			    if(popuptop == "" && popupleft =="")
                    window.parent.document.onmousedown = this.pos; 
                else			
                    popup.defaultPos(popuptop,popupleft);
                    
			c.style.paddingTop = 2;
			tt.style.display = 'block';
	        var closeBtnHtml = "<div align='right' style='position:relative;padding:2px 8px 5px 0px;'><img  src='http://202.38.2.146/MyQuuLounge/Images/btn-close-text.gif' title='close' style='cursor: pointer;' onmousedown='popup.poupHide();'/></div>";
	        var contentIFrame='<iframe id="iframeItemPopup" class="tabContent" frameborder="0" style="top:"' + document.body.scrollTop +  '";z-index:1;" ALLOWTRANSPARENCY="true" src="'+objSrc+'" width="'+popupwidth+'px" height="'+popupHeight+'px"></iframe>';
	        c.innerHTML = "";
			c.innerHTML = (closeBtnHtml + contentIFrame) ;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			maxw=popupwidth;
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){popup.fade(1)},timer);
		},
		pos:function(e){
		try{
			var u = ie ? event.clientY + window.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + window.documentElement.scrollLeft : e.pageX;
			
			tt = tt== null ? document.getElementById('ttpopup') : tt;
			tt.style.top = ((u - h) < 0 ? top:(u-h))+ 'px';
			tt.style.left = (l + left) + 'px';
			}catch(e){}
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
//				tt.style.opacity = alpha * .01;
//				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
		    try{
		    clearInterval(tt.timer);
		    tt.timer = setInterval(function(){popup.fade(-1)},timer);
		    }
		    catch(e){}
		},
		poupHide:function(){
		    var code = document.getElementById('iframeItemPopup');            
            code.src = '';
		    tt!= null? tt.style.display = 'none': document.getElementById('ttpopup').style.display = 'none';   
		},
		retainPos:function(e){
		    if(e)
		        window.parent.document.onmousedown = "";
		    else
		       window.parent.document.onmousedown = this.pos;	
		},
		defaultPos:function(popupTop,popupLeft)
		{
			tt = tt== null ? document.getElementById('ttpopup') : tt;
		    tt.style.top = popupTop+ 'px';
			tt.style.left = popupLeft + 'px';
		},
		refreshPage:function(objPage)
		{
		    window.parent.location.href=objPage;
		}
	};
}();

