
function openWindow(url, name, gWidth, gHeight) {//ceio v1.0
  if (document.all || document.layers) {
    w = screen.availWidth;
    h = screen.availHeight;
  }
  var leftPos = (w-gWidth)/2, topPos = (h-gHeight)/2;
  window.open(url,name, 'status=no,toolbar=no,scrollbars=yes,resizable=yes,width=' + gWidth + ',height=' + gHeight + ',top=' + topPos + ',left=' + leftPos);
}

function MM_openBrWindow(theURL,winName,features,width,height) { //v2.0
	var left=(screen.width-width)/2, top=(screen.height-height)/2;
	window.open(theURL,winName,features+',width='+width+',height='+height+',top='+top+',left='+left);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getByID(n) {
	var d = window.document;
	if (d.getElementById)
		return d.getElementById(n);
	else if (d.all)
		return d.all[n];
}

function showHide(item) {
	var obj = getByID('show_hide_' + item);
	var lnk_obj = getByID('show_hide_link_' + item);
	if (obj && lnk_obj)
		if (obj.style.display == 'none') {
			obj.style.display = 'block';
			lnk_obj.style.backgroundImage = 'url(/i/tp_06_arrow_down.gif)';
		} else if (obj.style.display == 'block') {
			obj.style.display = 'none';
			lnk_obj.style.backgroundImage = 'url(/i/tp_06_arrow_right.gif)';
		}
}

window.onload = function () {

	if (!document.getElementsByTagName) return true;

	ourForms = document.getElementsByTagName('form');

	// go through each form
	var numForms = ourForms.length;
	for (var i=0;i<numForms;i++) {

		// go through each form element
		var numFormElements = ourForms[i].elements.length;
		for (var j=0;j<numFormElements;j++) {

			var el = ourForms[i].elements[j];

			// ignore submit buttons
			if (el.type == "submit") continue;

			// if we got a text type input
			if (el.type == "text") {
				// only populate if we want it to
				// note: might want title attribute but no pre-population of inputs
				var ourClassName = el.className;
				if (ourClassName.match('auto-select') || ourClassName.match('login_field') || ourClassName.match('populate')) {
					// only populate if empty
					if (el.value == '') el.value = el.title;
				}

				// add auto select if class contains auto-select
				// note: else if below so auto-select takes precedence (assuming select is better than clear)
				if (el.className.match('auto-select')) {
					el.onfocus = function () {
						if (this.value == this.title) this.select();
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);
				}

				// add auto clear if class contains login_field
				else if (el.className.match('login_field')) {
					el.onfocus = function () {
						if (this.value == this.title) this.value = '';
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);

					el.onblur = function () {
						if (this.value == '') this.value = this.title;
					}
					if (el.captureEvents) el.captureEvents(Event.BLUR);
				}
			}

			// if we got a textarea
			if (el.type == "textarea") {
				// only populate if we want it to
				// note: might want title attribute but no pre-population of inputs
				var ourClassName = el.className;
				if (ourClassName.match('auto-select') || ourClassName.match('login_field') || ourClassName.match('populate')) {
					// only populate if empty
					if (el.value == '') el.value = el.title;
				}

				// add auto select if class contains auto-select
				if (el.className.match('auto-select')) {
					el.onfocus = function () {
						if (this.value == this.title) this.select();
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);
				}

				// add auto clear if class contains login_field
				else if (el.className.match('login_field')) {
					el.onfocus = function () {
						if (this.value == this.title) this.value = '';
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);

					el.onblur = function () {
						if (this.value == '') this.value = this.title;
					}
					if (el.captureEvents) el.captureEvents(Event.BLUR);
				}
			}

		}

	}

}
