var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var strAgent = navigator.userAgent.toLowerCase();
var bIE = (strAgent.indexOf("msie") != -1);
var bXP = (strAgent.indexOf("nt 5.1") != -1);
var bIE7 = (strAgent.indexOf("msie 7.0") != -1);
var bSafari = (strAgent.indexOf("konqueror") != -1 || strAgent.indexOf("safari") != -1);
var bFirefox = (strAgent.indexOf("firefox")!= -1);

var callSpeed = 0;
var sTime = 0;

var x = 0;
var y = 0;

var skinW = 0;
var skinH = 26;

function onMoveWin()
{
	x = (screen.availWidth-document.body.clientWidth)/2;
	y = (screen.availHeight-document.body.clientHeight)/2;

	width = document.body.offsetWidth + skinW;
	height = document.body.offsetHeight + skinH;

	skinW = (width - document.body.offsetWidth) + 1;
	skinH = (height - document.body.offsetHeight) + 1;
}
function resizeWinFunc(tW, tH, rTime)
{
	onMoveWin();
	
	var tX = (screen.availWidth-tW)/2;
	var tY = (screen.availHeight-tH)/2;
	var tW = tW + skinW;
	var tH = tH + skinH;

	easingMove(tX, tY, tW, tH, rTime);
}
function easeInOut(t, b, c, d)
{
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
}

function easingMove(tX, tY, tW, tH, rTime)
{
	var dX = tX - x;
	var dY = tY - y;
	var dW = tW - width;
	var dH = tH - height;

	var cX = Math.round(easeInOut(sTime, x, dX, rTime));
	var cY = Math.round(easeInOut(sTime, y, dY, rTime));
	var cW = Math.round(easeInOut(sTime, width, dW, rTime));
	var cH = Math.round(easeInOut(sTime, height, dH, rTime));

	self.moveTo(cX, cY);
	self.resizeTo(cW, cH + (bXP ? (bIE7 ? 40: 20) : 0));

	sTime++;

	if(sTime >= rTime)
	{
		x = tX;
		y = tY;
		width = tW;
		height = tH;

		skinW = 0;
		skinH = 26;

		self.moveTo(tX, tY);
		self.resizeTo(tW, tH + (bXP ? (bIE7 ? 40: 20) : 0));

		sTime = 0;

		getMovieName("index").closeLoader()
	}
	else
	{
		setTimeout("easingMove(" + tX +"," + tY + "," + tW + "," + tH + "," + rTime + ")", callSpeed);
	}
}
function getMovieName(movieName) 
{
	if (navigator.appName.indexOf("Microsoft") != -1) 
	{
		return window[movieName]
	}
	else 
	{
		return document[movieName]
	}
}