function openNewWindow(sURL, sName, iWidth, iHeight, bResizable, bScrollbars) {
    var iTop  = (screen.height - iHeight) / 2 ;
    var iLeft = (screen.width  - iWidth) / 2 ;
    var sOptions = "toolbar=no" ;
    sOptions += ",width=" + iWidth ;
    sOptions += ",height=" + iHeight ;
    sOptions += ",resizable="  + (bResizable  ? "yes" : "no") ;
    sOptions += ",scrollbars=" + (bScrollbars ? "yes" : "no") ;
    sOptions += ",left=" + iLeft ;
    sOptions += ",top=" + iTop ;
    var oWindow = window.open(sURL, sName, sOptions)
    oWindow.focus();
    return oWindow ;
}

function popUpPrintWindow(URLStr) {
    var pWindow = openNewWindow(URLStr, 'PrintWindow', '700', '500', 'yes', 'yes') ;
}

function SendMailWin(URLStr, iWidth, iHeight) {
    var sWindow = openNewWindow(URLStr, 'SendMailWin', iWidth, iHeight) ;
}

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;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function stop_event(e) {
	e = fix_E(e);
	e.cancelBubble = true;
	if (e.stopPropagation) {
		e.stopPropagation();
	}
}

function fix_mouseevent(e) {
	if (e.x) {
		e.pageX = e.x;
	}
	if (e.y) {
		e.pageY = e.y;
	}
	return e;
}

function fix_E(e) {
	if (!e) {
		e = window.e;
	}
	return e;
}

function viewpoint_size(viewpoint) {
	if (viewpoint.innerWidth) {
		return [viewpoint.innerWidth, viewpoint.innerHeight];
	} else if (viewpoint.document.body) {
		return [viewpoint.document.body.clientWidth, viewpoint.document.body.clientHeight];
	} else {
		return [viewpoint.document.documentElement.clientWidht, viewpoint.document.documentElement.clientHeight];
	}
}

function viewpoint_scroll(viewpoint) {
	if( typeof(viewpoint.pageYOffset) == 'number' ) {
		return [viewpoint.pageXOffset,viewpoint.pageYOffset];
	} else if (viewpoint.body) {
		return [viewpoint.body.scrollLeft, viewpoint.body.scrollTop];
	} else {
		return [viewpoint.documentElement.scrollLeft, viewpoint.documentElement.scrollTop];
	}
}
function element_size(element) {
	return [element.offsetWidth, element.offsetHeight];
}

function image_flip(elm) {
	var i;

	if ((i = elm.getAttribute('src').indexOf('-on')) == -1) {
		i = elm.getAttribute('src').lastIndexOf('.');
		elm.setAttribute('src', elm.getAttribute('src').substring(0,i) + '-on.' + elm.getAttribute('src').substring(i + 1));
	} else {
		elm.setAttribute('src', elm.getAttribute('src').substring(0,i) + elm.getAttribute('src').substring(i + 3));
	}
}