/*
* This function returns the location of the child window such that the
* child is centered with respect to the parent window.
* Return value is in the form of parameter to window.open
*/
function getChildLocation(parentX, parentY, parentWidth, parentHeight, childWidth, childHeight){
	var titleHeight = 30;
	var pw = parseInt(parentWidth+"");
	var ph = parseInt(parentHeight+"");
	var cw = parseInt(childWidth + "");
	var ch = parseInt(childHeight+"");

	var x = parseInt((pw - (cw + 10))/2);
	x = x + parseInt(parentX+"");
	var y = parseInt((ph - (ch + titleHeight))/2);

	y = y + parseInt(parentY+"");
	topLeft = parseInt(x+"");
	topRight = parseInt(y+"");
	return "screenX=" + topLeft + ",screenY=" + topRight + ",left=" + topLeft + ",top=" + topRight;
}
/*
* This function accepts the width and height of the window
* and returns a string representing the parameter to the window.open method.
*/
function getScreenXYParamString(w,h){
	return getChildLocation(0, 0, window.screen.width, window.screen.height, w, h);
}
function round (n, d) {
  n = n - 0;
  d = d || 2;
  var f = Math.pow(10, d);
  n = Math.round(n * f) / f;
  n += Math.pow(10, - (d + 1));
  n += '';
  return d == 0 ? n.substring(0, n.indexOf('.')) :
      n.substring(0, n.indexOf('.') + d + 1);
}
function getScreenXYParamsStringWithOffset(offsetX,offsetY){
	var titleHeight = 30;
	var lobbyWidth = 781;
	var lobbyHeight = 537;
	var x = round((window.screen.width - lobbyWidth)/2,0);
	var y = round((window.screen.height - (lobbyHeight + titleHeight))/2,0);
	topLeft = parseInt(x+"");
	topRight = parseInt(y+"");
	topLeft = topLeft + offsetX;
	topRight = topRight + offsetY;
	return "screenX=" + topLeft + ",screenY=" + topRight + ",left=" + topLeft + ",top=" + topRight;
}
/*
* Constructs the string representation of the current time, to the precision of milli seconds.
*/
function getDateString(){
	var d = new Date();
	return d.getHours() + "" + d.getMinutes()+ "" + d.getSeconds() + "" + d.getMilliseconds();
}
function isRefresh(e){
	if(window.event){ //IE
		keyNum = e.keyCode;
	}else if(e.which){ //Others
		keyNum = e.which;
	}
	if(keyNum == 116 || (e.ctrlKey && keyNum == 82) || (e.metaKey && keyNum == 82)){
		top.frames[6].document.GameLobby.doJob("31","","");
		top.reset();
	}
}