// HWT Div

var hwt_divlist = new Array();


function hwtDivMoveTo (id, x, y, smooth, ttc, cb) {

	var deltax = 0;
	var deltay = 0;
	var timestep = 25;
	var x0 = hwt_divlist[id][0];
	var y0 = hwt_divlist[id][1];
	var sty = hwt_divlist[id][8].all("__hwtDiv" + id).style;

	if (smooth) {

		deltax = x-x0;
		deltay = y-y0;

		if (deltax || deltay) {

			iterationsleft = Math.round(ttc/timestep);
			stepx = Math.round(deltax/iterationsleft);
			stepy = Math.round(deltay/iterationsleft);
			x0 += stepx;
			y0 += stepy;
			sty.left = x0;
			sty.top = y0;
			hwt_divlist[id][0] = x0;	
			hwt_divlist[id][1] = y0;
			window.setTimeout("top.hwtDivMoveTo('" + id + "'," + x + "," + y + "," + smooth + "," + (ttc-timestep) + ", '" + cb + "')", timestep);

		} else {
	
			if (cb!="") eval(cb);
		}

	} else {

		hwt_divlist[id][0] = x;
		hwt_divlist[id][1] = y;
		sty.left = x;
		sty.top=y;
		if (cb!="") eval(cb);
	}

	return;
}


function hwtDivResize (id, x, y, smooth, ttc) {

	var deltax = 0;
	var deltay = 0;
	var timestep = 25;
	var x0 = hwt_divlist[id][2];
	var y0 = hwt_divlist[id][3];

	var sty = hwt_divlist[id][8].all("__hwtDiv" + id).style;

	if (smooth) {

		deltax = x-x0;
		deltay = y-y0;

		if (deltax || deltay) {

			iterationsleft = Math.round(ttc/timestep);
			stepx = Math.round(deltax/iterationsleft);
			stepy = Math.round(deltay/iterationsleft);
			x0 += stepx;
			y0 += stepy;
			sty.width = x0;
			sty.height = y0;
			hwt_divlist[id][2] = x0;	
			hwt_divlist[id][3] = y0;
			window.setTimeout("top.hwtDivResize('" + id + "'," + x + "," + y + "," + smooth + "," + (ttc-timestep) + ")", timestep);
		}

	} else {

		hwt_divlist[id][2] = x;
		hwt_divlist[id][3] = y;
		sty.width = x;
		sty.height=y;
	}

	return;
}



function hwtDivSetVisible (id, visible) {

	var sty = hwt_divlist[id][8].all("__hwtDiv" + id).style;

	if (visible) {

		sty.visibility = "visible";
		hwt_divlist[id][6] = "visible";

	} else {

		sty.visibility = "hidden";
		hwt_divlist[id][6] = "hidden";
	}

	return;
}
		


function hwtDivAdd (id, left, top, width, height, color, bgcolor, visibility, bodycb) {

	hwt_divlist[id]=[left, top, width, height, color, bgcolor, visibility , bodycb, null];

	return;
}



function hwtDivBindToDoc (id, doc) {

	hwt_divlist[id][8] = doc;

	return;
}



function hwtDivDraw (id) {

	var out = '';
  	out += '<DIV id="__hwtDiv' + id + '" style="color:' + hwt_divlist[id][4] + '; backgroud-color:' + hwt_divlist[id][5] + '; layer-backgroud-color:' + hwt_divlist[id][5] + '; position:absolute; margin:0px; padding:0px; border:0px; top:' +  hwt_divlist[id][1] + 'px; left:' + hwt_divlist[id][0] + 'px; width:' + hwt_divlist[id][2] + 'px; height:' + hwt_divlist[id][3] + 'px; visibility:' + hwt_divlist[id][6] + ';">\n';  
   	out += eval(hwt_divlist[id][7]);
	out += '</DIV>\n';

	return (out);

}

