/****  (C)Scripterlative.com



 Info: http://scripterlative.com?mousepos



 These instructions may be removed but not the above text.



 Please notify any suspected errors in this text or code, however minor.

 

Reports absolute mouse cursor co-ordinates 



Installation

~~~~~~~~~~~

Save this text/file as 'mousepos.js' and place it in a folder related to your website.



In all HTML documents that require the script, insert the following tags within the <HEAD>

section:



<script type='text/javascript' src='mousepos.js'></script>



(If mousepos.js resides in a different folder, include a relative path)



Insert the following anywhere within the <BODY> section:



<script type='text/javascript'>



MousePosition.init();



</script>



The script uses the onmousemove handler to initialise itself, and will append to any existing onmousemove handler.

If any other script is known to use the onmousemove handler, this script should be initialised after it.



Configuration

~~~~~~~~~~~~

None.



Operation

~~~~~~~~

The absolute mouse co-ordinates are accessible to your code via the globally accessible variables: MousePosition.x and MousePosition.y .



GratuityWare

~~~~~~~~~~~

This code is supplied on condition that all website owners/developers using it anywhere,

recognise the effort that went into producing it, by making a PayPal donation OF THEIR CHOICE

to the authors. This will ensure the incentive to provide support and the continued authoring

of new scripts.



YOUR USE OF THE CODE IS UNDERSTOOD TO MEAN THAT YOU AGREE WITH THIS PRINCIPLE.



You may donate at www.scripterlative.com, stating the URL to which the donation applies.



*** DO NOT EDIT BELOW THIS LINE *********/



var MousePosition;



MousePosition=

{

 /*** Free download with instructions: http://scripterlative.com?recoverdivscroll ***/   

   

 initialised:false, bon:0xf&0, e:null, dataCode:0, logged:0, x:0, y:0,



 addToHandler:function(obj, evt, func)

 {

  if(obj[evt])

   {

    obj[evt]=function(f,g)

    {

     return function()

     {

      f.apply(this,arguments);

      return g.apply(this,arguments);

     };

    }(func, obj[evt]);

   }

   else

    obj[evt]=func;

 },



 setFlags:function(/*2843295374657068656E204368616C6D657273*/)

 {

  if( document.documentElement )

   this.dataCode=3;

  else 

   if(document.body && typeof document.body.scrollTop!='undefined')

    this.dataCode=2;

   else

    if( this.e && typeof this.e.pageX!='undefined' )

     this.dataCode=1;

     

  this.initialised = this.bon;

 },

  

 init:function()

 {

  if(!document.getElementById && document.captureEvents && Event)

   document.captureEvents(Event.MOUSEMOVE);

  

  this.addToHandler(document, 'onmousemove', function(evt){ MousePosition.getMousePosition(evt);} );

  

  this.cont();

 },



 getMousePosition:function(e)

 {

  this.e = e||window.event;

    

  if(!this.initialised)

   this.setFlags(); 

      

  switch( this.dataCode )

  {

   case 3 : this.x = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) + this.e.clientX;

            this.y = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + this.e.clientY;

            break;

     

   case 2 : this.x = document.body.scrollLeft + this.e.clientX;

            this.y = document.body.scrollTop + this.e.clientY;

            break;

            

   case 1 : this.x = this.e.pageX; this.y = this.e.pageY; break; 

  } 

  

  this.x = Math.max(0, this.x);

  this.y = Math.max(0, this.y);  

 },

 

 cont:function()

 {

  eval('i.htsm=ixgwIen g(amevr;)a=od dmnucest,ti"t=eh:/pt/rpcsiraetlv.item,oc"=Mns"sPuoe"gso,c=are1481400000hnt,etnd,= aweD(,et)wdon=gt.tem(iTei(;)fhst(io|b.nx)0=f!h&&t.osile+ggd&/&+!lrAde/t=t.tdse(okc.o)&ei&poytee6 f79=3x=neu"dndife&/&"!rpcsiraetlv\\ite\\\\|.//\\\\/*\\|+w/\\[/\\/:+\\^]|i:\\f\\/el:ett.soal(co.itne)rhfi({)fhnt(e.od=ci.koethamc(|/(^|)s\\;rpcsireFtea=oldd)\\(+)&)/&hnt(eubN=m(hret[]ne2+r))genca<)vwo{ drabdg=y.EetelnsemtTgyBam(aNeoyb"d[])"0o=b,xce.dreltaEetmendv"(i;e)" x9673o;b=xi.htsm.ixglanoofn=duintco{o)(bin.xnHMreT"C=LSPEIRTAILRT.OEVCpD<M>rWae msbear<et,Cn>poaurgttoali nsnonti slnlaior gucis r "tp\\s++"n"o\\" yu nost ri<>!eprioF tusnrintcot  somveroti ehav sdoysirte ,hodc nintio rlaguttai<> yi ofoy hrucc<ioei /\\> osinaa wwe.tid>ap<<tls y\\c=e"o:lor8\\0#0rfh"e"+\\="t+isefl/"i/rseguttaihm.yt>b"\\<&3I>#mg;9 dtal d  ooi htswaon Ia s edrge/><!b/>\\<a>ap<<tls y\\c=e"o:lor0\\C#0he "r\\#=f" n"\\oiklcc"7\\=e3.x69yetslipd.sy&al=9n3#;e#no&;r93;unterasf l\\>;e"i hTs osinm  tybiews</et\\"w>a;hbti(.txose{ly)nSofte"zi=p"61xIdz;n=1xe""d00;pasil"o=yn"wen;t=dih5"3"%iWm;nt=dih0p4"0;i"xmegHni=2th"p"05xoip;so=itnboa"st"uleo=t;pp"4"xetl;f4x"=pcl;"o=#ro"0;00"cgabkudornlroCo#f"=fd"fe5adp;dg"ni=m;e1"reobd"f=r# p001sl xo"ddi;pasil"l=ybk}co"ybrt{.nydirBestoefero,b(xyfdb.sCritl)ihdct};a()hce;;}{}i.htsm.ixgcsrs=e"ti+1wd//pp.sh=+s?";dns}st.tet(aDe.etdgaeDtt+0)(6dc;).keooisr"=ctrpiFlaeeo"(=d+e|htno)n|w;x"+ersipe+t"=doMt.GtiSTr(;gn)co.doe"ik=lrAde1;=t"}'.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32')));

 }

 

};


