/*
	----------------------------------
	opens a new window with parameters
	example: <a href="javascript:NewWindow('open_this_page.html','browserTitle','430','560','100','50','no','no','yes','no','yes','yes','auto','no');">open window</a>
	----------------------------------
*/
var objWin = null;

function NewWindow(thepageurl,thename,w,h,l,t,toolbar,location,directories,statusbar,resize,menubar,scroll,copyhistory)
{
	var LeftPosition = l;
	var TopPosition = t;
	if (l == 'center')
		{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		}
	if (t == 'center')
		{
		TopPosition = (screen.height) ? (screen.height-h)/4 : 0;
		}
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',status='+statusbar+',toolbar='+toolbar+',location='+location+',directories='+directories+',menubar='+menubar+',copyhistory='+copyhistory;
	objWin = window.open(thepageurl,thename,settings);
	if(objWin.focus){objWin.focus();}
}

/* var w3cDOM */
var w3cDOM = (document.getElementById) ? true : false;

/* accessibleFormField */
function accessibleFormField(id){
	var obj0 = document.getElementById(id);
	if(obj0) {
		obj0.onfocus= function() {this.className+=' inwork'; if (this.value!=this.defaultValue) this.select(); else this.value="";}
		obj0.onblur = function() {
			  this.className = this.className.replace(/\sinwork/, '');
			  if (this.value=="") {this.value=this.defaultValue;}
			  this.value=this.value;
		}
	}
}

/* 
http://www.scottandrew.com/weblog/articles/cbs-events
*/
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
	return false;
  }
} 

