<!--
 /*
 (C) Copyright 2000 - 2003 Nabh Information Systems, Inc.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
var MMM_d_yyyy_format = 0;
var d_MMM_yyyy_format = 1;
var yyyy_MMM_d_format = 2;

var newWindow;  
function openWindow(url,name,w,h) {
  newWindow= window.open(url, name, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  newWindow.focus();
}

function openSingleWindow(url,name,w,h) {
  if (newWindow != null) newWindow.close();
  newWindow = window.open(url, name, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  newWindow.focus();
  //setTimeout('self.close()', 10000);
}

/*
function openContentWindow(content,name,css,cssclass,cssStyle,w,h) {
  if (newWindow != null) newWindow.close();
  newWindow = window.open('', name, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  newWindow.document.write('<html><head><title>');
  newWindow.document.write(name + '</title>');
  newWindow.document.write('<link href="' + css + '" type="text/css" rel="stylesheet" />');
  newWindow.document.write('</head><body><div class="' + cssclass + '" style="' + cssStyle + '">' + content + '</div></body></html>');
  newWindow.document.close();  
  newWindow.focus();
  //return;
}
*/

function openContentWindow(content,name,cssStyle,w,h) {
  if (newWindow != null) newWindow.close();
  newWindow = window.open('', name, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  newWindow.document.write('<html><head><title>');
  newWindow.document.write(name + '</title>');
  newWindow.document.write('</head><body><div style="' + cssStyle + '">' + content);
  newWindow.document.write('<p/><center><a href="javascript:window.close()">Close window</a></center></div></body></html>');
  newWindow.document.close();  
  newWindow.focus();
  //return;
}

function openOnParentWindow(url) {
	if (window.opener && !window.opener.closed) {
		window.opener.location.href= url;
		window.opener.focus();
		//self.close();
		//return false;
	} else {
		window.location.href=url;
		return false;
	
	}
}

function setFocusOnLoginField() {
    if (document.loginForm != null) {
    	document.loginForm.j_username.focus();
    } else if (document.registerForm != null) {
    	if (document.registerForm.username != null)
    	    document.registerForm.username.focus();
	else if (document.registerForm.oemail != null)
	    document.registerForm.oemail.focus();
    }
}

function showToolTips(obj) {
    if (document.layers && document.layers[obj] != null) {
        //netscape 4.x || Mozilla < 1.5
        document.layers[obj].visibility = 'visible';
    }else if (document.all) {
        //IE4+
        document.all[obj].style.visibility = 'visible';
    }else {
        //Netscape 6+ || Mozilla 1.5+
        document.getElementById(obj).style.visibility ='visible';
    
    }
}

function hideToolTips(obj) {
    if(document.layers && document.layers[obj] != null) {
        //netscape 4.x || Mozilla < 1.5
        document.layers[obj].visibility = 'hide';
    } else if (document.all) {
        //IE4+
        document.all[obj].style.visibility = 'hidden';
    } else {
        //Netscape 6+ || Mozilla 1.5+
        document.getElementById(obj).style.visibility ='hidden';
    }
}

function verifyCheckboxes(fields) {
    //check if the fields is an array (more than 1 check box)
    if (fields.length == undefined) {
        if (fields.checked == true) 
            return true;
        return false;
    } else {
        for (i=0; i < fields.length; i++) 
            if (fields[i].checked == true)
                return true;
        return false;
    }
}

function SwitchTab(obj, thePath, cls, subTabIndexes, parentIndexes, childIndex)
{
	var open = 'url("'+thePath + 'images/collapse_tab.gif")';
	var close = 'url("'+thePath + 'images/expand_tab.gif")';
	  if(document.getElementById)  {
		var el = document.getElementById(obj);
		var title = document.getElementById(obj+'Title');

		for (var i =0; i < subTabIndexes.length; i++) {
			var selTab = document.getElementById('tab_selected_'+subTabIndexes[i]);
			var unselTab = document.getElementById('tab_'+subTabIndexes[i]);
			var selTabTitle = document.getElementById('tab_selected_'+subTabIndexes[i]+'Title');
			var unselTabTitle = document.getElementById('tab_'+subTabIndexes[i]+'Title');

			var isSelected = false;
			for ( var j=0; j < parentIndexes.length; j++) {
				if (parentIndexes[j] == subTabIndexes[i] || childIndex == subTabIndexes[i]) {
					isSelected = true;
					break;
				}

			}

			if (isSelected) continue;

			if(selTab != null) {
				if (selTab.style.display == "block") {
					selTabTitle.style.backgroundImage = close;
					selTab.style.display = "none";
				}
			} else if (unselTab != null) {
				if (unselTab.style.display == "block") {
					unselTabTitle.style.backgroundImage = close;
					unselTab.style.display = "none";
				}
			}
		}

		if(el.style.display != "block"){ 
		  title.style.backgroundImage = open;
		  el.style.display = "block";
		}else{
		  title.style.backgroundImage = close;
		  el.style.display = "none";
		}

		//if (cls == "SelectedTabTitle")
		//	title.className = "UnselectedTabTitle";
		//else
		//	title.className = "SelectedTabTitle";

		//return true;
  }
}

// Calculate four digit year.
function fourdigits(number) {
  return (number < 1000) ? number + 1900 : number;
}

function getDateFormat(theformat) {
    switch (theformat) {
        case "yyyy_MMM_d":
            return yyyy_MMM_d_format;
        case "d_MMM_yyyy":
            return d_MMM_yyyy_format;
        default:        
            return MMM_d_yyyy_format;
    
    }

}

function MM_findObj(n, d) { //v3.0
  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); return x;
}
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_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];}}
}

//-->
