/*

		dw_posrel.js

		contains posRel method for dynObj

		adapted from cross-browser.com - Mike Foster



		This code is from Dynamic Web Coding 

    at http://www.dyn-web.com/

    See Terms of Use at http://www.dyn-web.com/bus/terms.html

    Permission granted to use this code 

    as long as this entire notice is included.		

*/



// position layer in window or containing layer

dynObj.prototype.posRel = function(loc,mar,container) {

	if (!container) {

		cWd = getWinWidth();

		cHt = getWinHeight();

	} else {

		cWd = container.width;

		cHt = container.height;

	}	

	switch (loc) {

		case "nw" :

			x = mar; y = mar;

			break;			

		case "n":

			x = Math.round((cWd-this.width)/2);

			y = mar;

		break;

		case "ne"	:

			x = cWd-this.width-mar;

			y = mar;

		break;

		case "w"	:

			x = mar;

			y = Math.round((cHt-this.height)/2);

		break;

		case "c" :

			x = Math.round((cWd-this.width)/2);

			y = Math.round((cHt-this.height)/2);			

			break;

		case "e" :

			x = cWd-this.width-mar;

			y = Math.round((cHt-this.height)/2);			

		break;

		case "sw"	:

			x = mar; 

			y = cHt-this.height-mar;

		break;

		case "s"	:

			x = Math.round((cWd-this.width)/2);

			y = cHt-this.height-mar;

		break;

		case "se"	:

			x = cWd-this.width-mar;

			y = cHt-this.height-mar;			

		break;

		default	:

			alert("Wrong position chosen!")

		break;

	}

		this.leftPos = x;

		this.topPos = y;

}



