//0=x, 1=y 2=  src -> always 3 = obj id



function casImg() {//var i = 0;/////////////////////
	if(typeof document.myimages=='undefined') document.myimages = new Array();
	var docimg=null;
	this.setsrc = function(imid, s) {document.myimages[imid].src = s;};//---- setsrc-------
	this.getsrc = function(imid) {return document.myimages[imid].src;};//---- getsrc-------
	this.setobj = function(imid) {docimg = getOBJ(imid);}; //-------------- setobj-------
	this.objset = function() {return (docimg) ? true : false;}; //--------- objset-------
	this.setobjsrc = function(s) {if(docimg) docimg.src = s;else alert('No img obj set')}; //------------------------------------------------------------------------ setobjsrc -------
	this.getx = function() {return document.myimages[baseimg].width;}; //---- getx-------
	this.gety = function() {return document.myimages[baseimg].height;}; //--- gety-------
	this.set = function(imid, x, y) { //-------------------------------------- set-------
		if(imid) this.setobj(imid);
		if(x) docimg.style.width = x + 'px';
		if(y) docimg.style.height = y + 'px';
		docimg.src=document.myimages[this.baseimg].src;
	};

	this.secureload = function(imid) {//-------------------------------- secureload -------
		if(document.myimages[imid].complete) return true;
		else setTimeout(function(){return seclo(imid);}, 10);
	};
	this.getind = function(src) {//----------------------------------- getind -------
		var st = src.lastIndexOf('/'), en = src.lastIndexOf('.');
		return src.substring(((st>0) ? st+1 : 0), en);
	};
	this.setimg = function(ind, x, y) { if(!document.myimages[ind]) document.myimages[ind] = new Image(x, y);}; //-----------------/////////////////------------------ setimg -------
	
	var seclo = this.secureload;
	this.baseimg = this.getind(arguments[2]);
	this.setimg(this.baseimg, arguments[0], arguments[1]);
	this.setsrc(this.baseimg, arguments[2]);
	if(arguments[3]) this.setobj(arguments[3]);
}

function captimg(x, y, b, c, o, j) {
	_Inheritance(new casImg(x, y, b, j), this);
	this.capt = c;
	this.orient = o;
}

function crollimg(x, y, off, onn, objid) {
	_Inheritance(new casImg(x, y, off, objid), this);
	var stat = 0, onimg = this.getind(onn);
	this.setimg(onimg, x, y);
	this.setsrc(onimg, onn);
	
	this.setof = function() {this.setobjsrc(this.getsrc(this.baseimg)); stat=0;};
	this.seton = function() {this.setobjsrc(this.getsrc(onimg)); stat=1;};
	this.getstatus = function() {return stat;};
	this.setstatus = function(s) {stat = s;};
	
	

//	this.getsrco = function() {return imgon.src;};
}

function crollink(x, y, off, onn, nol, objid) {
	_Inheritance(new crollimg(x, y, off, onn, objid), this);
	var imgnol = this.getind(nol);
	this.setimg(imgnol, x, y);
	this.setsrc(imgnol, nol);
	
	this.setnol = function(oid) {
		if(oid && !this.objset()) this.setobj(oid);
		this.setobjsrc(this.getsrc(imgnol));
		this.setstatus(-1);
	};	
	
//	this.getsrcn = function() {return imgnol.src;};
}

