function centerPageSet(){
	var obj = document.getElementById('pageSet');
	var content = document.getElementById('main');
	
	var w = getWindowWidth();	
	var h = getWindowHeight();
	
	var x = Math.round((w-800)/2);
	obj.style.left = x+'px';

	/*
	var h = getWindowHeight();	
	var y = Math.round((h-186)/2);
	obj.style.top  = y+'px';
	*/
	
	obj.style.display = 'block';
	
	if(content){
		var ch = content.offsetHeight;
		if(ch<(h-300)){
			content.style.height = h-330;
		}
	}
}

/** 
 * Return height of current window
 * Shoule add a layer 'measure' in the body
 */
function getWindowHeight(){	
	return (document.getElementById("measure"))?(document.getElementById("measure").offsetHeight):document.body.offsetHeight;
}

/**
 * Return width of current window
 * Shoule add a layer 'measure' in the body
 */
function getWindowWidth(){
	return (document.getElementById("measure"))?(document.getElementById("measure").offsetWidth):document.body.offsetWidth;
} 

/**
 * findPosX, by ppk (http://www.quirksmode.org/js/findpos.html)
 */
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

/**
 * findPosY, by ppk 
 * (http://www.quirksmode.org/js/findpos.html)
 * 
 */
function findPosY(obj){
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			//printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}

/**
 * Fix IE event  
 */
function getEvent(e){
	if(window.event){
		var e = window.event;
		var keyCode = e.keyCode;
		e.target = e.srcElement;
		e.which = e.keyCode;
	}else{
		var keyCode = e.keyCode;		
	}
	e.ENTER = (keyCode==13);
	e.ESC   = (keyCode==27);
	
	//alert(e.keyCode+','+e.which+','+e.charCode);

	return e;
}

/**
 * cross-browser event handling for IE5+, NS6 and Mozilla
 * By Scott Andrew
 */
function addEvent(elm, evType, fn, useCapture) {
	try{ // remove current event listener if it exists
		removeEvent(elm, evType, fn, useCapture);
	}catch(e){
		// no current event listener
	}
	
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);    
    } else if (elm.attachEvent) {
      elm.attachEvent('on' + evType, fn);
    } else {
      elm['on' + evType] = fn;
    }
}
/**
 * remove event from an object
 */
function removeEvent(elm, evType, fn, useCapture) {
    if (elm.removeEventListener) {
      elm.removeEventListener(evType, fn, useCapture);
    } else if (elm.attachEvent) {
      elm.detachEvent('on' + evType, fn);      
    } else {
      elm['on' + evType] = null;
    }
}
/**
 * Open window
 */
function openWin(url,width,height){
	window.open(url,"mywindow","menubar=0,resizable=1,width="+width+",height="+height); 
} 

function isInteger(e){
	var strCheck = '0123456789';
	var e = getEvent(e);
	key = String.fromCharCode(e.which);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	return true;
}

