var objDataTarget;

function drawCalendar(formAndField) {
	var Nav4 = ((navigator.appName == "Netscape"));
	if (!Nav4) {
	document.write('<img align="absmiddle" border="0" height="22" hspace="5" onMouseUp="dateMousedownEvent(event, ');
	document.write('\'');
	document.write(formAndField);
	document.write('\')" ');
	document.write('src="/images/html/calendar/calendar.gif" style="cursor:hand;"/>');
	}
}

function dateMousedownEvent(event, objInputTarget) {
	var posX = event.screenX;
	var posY = event.screenY;
	var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4))
	objDataTarget = objInputTarget;
	if (!Nav4) {
	var objMD = 
		showModalDialog(
			"images/html/calendar/calendarPopup.html", 
			window,
			"status:no;resizable:no;dialogWidth:203px;dialogHeight:235px;dialogLeft:" + posX + "px;dialogTop:" + posY + "px;"
		);
	} else {
		alert("The calendar popup only works with Internet Explorer");	
	}
}




function HelpWindow(title, message, height, width) {
    var output = "";

    if (height == null) height = 200;
    if (width == null) width = 350;

    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;

    var newWindow = window.open(
      "",
      "HelpWindow",
      "height=" + height + ",width=" + width + ",top=" + top + ",left=" + left + ",centered=yes,toolbar=no,directories=no,menubar=no,resizable=yes"
    );

    if (newWindow == null) {
      newWindow.opener = self;
    }

    output += '<form>';
    output += '<table>' + '<tr>' + '<td width="200">';
    output += '<b>' + title + '</b>' + '<br />' + '<hr />';
    output += '</td>' + '</tr>' + '<tr>' + '<td>';
    output += message;
    output += '</td>' + '</tr>';
    output += '<tr>' + '<td align="right">';
    output += '<br />' + '<input type="button" value="Close" onClick="self.close()" />';
    output += '</td>' + '</tr>' + '</table>';
    output += '</form>';

    newWindow.document.write(output);
    newWindow.document.close();

    return false;
}


var dirty = false;
function registerDirtyEvents() {
	dirty = false;
	if (document.contentForm) {
	if (document.addEventListener) {     // DOM Level 2 Event Model
		document.contentForm.addEventListener("mouseup", setDirty, true);
		document.contentForm.addEventListener("keypress", setDirty, true);
	}
	else if (document.attachEvent) {     // IE 5+ Event Model
		document.contentForm.attachEvent("onmouseup", setDirty);
		document.contentForm.attachEvent("onkeypress", setDirty);
	}
	else {     // IE 4 Event Model
		var olddownhandler = document.doform.onmouseup;
		var oldpresshandler = document.doform.onkeypress;
		document.contentForm.onmouseup = setDirty;
		document.contentForm.onkeypress = setDirty;
	}
	
	if (document.contentForm) {
		for (var i=0;i< document.contentForm.elements.length; i++) {
			var e = document.contentForm.elements[i];
			var et = e.type;
			if (et != "hidden" && et != "object" && et != "button" && et != "select-one" && et != "select-multi" && et != "") {
				try {document.contentForm.elements[i].focus();
				break; } catch (e) {}
			}
		}
	}
	}
	// do this so I dont' have to modify every XSL, this will
	// attach rollover code to every link with an 'alt' tag and
	// every image with an 'hsrc' tag.
	soopaSetup();
}
function setDirty(e) {
	dirty = true;
}
function submitPage() {
	if (dirty) {
		return confirm("Any changes will be lost ... Are you sure?");
	}

	return true;
}

/*******************************************************************
 * Simulated PROGRESS bar.
 * This works in conjunction with the pml-messages xsl template
 * Call this method onSubmit of your form or on your button action 
 * handler.
 *******************************************************************/
function showActivity(frm) {
	var pmlmessages = document.getElementById('pmlmessages');
	if (pmlmessages != null) {
		pmlmessages.style.display = 'none';
	}
	var activityElement = document.getElementById('activity');
	if (activityElement != null) {
		activityElement.style.display = 'block';
	}
}

/*******************************************************************
 * soopa-rollovers.js
 * 7/28/2001
 * www.youngpup.net
 *
 * easiest rollovers on earth, baby!
 * see www.youngpup.net for documentation.
 *******************************************************************/


function soopaSetup() {
	var img, sh, sn, sd,lnk,al;
	
	for (var i = 0; (lnk = document.links[i]); i++) {
		if (lnk.getAttribute) {
			al = lnk.getAttribute("alt");
			if (al == null || al == "") {
				al = lnk.getAttribute("name");
			}
			if (al != null && al != "") {
				lnk.onmouseover = soopaASwapOn;
				lnk.onmouseout = soopaASwapOff;
			} 
		}
	}


	for (var i = 0; (img = document.images[i]); i++) {
		if (img.getAttribute) {

			sn = img.getAttribute("src");
			sh = img.getAttribute("hsrc");
			sd = img.getAttribute("dsrc");
			
			if (sn != "" && sn != null) {
				img.n = new Image();
				img.n.src = img.src;
			
				if (sh != "" && sh != null) {
					img.h = new Image();
					img.h.src = sh;
					img.onmouseover = soopaSwapOn
					img.onmouseout  = soopaSwapOff
				}

				if (sd != "" && sd != null) {
					img.d = new Image();
					img.d.src = sd;
					img.onmousedown = soopaSwapDown
				}
			}
		}
	}
}

