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('<a href="javascript:NewCal(\'' + formAndField + '\',\'mm\\dd\\yyyy\',false,24)"><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;"/></a>');
	}
}

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 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.isIE=(this.ver.indexOf("MSIE")>-1 && this.dom)?true:false;
	this.isSafari=(this.ver.indexOf("Safari")>-1 && this.dom)?true:false;
	
	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');");
}

function changeTitleInfo(new_header) {
	if (dojo) {
		dojo.addOnLoad (
			function() {
				document.getElementById('sectionTitle').innerHTML = new_header;	
				document.title = document.title.substring(0, document.title.lastIndexOf('/')) + "/ " + new_header;
			}
		);
	}
	else {
		document.getElementById('sectionTitle').innerHTML = new_header;	
		document.title = document.title.substring(0, document.title.lastIndexOf('/')) + "/ " + new_header;
	}
}

if (dojo) {
	dojo.addOnLoad (
	function(){
		var leftcol = document.getElementById('left_column');
		if(leftcol != null){
			if(leftcol.clientHeight < 60){leftcol.style.visibility = "hidden";}
		}
		var adminMenu = document.getElementById('siteAdminMenu');
		if(adminMenu != null){
		    var bwsr = new Browser();
		    if(bwsr.isIE)
				document.body.style.backgroundPosition = "0px 60px";
		    else if(bwsr.isSafari)
				document.body.style.backgroundPosition = "0px 63px";
		    else
				document.body.style.backgroundPosition = "0px 69px";
		}
	});
}

/* Deprecated */

function HelpWindow(title, message, height, width) {
}
function registerDirtyEvents() {
}
function setDirty(e) {
}

function submitPage() {
}
function showActivity(frm) {
}
function hideActivity(frm) {
}
function soopaSetup() {
}
function soopaASwapOn() {
}
function soopaASwapOff() {
}
function soopaSwapOn() {
	return true;
}
function soopaSwapOff() {
	return true;
}
function soopaSwapDown() {
}
function soopaSwapUp() {
}