var IE = document.all?true:false
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
 
if (!IE) document.captureEvents(Event.MOUSEMOVE)
if (!IE) document.captureEvents(Event.MOUSEDOWN)
if (!IE) document.captureEvents(Event.MOUSEUP)

window.onscroll = function check_heading() {
												if(autoscroll == true) return false;
												manualhash=false;
												var sections = getElementsByClass('section');
												var pageTop = getPageTop();
												if(pageTop[1]==0)
												{
													
													window.location.hash = "/" + slug;
													
													oldhash = slug;
												}
												var didsomething = 0;
												for (var i in sections) {
													//alert(i);
													if (sections[i].id != "undefined") {
														elid = sections[i].id;
														sectionRect = getElementRect(sections[i],true);
														if (rectsIntersect(sectionRect,pageTop)) {
															
															thishash = "/" + elid.replace("div/","");
															if(oldhash != thishash)
															{
																window.location.hash = thishash;
																textmark(elid.replace("div/",""));
																document.title = document.getElementById(elid.replace("div/","")).innerHTML;
																didsomething = 1;
															}
															oldhash = thishash;
														}
														
													}
												}
												
											}



document.onmousemove = function getMouseXY(e) {
													try {
													  if (IE) {
														mouseX = event.clientX + document.body.scrollLeft
														mouseY = event.clientY + document.body.scrollTop
													  } else {
														mouseX = e.pageX
														mouseY = e.pageY
													  }  
													  if (mouseX < 0){mouseX = 0}
													  if (mouseY < 0){mouseY = 0}  
													  
													  if(dragging)
													  {
														frame = document.getElementById('supplement');
														blindspot = getElementRect(document.getElementById('imglink'));
														hotspot = Array(mouseX,mouseY,mouseX+1,mouseY+1);
														if(blindspot != null && blindspot != undefined)
														{
															bad = rectsIntersect(blindspot,hotspot);
														}
														if(!bad)
														{
															frame.style.left 	= mouseX-popOffsetX+"px";
															frame.style.top 	= mouseY-popOffsetY+"px";
														}
														else
														{
															dragging = false;
														}
													  }
													  }catch(e){}
												}



document.oncontextmenu = function mischandler()	{	return true;	}
 
document.onmousedown = function mousehandler(e)	{
														var myevent = (isNS) ? e : event;
														var eventbutton = (isNS) ? myevent.which : myevent.button;
														if((eventbutton==2)||(eventbutton==3)) return false;
													}
 
 document.onmouseup = function mup(){ dragging = false;}
 

 
 window.onhashchange = function() { setCookie("placemark",window.location.hash,365);  if(manualhash==true){rootinit();} manualhash=false;  }
 
 
 window.onfocus = function() { manualhash=false; }
 window.onblur = function() { manualhash=true; }
