//- Instinct_Layer -//
function Instinct_Layer(oInstinct, cName) {
//- Model - Initialize -//
	this.name = cName;
	this.divName = cName;
	this.layerName = this.divName;
	this.buffer = '';
	this.oLayer = null;
	this.oEventLayer = null;
	this.isFirstGen = true;	// flag to indicate is the contents are being generated for the first time
	this.width = 0;
	this.height = 0;
	this.parentObject = null;

	switch (oInstinct.Detect.Engine) {
	case "W3":
	case "IE":
		Instinct_Layer_W3(this);
		break;
		
	case "??":
	case "NS":
	default:
		Instinct_Layer_NS(this);
		break;
	}
	this.onLoad();

//- Model - Link -//
	this.alignToImage = alignToImage;
	this.scrollTo = scrollTo;
	this.scrollBy = scrollBy;
	
//- Model - Implementation -//
	// -- Implementation : Common Interface -- //
	function scrollTo(nX, nY, bBound) {
		var nx = this.getClipLeft() - nX;
		var nx = this.getClipTop() - nY;
		this.scrollBy(-nx, -ny, bBound);
	}
	
	function scrollBy(nX, nY, bBound) {
		var clipLeft = this.getClipLeft();
		var clipTop = this.getClipTop();
		var clipRight = this.getClipRight();
		var clipBottom = this.getClipBottom();
		if (bBound == true) {
			if (clipLeft + nX < 0) nX = -clipLeft;
			else if (clipRight + nX > this.oLayer.getWidth()) nX = this.oLayer.getWidth() - clipRight;
			if (clipTop + nY < 0) nY = -clipTop;
			else if (clipBottom + nY > this.oLayer.getHeight()) nY = this.oLayer.getHeight() - clipBottom;
		}
		this.oLayer.clipLayer(clipLeft + nX, clipTop + nY, clipRight + nX, clipBottom + nY);
		this.oLayer.moveBy(-nX,-nY);
	}
	
	function alignToImage(cImage, nOffsetLeft, nOffsetTop) {
		var oImage = new Instinct_Image(oInstinct, cImage);
		if (oImage.Image == null) {return false;}

		this.moveTo(oImage.getX() + nOffsetLeft, oImage.getY() + nOffsetTop);
		return true;
	}
}
	
//- static methods -//
var Instinct_Layer__getLayer;
if ((oInstinct.Detect.Engine == "IE") || (oInstinct.Detect.Engine == "W3")) {
	Instinct_Layer__getLayer = Instinct_Layer_W3__getLayer;
} else {
	Instinct_Layer__getLayer = Instinct_Layer_NS__getLayer;
}
function Instinct_Layer__BindToLayer(oInstinct, cName) {
	var oLayer = new Instinct_Layer(oInstinct, cName);
	oLayer.oLayer = Instinct_Layer__getLayer(cName);
	return oLayer;
}