/*s 
Simple Image Trail script- By JavaScriptKit.com 
Visit http://www.javascriptkit.com for this script and more 
This notice must stay intact 
*/ 
var trailimage=["test.gif", 100, 99] //image path, plus width and height
var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 270;   // maximum image size. 
var currentimagewidth = 270;
var objid="news1"
var newslist=["news1","news2","news3","news4"]
var flag=0;
var i=0;
var m=0;
var numofnews=4;

if (document.getElementById || document.all) {
//document.write('<div id="trailimageid" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px"><img src="../../script/'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')
//document.write('<div id="news1" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px"><img src="../../script/'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')

        document.write('<div id="displaynews"  style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px">'); 
        document.write('</div>'); 
}

function gettrailobjnostyle(){ 
if (document.getElementById) 
//return document.getElementById("trailimageid") 
return document.getElementById(objid) 
else if (document.all) 
return document.all.trailimagid 
} 

function gettrailobj(){
if (document.getElementById)
//return document.getElementById("trailimageid").style
return document.getElementById(objid).style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle1(currElem){ 
if (document.getElementById) 
//return document.getElementById("trailimageid") 
return document.getElementById(currElem) 
else if (document.all) 
return document.all.trailimagid 
} 

function truebody(){ 
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
} 

function showtrail(imgheight, imgwidth, currElem){ 
		flag =1;
    objid=currElem;
		//gettrailobj();
        if (imgheight > 0){ 
                currentimageheight = imgheight; 
        } 
        if (imgwidth > 0){ 
                currentimagewidth = imgwidth; 
        }
        document.onfiltered=followmouse;
    if (gettrailobj().left != "") {
           gettrailobj().visibility="visible"; 
    }
}

function hidetrail(){
  flag=0;
    gettrailobj().visibility="hidden"
//document.onmousemove=""
       document.onfiltered="" 
        gettrailobj().left="" 
}

function followmouse(e){ 
        var xcoord=offsetfrommouse[0] 
        var ycoord=offsetfrommouse[1] 

        var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15 
        var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

  //      var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15 
 //       var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

        if (typeof e != "undefined"){ 
                if (docwidth - e.pageX < (currentimagewidth + 30)){ 
                        xcoord = e.pageX - xcoord - currentimagewidth + 20 ; // Move to the left side of the cursor 
                } else { 
                        xcoord += e.pageX +50; 
                } 
                if (docheight - e.pageY < (currentimageheight + 10)){ 
                        ycoord += e.pageY - Math.max(0,(10 + currentimageheight + e.pageY - docheight - truebody().scrollTop));

                } else { 
                        ycoord += e.pageY; 
                } 

        } else if (typeof window.event != "undefined"){ 

                if (docwidth - event.clientX < (currentimagewidth + 30)){ 
                        xcoord = event.clientX + truebody().scrollLeft - xcoord - currentimagewidth +20 ; // Move to the left side of the cursor

                } else { 
                        xcoord += truebody().scrollLeft+event.clientX + 50
                } 
                if (docheight - event.clientY < (currentimageheight + 10)){ 
                        ycoord += event.clientY + truebody().scrollTop - Math.max(0,(10 + currentimageheight + event.clientY - docheight));

                } else { 
                        ycoord += truebody().scrollTop + event.clientY; 
                } 
        } 
        if(ycoord < 0) { ycoord = ycoord*-1; } 
        gettrailobj().left=xcoord+"px" 
        gettrailobj().top=ycoord+"px"

    if (flag == 0) {
        i=(i+1)%numofnews;
        objid = newslist[i];
    }
} 

document.onmousemove=followmouse

