//   ************************************************************************//
//   * Module Name		: Layer_Resize.js									*//
//   * Release			: 1.1												*//
//   * Date				: 29/02/2008										*//
//   * Project			: AGSE_TT											*//
//   * Author			: aCOSwt											*//
//   * Description		: Animation resizing a layer						*//
//   * History			: 1.0 : First Site Version							*//
//   *					: 1.1 : Misc adaptations due to CSS + differences	*//
//   *					:       MSIE / Others								*//
//   * Language			: JavaScript										*//
//   * Compatibility	: FireFox 2 - IE 7 - Opera 9 - Konqueror 3			*//
//   ************************************************************************//

function Layer_Resize(layerId,imgId,trgt_wdth,trgt_hght,incX,incY,speed){

	var	x_dist, y_dist, corrx, corry, topx, topy, funcstr, el_layer, el_img;

	el_layer=document.getElementById(layerId);
	el_img=document.getElementById(imgId);
	if(navigator.appName=="Microsoft Internet Explorer"){
		topx=parseInt(el_layer.currentStyle.left);
		topy=parseInt(el_layer.currentStyle.top);
		x_dist=trgt_wdth-parseInt(el_img.currentStyle.width);
		y_dist=trgt_hght-parseInt(el_img.currentStyle.height);}
	else{
		x_dist=trgt_wdth-parseInt(document.defaultView.getComputedStyle(el_img,null).getPropertyValue("width"));
		y_dist=trgt_hght-parseInt(document.defaultView.getComputedStyle(el_img,null).getPropertyValue("height"));
		topx=parseInt(document.defaultView.getComputedStyle(el_layer,null).getPropertyValue("left"));
		topy=parseInt(document.defaultView.getComputedStyle(el_layer,null).getPropertyValue("top"));}
	if(Math.abs(x_dist)<incX)
		corrx=0;
	else
		corrx=x_dist-(x_dist/Math.abs(x_dist))*incX;
	el_img.style.width=(trgt_wdth-corrx)+"px";
	el_layer.style.left=(topx-parseInt((x_dist-corrx)/2))+"px";
	if(Math.abs(y_dist)<incY)
		corry=0;
	else
		corry=y_dist-(y_dist/Math.abs(y_dist))*incY;
	el_img.style.height=(trgt_hght-corry)+"px";
	el_layer.style.top=(topy-parseInt((y_dist-corry)/2))+"px";
	if(!(corrx==0 && corry==0)){
		if(speed){
			funcstr="Layer_Resize('"+layerId+"','"+imgId+"',"+trgt_wdth+","+trgt_hght+","+incX+","+incY+","+speed+")";
			setTimeout(funcstr,speed);}
		else
			return(1);}
	else
		return(0);}