
var http;
var xPos;
var yPos;
//----------------------Window object-----------------------------------------------------------------
var myWindow = 
{
    
    myDoc : document.documentElement,
    scrollX:function()
    {
        
        return this.myDoc.scrollLeft;
    },
    
    scrollY:function()
    {
        
        return this.myDoc.scrollTop;
    },
    
    getHeight:function()
    {
        return this.myDoc.clientHeight;
    },
    
    getWidth:function()
    {
        return this.myDoc.clientWidth;
    }
}

// The Frame object
var myFrame =
{
    el:null,
    id:"tipFrame",
    
    exist:false,
    create:function(url)
    {
        this.el = document.createElement('iframe');
        this.el.id = this.id;
        this.el.scrolling = 'no';
        this.el.frameborder = 'no';
        this.el.src = url;
        this.exist = true;
        this.el.style.visibility = "hidden";
        this.el.frameBorder = "no";
        
    },
            
    customize:function(height,width)
    {
        if(this.el==null)
            return;
        this.el.height = height;
        this.el.width = width;
    },
    
    destroy:function()
    {
        this.el = null;
        this.exist = false;
    },
    
    getFrame:function()
    {
        return this.el;
    },
    
    position:function(x,y)
    {
         this.el.style.position = 'absolute';
         this.el.style.left = x ;
         this.el.style.top = y ;
    },
    
    hide:function()
    {
        if(this.el!=null)
            this.el.visible = "hidden";
    }
   
        
}


// method to call the frame
function addFrame(e,url)
{
    
    showFrame(e,url);
    
       
}

//show frame
function showFrame(e,url)
{
    if(document.getElementById(myFrame.id))
        return;
    //var myEvent = window.event;
           
    else
    {
        myFrame.create(url);
        var myFrm = myFrame.getFrame();
        document.body.appendChild(myFrm);
    }

}

//remove frame
function removeFrame()
{
    if(document.getElementById(myFrame.id))
    {
        var tmpFrame = document.getElementById(myFrame.id);
        document.body.removeChild(tmpFrame);
        myFrame.destroy();
    }
}


// capture mouse move
function captureMouseMove()
{
    xPos = window.event.clientX;
    yPos = window.event.clientY;
    
}

function registerMouseMove()
{
    if(document.all)
    {
        document.onmousemove = captureMouseMove;
    }
    
}
//------------------------------------------------------------------------------------------



//--------------------------------------------------------AJAX Object------------------------
function getXmlHttp()
{
    var tempHttp;
    
    try
    {
        http = new XMLHttpRequest();
        
    }
    catch(e)
    {
        try
        {
            
            http = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
            http = null;
        }
    }
           
}


var myAjax = 
{
    toString:function()
    {
        return "Beco's Ajax";
    },
    makeRequest:function(method,url,handlerFunction)
    {
        
        getXmlHttp();
        http.onreadystatechange = handlerFunction;
        http.open(method,url,true);
        http.send(null);
        
    }
}


//----------------------------------------------------------------------------------------




function popTheUp(url)
{
    
    var start = url.indexOf("#")+1;
    var idData = url.substring(start);
   // var myAjax =new Ajax();
    start -=1;
    var reqUrl = url.substring(0,start);
    reqUrl +="?text="+idData;
    
    myAjax.makeRequest("Get",reqUrl,getText,window.event);
    
   
} 

function setSize()
{
if (eval(document.getElementById("tipFrame")))
{
    if(document.getElementById("tipFrame").readyState=="complete")
    {
       var e = window.event;      
        x = e.clientX + myWindow.scrollX()+1;
        y = e.clientY + myWindow.scrollY()+1;
        var height = document.getElementById("tipFrame").contentWindow.document.body.scrollHeight;
        var width =  document.getElementById("tipFrame").contentWindow.document.body.scrollWidth;
        myFrame.customize(height,width);
        if((x+width)>(myWindow.scrollX()+myWindow.getWidth()))
        {
            x = x-width;
            if(x<0)
                x=0;
        }
        if((y+height)>(myWindow.scrollY()+myWindow.getHeight()))
        {
            y = y-height;
            if(y<0)
                y=0;
        }        
        myFrame.position(x,y);
        document.getElementById("tipFrame").style.visibility = "visible";
    }
    }
}

function tips(txtID)
{
    var reqT = 'PopUps.aspx?text='+txtID;
    var e = window.event;
    if(document.all)
    {
        addFrame(e,reqT);
        document.getElementById("tipFrame").onreadystatechange = setSize;
                        
    }
    else
        myAjax.makeRequest("Get",reqT+":ajx",getDTips);   
}

function freeTips(txtID)
{
    var reqT = 'PopUps.aspx?freeText='+txtID;
    var e = window.event;
    if(document.all)
    {
        addFrame(e,reqT);
        document.getElementById("tipFrame").onreadystatechange = setSize;
                        
    }
    else
        myAjax.makeRequest("Get",reqT+":ajx",getDTips);   
}

function tipsRzin(rzin)
{
    var reqT = '../../PopUps.aspx?rzin='+rzin;
    var e = window.event;
    if(document.all)
    {
        addFrame(e,reqT);
        document.getElementById("tipFrame").onreadystatechange = setSize;
                        
    }
    else
        myAjax.makeRequest("Get",reqT+":ajx",getDTips);   
}

function getText()
{
    
    if(http.readyState == 4)
    {       
        makeThePop(http.responseText); 
    }
}



function getDTips(e)
{
    

     if(http.readyState == 4)
    {    
       stm(http.responseText.split(":",2),Style[12]);
       
    }
}
function makeThePop(content)
{
      popup = window.open("","Vocabulary","height=100px,width=300px,scrollbars=yes");
      popup.document.open();
      popup.document.write(content); 
      popup.document.close(); 
      
}



function pop(ur,title)
{
    window.open(ur,title,"height=500px,width=800px,scrollbars=yes");
}

function tes()
{
    alert("java script accesed");
}

