﻿// JScript File
/*******************************
*Customised mouseover popup: For help, please email info@anandsoft.com.
*Made available by  anandsoft.com
*Written by G.Naresh
*The above information may not be removed 
********************************/

/**************************************
*     Steps for making a customised popup
*
*    1)  Cut and paste the given code in between the <head> and </head> tags of a html page
*    2)  Ensure that the <body> tag of html page is written as <BODY onload="initalt()">
*    3)  When giving a hyperlink to a page write the  <a href ="">Link Name</a>  as follows
*          <a href="" onmouseover="doalt('your message')" onmouseout="realt()">Link</A> 
*    4)  In the above line instead of  "your message"  You can give your own message what ever 
*          you want to be displayed
*
*
*      This Example gives you a clear cut idea of  the sequence of tags  in html page
*
*      <html>
*      <head>
*      Place the script within <head> and </head> tags as shown here 
*      </head>
*      <BODY onload="initalt()">
*      The URL below to be placed as required with in <body> and </body> tags. You can use it for  image links also.
*       <a href="http://www.yoursite.html" onmouseover="doalt('your message')" onmouseout="realt()">Link</A> 
*      </body>  
*      </html>
*
********************************/

// Call the init-routine with <BODY onload="initalt()">
// Call the alt-routine via mouseover 
// <a href="" onmouseover="doalt('your message')" onmouseout="realt()">Link</A>
// You can use any html you want as your message, so this could also be used for some 
// Menus...
//

function initalt()
{
    altback="white" 
    altborder="3333CC"
    altfont="arial"  // Alt-Message Font
    altfontcolor="203C70"// Alt-Message Font color
    altfontsize="2" // Alt-Message Font Size
    altoffx=10 // Alt-Message horizontal offset from mouse-position
    altoffy=20 // Alt-Message vertical offset from mouse-position
    altwidth=240 // Alt-Message width, will be expanded by your message
    altheight=0 // Alt-Message height, will be expanded by your message
    // end of Variables

    document.onmousedown = sniff
    document.onmousemove = sniff
    document.onmouseup = sniff
    if (document.layers) 
    {  //NS
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
        document.layers['altmessage'] = new Layer(altwidth)
        document.layers['altmessage'].left = 0
        document.layers['altmessage'].top = 0
        document.layers['altmessage'].height = altheight
        document.layers['altmessage'].bgColor = altback
        document.layers['altmessage'].visibility = "hidden"
        document.layers['altmessage'].borderStyle = "solid"
        document.layers['altmessage'].borderColor = altborder
        document.layers['altmessage'].borderWidth = 1
    }
    else if (document.all)
    { //IE
        document.body.insertAdjacentHTML("BeforeEnd",'<DIV ID="altmessage" STYLE="z-index:200;position:absolute;width:'+altwidth+';height:'+altheight+';left:0;top:0;visibility:hidden;background:'+altback+';border-style:solid;border-width:1;border-color:'+altborder+'"></DIV>')
    }
}

function sniff(e) 
{
    // GETS Mouseposition
    if (document.layers)
    {
        var mousex=e.pageX; var mousey=e.pageY;document.layers['altmessage'].left = mousex+altoffx;document.layers['altmessage'].top = mousey+altoffy
    }
    else if (document.all)
    {
        var mousex=event.x; var mousey=event.y+document.body.scrollTop;altmessage.style.top=mousey+altoffy;altmessage.style.left=mousex+altoffx
    }
}

function doalt(message)
{
    //The main routine
    content='<font face="'+altfont+'" size="'+altfontsize+'" color="'+altfontcolor+'">'+message+'</FONT>'				
    if (document.layers) 
    {
        with (document.layers['altmessage'].document)
        {
            open()
            write(content)
            close()
        }
        document.layers['altmessage'].visibility = "show"
    }
    else if (document.all) 
    { 
        document.all['altmessage'].innerHTML = content
        document.all['altmessage'].style.visibility = "visible"
    }
}

function realt()
{
    if (document.layers)document.layers['altmessage'].visibility = "hidden";
    else if (document.all) document.all['altmessage'].style.visibility = "hidden";
}
