/***********************************************
* Sticky Note script- ¿ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
* Go to http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablefade="no" //("yes" to enable fade in effect, "no" to disable)
var autohidebox=["no"] //Automatically hide box after x seconds? [yes/no, if_yes_hide_after_seconds]
var showonscroll="yes" //Should box remain visible even when user scrolls page? ("yes"/"no)
var IEfadelength=1 //fade in duration for IE, in seconds
var Mozfadedegree=0.05 //fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2)

////////No need to edit beyond here///////////

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true
}


function displayfadeinbox(element_id, center){
	var ie=document.all && !window.opera
	iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	objref= document.getElementById(element_id)
	var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
	var docwidth=(ie)? iebody.clientWidth : window.innerWidth
	docheight=(ie)? iebody.clientHeight: window.innerHeight
	var objwidth=objref.offsetWidth
	objheight=objref.offsetHeight

	if (center) {
	        objref.style.left=docwidth/2-objwidth/2+"px" 
	        objref.style.top=scroll_top+docheight/2-objheight/2+"px" 
	} else {
		if (tempX + objwidth > docwidth - 50)
			tempX = docwidth - objwidth - 50
//		if (tempY + 10 + objheight - scroll_top > docheight)
//			tempY = docheight - objheight - 30 + scroll_top
		objref.style.left=tempX+"px" 
		if (ie)
			objref.style.top=(tempY + 20 + scroll_top)+"px"  
		else
			objref.style.top=(tempY + 20)+"px"
	}

	if (showonscroll=="yes")
		showonscrollvar=setInterval("staticfadebox()", 50)

	if (enablefade=="yes" && objref.filters){
		objref.filters[0].duration=IEfadelength
		objref.filters[0].Apply()
		objref.filters[0].Play()
	}

	objref.style.visibility="visible"
	if (objref.style.MozOpacity){
		if (enablefade=="yes")
			mozfadevar=setInterval("mozfadefx()", 90)
		else{
			objref.style.MozOpacity=1
			controlledhidebox()
		}
	} else
		controlledhidebox()
}

function mozfadefx(){
	if (parseFloat(objref.style.MozOpacity)<1)
		objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree
	else{
		clearInterval(mozfadevar)
		controlledhidebox()
	}
}

function staticfadebox(){
	var ie=document.all && !window.opera
	var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
//	objref.style.top=scroll_top+docheight/2-objheight/2+"px"
}

function hidefadebox(){
	objref.style.visibility="hidden"
	if (typeof showonscrollvar!="undefined")
		clearInterval(showonscrollvar)
}

function controlledhidebox(){
	if (autohidebox[0]=="yes"){
		var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000
		setTimeout("hidefadebox()", delayvar)
	}
}

