var wini; //Reference to a window
function PopWin(url, name, width, height) {
	h = (height) ? height : 500;
	w = (width) ? width : 600;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =  'height='+ h +',width='+ w +',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
	wini = window.open(url,name,settings);
	if (wini) wini.focus();
	return ( !wini )
}// PopWin()

function addEvent(obj,evType,fn){
	if(obj.addEventListener){
		obj.addEventListener(evType,fn,true);
		return true;
	}
	else if(obj.attachEvent){
		var r=obj.attachEvent("on"+evType,fn);
		return r;
	}
	else{
		eval("obj.on"+evType+ " = " + fn);
		return true;
	}
}

function getObj(name, ref) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		if(this.obj) 
			this.style = document.getElementById(name).style;
  }
  else if (document.all) {
		this.obj = document.all[name];
		if(this.obj)
			this.style = document.all[name].style;
  }
  else if (document.layers) {
   	this.obj = document.layers[name];
		if(this.obj)
	   	this.style = document.layers[name];
  }
	return this.obj; //secondary functionality returns reference to obj
}

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 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;
}
