/*========================================================================
 D-HTML crossHair        === CopyRight (C) 2001 HP-DESIGN.NET
====                     === URL : http://hp-design.net/
====                     ===
====無断転載・配付は禁止です。この著作権表示を消さない事！
======================================================*/

// Browser Checker
function browserCheck(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.ie5=((this.ver.indexOf("MSIE 5")>-1) && this.dom)?1:0; 
	this.ie6=((this.ver.indexOf("MSIE 6")>-1) && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && (parseInt(this.ver) >= 5)) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ns=this.ns4||this.ns6;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

function crossHair_SetX() {
	this.css = bw.ie4?document.all['divCHX'].style:bw.dom?document.getElementById('divCHX').style:bw.ns4?document.layers['divCHXnn4'].document.layers['divCHX']:0;
	this.clipTo = SetClip;
	return this;
}
function crossHair_SetY() {
	this.css = bw.ie4?document.all['divCHY'].style:bw.dom?document.getElementById('divCHY').style:bw.ns4?document.layers['divCHYnn4'].document.layers['divCHY']:0;
	this.clipTo = SetClip;
	return this;
}


function crossHair() {
	bw = new browserCheck;
	if(bw.ie4||bw.ie5||bw.ie6){
		pageWidth = (bw.ns4 || bw.ns6)?innerWidth:document.body.clientWidth;
		pageHeight = (bw.ns4 || bw.ns6)?innerHeight:document.body.clientHeight;
		oCrossHairX = new crossHair_SetX;
		oCrossHairY = new crossHair_SetY;
		
		oCrossHairX.css.width = pageWidth-1;
		oCrossHairY.css.height = pageHeight-1;
		oCrossHairX.clipTo(0,pageWidth-1,1,0);
		oCrossHairY.clipTo(0,1,pageHeight-1,0);

		if (bw.ns4)document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = crossHair_Move;
	}
}

function SetClip(ct,cr,cb,cl) {
	if (bw.ns4){
		this.css.clip.top=ct;this.css.clip.right=cr;
		this.css.clip.bottom=cb;this.css.clip.left=cl;
	}
	else {
		this.css.clip="rect("+ct+"px "+cr+"px "+cb+"px "+cl+"px)";
	}
}

function crossHair_Move(e){
	var chmx=bw.ns?e.pageX:event.x;
	var chmy=bw.ns?e.pageY:event.y;
	var chpw=bw.ns?window.pageXOffset:document.body.scrollLeft;
	var chph=bw.ns6?window.pageYOffset:document.body.scrollTop;

	oCrossHairX.css.top = chmy + chph;
	oCrossHairY.css.top = chph;
	if(chmx < pageWidth-2) {
		oCrossHairY.css.left = chmx + chpw;
		oCrossHairX.css.left = chpw;
	}
}