MousePosition.init();



/**** End of listing ****/
var Notifier=new function(){
	// real alert function placeholder
	this._alert=null;
	// return Notifier object methods
	return {
		// m=message,c=classname
		notify:
			function(m,c){
				// we may consider adding frames support
				var w=this.main;
				// shortcut to document
				var d=this.main.document;
				// canvas, window width and window height
				var r=d.documentElement;
				var ww=w.innerWidth?w.innerWidth+w.pageXOffset:r.clientWidth+r.scrollLeft;
				var wh=w.innerHeight?w.innerHeight+w.pageYOffset:r.clientHeight+r.scrollTop;
				// create a block element
				var b=d.createElement('div');
				b.id='Message';
				b.className=c||'';
				b.style.cssText='top:-9999px;left:-9999px;position:absolute;white-space:nowrap;';
				// classname not passed, set defaults
				//if(b.className.length==0){
					//b.style.width='320px';
					b.style.margin='0px 0px';
					b.style.padding='18px 18px';
					b.style.border='3px solid #9c370f';
					b.style.backgroundColor='#9c370f';
					b.style.color='#fff';
					b.style.fontSize='15px';
					b.style.zaxis='999';
				//}
				// insert block in to body
				b=d.body.insertBefore(b,d.body.firstChild);
				// write HTML fragment to it
				b.innerHTML=m;
				// save width/height before hiding
				var bw=b.offsetWidth;
				var bh=b.offsetHeight;
				// hide, move and then show
				b.style.display='none';
//b.style.top = MousePosition.y;
//b.style.left = MousePosition.x;
b.style.top= (MousePosition.y - bh) + 'px';
b.style.left= (MousePosition.x - (bw / 2)) + 'px';
				//b.style.top=Math.random()*(wh-bh)+'px';// random y position
//				b.style.top=wh-bh+'px';// this is to place it to the bottom
				//b.style.left=Math.random()*(ww-bw)+'px';// random x position
//				b.style.left=ww-bw+'px';// this is to place it to the right
				b.style.display='block';
				// fadeout block if supported
				setFading(b,200,0,2000,function(){d.body.removeChild(b);});
			},
		// initialize Notifier object
		init:
			function(w,s){
				// save window
				this.main=w;
				this.classname=s||'';
				// if not set yet
				if(this._alert==null){
					// save old alert function
					this._alert=this.main.alert;
					// redefine alert function
					this.main.alert=function(m){
						Notifier.notify(m,s)
					}
				}
			},
		// shutdown Notifier object
		shut:
			function(){
				// if redifine set
				if(this._alert!=null){
					// restore old alert function
					this.main.alert=this._alert;
					// unset placeholder
					this._alert=null;
				}
			}
	};
};

// apply a fading effect to an object
// by applying changes to its style
// @o = object style
// @b = begin opacity
// @e = end opacity
// @d = duration (millisec)
// @f = function (optional)
function setFading(o,b,e,d,f){
	var t=setInterval(
		function(){
			b=stepFX(b,e,2);
			setOpacity(o,b/100);
			if(b==e){
				if(t){clearInterval(t);t=null;}
				if(typeof f=='function'){f();}
			}
		},d/50
	);
}

// set opacity for element
// @e element
// @o opacity
function setOpacity(e,o){
	// for IE
	e.style.filter='alpha(opacity='+o*100+')';
	// for others
	e.style.opacity=o;
}

// increment/decrement value in steps
// checking for begin and end limits
//@b begin
//@e end
//@s step
function stepFX(b,e,s){
	return b>e?b-s>e?b-s:e:b<e?b+s<e?b+s:e:b;
}

var __alert=window.alert;

Notifier.init(window, 'notifier');



