/******************************************
* Cross browser cursor trailer script- By Brian Caputo (bcaputo@icdc.com)
* Visit Dynamic Drive (http://www.dynamicdrive.com/) for full source code
* Modified Dec 31st, 02' by DD. This notice must stay intact for use
******************************************/

var strVars = window.location.search;
strVars = strVars.replace("?","");
var splitVars = new Array();
var vars = new Array();
splitVars = strVars.split("&");
for(i=0;i<splitVars.length;i++)
{
var tmp = splitVars[i].split("=");
var nname = tmp[0];
vars[nname] = tmp[1];
}

A=document.getElementById
B=document.all;
C=document.layers;
className="kids";
var isIE = (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf('Opera') == -1);

T1=new Array("assets/mini1.gif",40,40,"assets/mini2.gif",40,40,"assets/mini3.gif",40,40,"assets/mini4.gif",40,40);

var offsetx=40 //x offset of trail from mouse pointer
var offsety=0 //y offset of trail from mouse pointer

nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;

if(vars[unescape("%66%6C%69%65%73")]==unescape("%68%75%6E%67%72%79")) {
    for (i=0;i<nos;i++){
       T1[i*3]=unescape("%61%73%73%65%74%73%2F%63%72%61%70%3"+(i+1)+"%2E%67%69%66");
    }
} 

// Get page offset and height;
var arrayPageSize = getPageSize();

rightedge=B? document.body.clientWidth-T1[1] : window.innerWidth-T1[1]-20
//bottomedge=B? document.body.scrollTop+document.body.clientHeight-T1[2] : window.pageYOffset+window.innerHeight-T1[2]
bottomedge=arrayPageSize[1]-T1[2];

for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")
}

function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!A && !B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "\n<div id='"+N+"'"+" class='"+className+"' style='position:absolute;left:"+Xp+"px; top:"+Yp+"px;");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((A || B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}

function closeContainer(){
document.write((A || B)?"</div>":"</layer>")
}

function getXpos(N){
if (A)
return parseInt(document.getElementById(N).style.left)
else if (B)
return parseInt(B[N].style.left)
else
return C[N].left
}

function getYpos(N){
  if (A){
    return parseInt(document.getElementById(N).style.top);
  }
  else if (B){
    return parseInt(B[N].style.top);
  }
  else {
    return C[N].top;
  }    
}

function moveContainer(N,DX,DY,OS){
  c=(A)? document.getElementById(N).style : (B)? B[N].style : (C)? C[N] : "";
  if (!B){
    rightedge=window.innerWidth-T1[1]-20
    bottomedge=window.pageYOffset+window.innerHeight-T1[2]
  }

  c.left=Math.min(rightedge, DX+offsetx);
  c.top=Math.min(bottomedge, DY+offsety+OS);
}

function cycle(){


//if (IE5) 
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
  moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)),0)
  }
}

function newPos(e){
if(isIE){
    var newPageOffset = getPageScroll();
    var newYoffset = parseInt(newPageOffset[1]);
}
else {
    var newYoffset = 0;
}
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2,newYoffset);
}

function getedgesIE(){
rightedge=document.body.clientWidth-T1[1]
bottomedge=document.body.scrollHeight-T1[2]
}

// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

// Get Page size by Lokesh Dhakar - http://www.huddletogether.com

function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

//document.body.onclick = function () {alert(getYpos('CUR1'));}

if (B){
window.onload=getedgesIE
window.onresize=getedgesIE
}

if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
