// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var abdovar=0; var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} 
var txt="";
var lef=0;var topp=0;var widthh=0;
var popup;
function fd(oi, wS) {
//alert(oi);
if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi);
if (al) return wS ? document.all[oi].style: document.all[oi];
if (an) return document.layers[oi];}
function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
function popUp(evt,oi) 
{
	if (DH) 
		{
			if(abdovar==1){return;}
            //////////////////////////////////////////////////
//            if(document.selection && document.selection.empty){
//            document.selection.empty() ;
//            } else if(window.getSelection) {
//            sel=window.getSelection();
//            if(sel && sel.removeAllRanges)
//            sel.removeAllRanges() ;
//            }

            if(oi.indexOf("#RemoveHameshInCopy#") > -1)
            {
                txt = oi.substring(oi.indexOf("#RemoveHameshInCopy#")+20);
                while(txt.indexOf('^') > -1)
                {
                    txt = txt.replace('^','\\');
                }
                while(txt.indexOf('*') > -1)
                {
                    txt = txt.replace('*','\'');
                }
			    oi = oi.substring(0,oi.indexOf("#RemoveHameshInCopy#"));
			}
			else
			{
			    txt=""; 
			}
			//////////////////////////////////////////////////
			var wp = pw();
			ds = fd(oi,1);
			dm = fd(oi,0); 
			//////////////////////////////////////////////////
			if(txt != "" && navigator.appName.indexOf("Internet Explorer") == -1)
			{
			    dm.innerHTML = txt;
			}
			//////////////////////////////////////////////////
			st = ds.visibility; 
			if (dm.offsetWidth) 
			    ew = dm.offsetWidth; 
			else if (dm.clip.width) 
			    ew = dm.clip.width; 

            if(txt != ""  && navigator.appName.indexOf("Internet Explorer") > -1)
            {
			    if (txt.length<=25)
			        ew = 170
			    else
			    {
			        ew = 270
			        var num = 10;
			        while( ((txt.length*7)/num) > wp*9/10 && ((txt.length*7)/num) > 270)
			        {
			            ew = (txt.length*7)/num;
			            num++;
			            
			            if(ew <= wp*9/10)
			                return;
			        }
			    }
			}
			else
			{
			    if (dm.innerHTML.length<=25)
			        ew = 170
			    else
			    {
			        ew = 270
			        var num = 10;
			        while( ((dm.innerHTML.length*7)/num) > wp*9/10 && ((dm.innerHTML.length*7)/num) > 270)
			        {
			            ew = (dm.innerHTML.length*7)/num;
			            num++;
			            
			            if(ew <= wp*9/10)
			                return;
			        }
			    }
			}

			abdovar=1;
			//tv = mouseY(evt) + 20; 
			tv = mouseY(evt)+13; 
			
			lv = mouseX(evt) - (ew/4); 
			
			if (lv < 2) 
			    lv = 2; 
			    
			else if (lv + ew > wp) 
			{
			    lv=wp-ew-10;
			
//			    lv -= ew/2; 
//			    while(lv + ew >= wp) 
//			    {
//			        lv -= 10; 
//			    }
			}

            if(navigator.appName.indexOf("Internet Explorer") <= -1)
            {
                if(lv + ew+22 > wp)
                    lv = wp-ew-22;
            }
			lef = lv;
			topp = tv;
			widthh=ew;
			if (!an) 
			{
				lv += 'px';tv += 'px';ew += 'px';
			} 
			ds.left = lv; 
			ds.top = tv; 
			ds.width = ew;
			ds.visibility = "visible";
			if(txt != "" && navigator.appName.indexOf("Internet Explorer") > -1)
			{
			    ds.visibility = "hidden";
			    popup = window.createPopup();
                popup.document.body.innerHTML = txt;
                popup.document.body.style.backgroundColor = '#ffffe5';
                popup.document.body.style.textAlign=document.getElementById(oi).style.textAlign;
                popup.document.body.style.borderRight="#666666 1px solid";
                popup.document.body.style.borderTop="#666666 1px solid";
                popup.document.body.style.borderBottom="#666666 1px solid";
                popup.document.body.style.borderLeft="#666666 1px solid";
                popup.document.body.style.paddingRight="1px";
                popup.document.body.style.paddingLeft="1px";
                popup.document.body.style.paddingTop="1px";
                popup.document.body.style.paddingBottom="1px";
                popup.document.body.style.font="13px 'Tahoma'";
                //popup.document.body.style.top="20px";
                //popup.document.body.style.left="90px";
                //popup.document.body.style.width="270px";
                popup.document.body.style.color="#333333";
                //popup.document.body.style.zIndex="100";
                //popup.document.body.style.position="absolute";
                //alert(txt.length*7);
                if(document.getElementById(oi).style.textAlign == "right")
                    popup.document.body.style.direction="rtl";
                else
                    popup.document.body.style.direction="ltr";

                if(txt.length<=25)
                    popup.show(lef, topp, widthh, ((Math.ceil((txt.length*6)/widthh))*22)+5, document.body);
                else
                    popup.show(lef, topp, widthh, ((Math.ceil((txt.length*7)/widthh))*18)+5, document.body);
            }
            else
            {
                ds.visibility = "visible";
            }
		}
}
function popUp2(evt,oi) 
{
	if (DH) 
		{
		    //////////////////////////////////////////////////
		    txt="";
		    if(oi.indexOf("#RemoveHameshInCopy#") > -1)
		    {
		        txt = oi.substring(oi.indexOf("#RemoveHameshInCopy#")+20);
			    oi = oi.substring(0,oi.indexOf("#RemoveHameshInCopy#"));
			}
			else
			{
			    txt="";
			}
			//////////////////////////////////////////////////
		
			if(abdovar==1)
			abdovar=0;
			var wp = pw(); 
			ds = fd(oi,1); 
			dm = fd(oi,0); 
			//////////////////////////////////////////////////
			if(txt != "" && navigator.appName.indexOf("Internet Explorer") == -1)
			    dm.innerHTML = "";
			//////////////////////////////////////////////////
			st = ds.visibility; 
			if (dm.offsetWidth) ew = dm.offsetWidth; 
			else if (dm.clip.width) ew = dm.clip.width; 
				 ds.visibility = "hidden";
				 ds.width = 0;
				 abdovar=0;
				 
            if(txt != "" && navigator.appName.indexOf("Internet Explorer") > -1)
                popup.hide();
			}
}