function soopaASwapOn() {
	var	al = this.getAttribute("alt");
	if (al == null || al == "") {
		al = this.getAttribute("name");
	}

	var e = document.getElementById("rolloverText");
	if (e != null) e.innerHTML = al;

	window.status = al;
	return true;
}

function soopaASwapOff() {
	var e = document.getElementById("rolloverText");
	if (e != null) {
		e.innerHTML = '';
		var originalText = e.getAttribute("original");
		if (originalText != null) {
			e.innerHTML = originalText;
		} else {
			e.innerHTML = '';
		}
	}
	window.status = '';
	return true;
}



function soopaSwapOn() {
	this.src = this.h.src;
	var e = document.getElementById("rolloverText");
	if (e != null) e.innerHTML = this.alt;
	window.status = this.alt;
	return true;
}

function soopaSwapOff() {
	this.src  = this.n.src;
	var e = document.getElementById("rolloverText");
	//if (e!= null) e.innerHTML = 'Rollover Icon for Description -->';
	if (e != null) {
		var originalText = e.getAttribute("original");
		if (originalText != null) {
			e.innerHTML = originalText;
		} else {
			e.innerHTML = '';
		}
	}
	window.status = '';

	return true;
}

function soopaSwapDown() {
	this.src  = this.d.src;
	this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
	soopaSwapUp.img = this;
	document.onmouseup = soopaSwapUp;
}

function soopaSwapUp() {
	var ths = soopaSwapUp.img;
	ths.src = ths.n.src;
	if (ths.temp) document.onmouseup = ths.temp;
}




function getDiv_dom(name) {
    return document.getElementById(name);
}
function getDiv_ie4(name) {
    return document.all[subdiv];
}
function getDiv_ns4(name,nest) {
    return nest?document[nest].document[name] : document[name];
}

function getMouseEvent_ie() {
    var me = new Object();
    me.x = window.event.clientX;
    me.y = window.event.clientY;
    me.documentX = window.event.clientX + document.body.scrollLeft;
    me.documentY = window.event.clientY + document.body.scrollTop;
    return me;
}

function getMouseEvent_ns(e) {
    e.x = e.pageX;
    e.y = e.pageY;
    e.documentX = e.x;// + window.pageXOffset;
    e.documentY = e.y;// + window.pageYOffset;
    return e;
}

function Browser() {
	this.ver=navigator.appVersion

	this.description = "(" + navigator.appVersion +")";
	this.dom=document.getElementById?1:0
	
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    if (this.ns5) this.description += " NS5";
    this.ie4=(document.all && !this.dom)?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	this.width=screen.width;
    if (this.ns4) {
        this.getDiv = getDiv_ns4;
        this.description = " NS4";
    }
    if (this.ver.indexOf("MSIE") > -1)
        this.getMouseEvent = getMouseEvent_ie;
    else
        this.getMouseEvent = getMouseEvent_ns;
        
    if (this.ie4) {
       this.getDiv = getDiv_ie4; 
       this.description += " IE4"
    }
	if (this.dom) {
        this.getDiv = getDiv_dom;	
        this.description += " Supports DOM";
	}

	return this;
}
function togglePopupDiv(e,subdiv)
{
    var bw = new Browser();
    var obj = bw.getMouseEvent(e);

    var div = bw.getDiv('hd_' + subdiv);
    
	var sty = div.style;
	if (sty.visibility == 'hidden')
	    sty.visibility = 'visible';
	else
	    sty.visibility = 'hidden'; 
}
function toggleDiv(e,subdiv,show)
{
    var bw = new Browser();
    var obj = bw.getMouseEvent(e);



    var div = bw.getDiv('hd_' + subdiv);
    if (div == null) return;   




	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}

	if (div.innerWidth)
	{
		divWidth = div.innerWidth;
		divHeight = div.innerHeight;
	}
	else if (div.clientWidth)
	{
		divWidth = div.clientWidth;
		divHeight = div.clientHeight;
	} else {
		divWidth = 200;
		divHeight = 100;
		} 




	var sty = div.style;
	//alert("divHeight=" + divHeight + ", client width = "  + divWidth + ", x = " + obj.x + ", framewidth = " + frameWidth);

	var offset = 5;
	sty.left = (obj.documentX + offset + divWidth + 20) > frameWidth ?  obj.documentX - divWidth - offset : obj.documentX + offset ;
	sty.top = obj.documentY - divHeight - offset - 20 < 0 ? obj.documentY + offset : obj.documentY - divHeight - offset;
	
	if (show == null) {
		if (sty.visibility == 'hidden')
		    sty.visibility = 'visible';
		else
	    	sty.visibility = 'hidden'; 
	} else {
		if (show)
			sty.visibility = 'visible';
		else
			sty.visibility = 'hidden';
	}

	    
	var iframe = bw.getDiv('if_' + subdiv);
	if (iframe) {
		var sty = iframe.style;
		
		sty.left = div.style.left;
		sty.top = div.style.top;
		sty.width = 200;
		sty.height = divHeight + 2;
		if (sty.visibility == 'hidden')
		    sty.visibility = 'visible';
		else
		    sty.visibility = 'hidden'; 
	}
	
}


function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480,left = 465,top = 262');");
}

