/************************************************************************
File name		: MoveToTop.js
Application		: Framework 1.0
Purpose			: This page shows hovering text to return to the top of the page
Last modified	: 
--------------------------------------------------------------------------

Developed By	: R Systems International Ltd., India
--------------------------------------------------------------------------
Comments:
	This functionality has a few requirements:
	1. Add the <script src="[this file]"></script> 
	2. Call the 'callOnLoad' function from body onload event of the page.
	3. <span id="logo" style="position:absolute;top:-300px;z-index:100"></span>
	4. Works for IE only for NS call createtext function from the body onload event		

*************************************************************************/
var displayed = "<img src='../Images/icon_Expand.gif' border=0 alt='Click here to move to the top.'>"
var displayedb = "<img src='../Images/icon_ExpandDown.gif' border=0 alt='Click here to move to the bottom.'>"

///////////////////////////Do not edit below this line////////////

var logolink='javascript:window.scrollTo(0,0)';//ietruebody().clientWidth
var logolinktop='#rockbottom'//'javascript:window.scrollTo(0,ietruebody().clientHeight)';
var ns4=document.layers;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function regenerate()
{
	window.location.reload();
}

function regenerate2()
{
	if (ns4)
	setTimeout("window.onresize=regenerate",400);
}
	
function createtext()
{ //function for NS4
	staticimage=new Layer(5);
	staticimage.left=-300;
	staticimage.document.write('<a href="'+logolink+'">'+displayed+'</a>');
	staticimage.document.write('<a href="'+logolinktop+'">'+displayed+'</a>');
	//staticimage.document.write('<a href="#sectiontest"></a>');
	staticimage.document.close();
	staticimage.visibility="show";
	regenerate2();
	staticitns();
}

function staticit()
{ //function for IE4/ NS6
	//alert(w);
	//alert(h);
	var w2=ns6? pageXOffset+w : ietruebody().scrollLeft+w;
	var h2=ns6? pageYOffset+h : ietruebody().scrollTop+h;
	crosslogo.style.left=w2+"px";//969//
	crosslogo.style.top=h2+"px";
	crosslogotop.style.left=w2-19+"px"//955;
	crosslogotop.style.top=h2+"px";
	document.forms[0].hdnLogo.value = h2;
}

function staticit2()
{ //function for NS4
	staticimage.left=pageXOffset+window.innerWidth-staticimage.document.width-28;
	staticimage.top=pageYOffset+window.innerHeight-staticimage.document.height-10;
}

function inserttext()
{ //function for IE4/ NS6
	if (ie4)
	{
		crosslogo=document.all['logo'];
		crosslogotop = document.all['logo_top'];
	}	
	else if (ns6)
	{
		crosslogo=document.getElementById("logo");
	}	
		crosslogo.innerHTML='<a href="'+logolink+'">'+displayed+'</a>';
		crosslogotop.innerHTML='<a href="'+logolinktop+'">'+displayedb+'</a>';
		w = ns6 || window.opera? window.innerWidth-crosslogo.offsetWidth-20 : ietruebody().clientWidth-crosslogo.offsetWidth-20;
		h = ns6 || window.opera? window.innerHeight-crosslogo.offsetHeight-15 : ietruebody().clientHeight-crosslogo.offsetHeight-20;
		crosslogo.style.left=w+"px";//969//
		crosslogotop.style.left=w-19+"px";//955
		
		if ((document.forms[0].hdnLogo.value == '') || (document.forms[0].hdnLogo.value == '0')) 
		{
			crosslogo.style.top=h+"px";
			crosslogotop.style.top=h+"px";
			document.forms[0].hdnLogo.value = h;
		}
		else
		{
			crosslogo.style.top=document.forms[0].hdnLogo.value+"px";
			crosslogotop.style.top=document.forms[0].hdnLogo.value+"px";
		}
		
}

function staticitns()
{ //function for NS4
	startstatic=setInterval("staticit2()",90);
}

//Gets the changed Height and sets the Pointer
function calculateHeight()
{
//alert('change')
	crosslogo=document.all['logo'];
	crosslogotop = document.all['logo_top'];
	h = ns6 || window.opera? window.innerHeight-crosslogo.offsetHeight-15 : ietruebody().clientHeight-crosslogo.offsetHeight-20;
	w = ns6 || window.opera? window.innerWidth-crosslogo.offsetWidth-20 : ietruebody().clientWidth-crosslogo.offsetWidth-20;
	staticit();
}

function callOnLoad()
{//this
	
	if (ie4||ns6)
	{
		document.all.logo.innerHTML = displayed;
		document.all.logo_top.innerHTML = displayedb;
		inserttext();
	}
	else if (ns4)
		window.onload=createtext();
}

/*Set the Value of the Span ID
if (ie4)
	window.onscroll = staticit();
else if (ns6)
	startstatic=setInterval("staticit()",100);*/
	