//**************************************************************************************
// Common client Javascript used by ENDIVA
//
// Copyright (c) 2000 ENDIVA Software, Inc. All rights reserved.
//**************************************************************************************

var hdwin=0;
function close_popup()
{
	if (hdwin)	hdwin.close();
}

function popup(url,param)
{
var sparam;
	if (param=="")
		sparam="toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,top=0,left=200";
	else
		sparam=param;
	close_popup();
	hdwin=open(url,"",sparam);	  
	if (hdwin) hdwin.focus();  

}

function confirm_delete(url, msg)
{
	if (confirm(msg)==false)
		; //do nothing
	else { document.location.href=url; }
}

function confirm_delete2(form, msg)
{
    if (confirm(msg)==false)
        ; //do nothing
    else
    {
        form.hdnDelete.value='delete';
        form.submit();
    }
}

function isEmpty(str)
{
	var spcnt = 0;
	for (count=0;count<str.length;count++) 
	{ tmp = str.substring(count,count+1);
	  if (tmp==" ") spcnt = spcnt+1;
	}
	if (spcnt==str.length) 	return (1);  // true
	else return (0);
}

function isNumeric(str, allowDecimal) {
var bFoundDecimal=false;
 for (var i = 0; i < str.length; i++) {
  var oneChar = str.charAt(i);
  if (oneChar < "0" || oneChar > "9") {
     if (allowDecimal && oneChar=="." && i<str.length-1 && !bFoundDecimal) {
         bFoundDecimal = true;
     }
     else {
         return (false);
     }
  }
 }
 return (true);
}

function leftTrim(str) {
	while (str.substring(0,1) == " "){
		str = str.substring(1, str.length);
	}
	return str;
}

function rightTrim(str) {
	while (str.substring(str.length-1, str.length) == " "){
		str = str.substring(0,str.length-1);
	}
	return str;
}

function trim(str) {
	var tmp = leftTrim(str);
	return rightTrim(tmp);	
}



function check_selection (form, element, msg)
{ if (element.value=='') alert (msg); else form.submit(); }

function isIEBrowser() 
{
  var agent = navigator.userAgent.toLowerCase();
  if (agent.indexOf("msie") != -1) return (1);
  else return (0);
}


var catID=0; var pcatID=0; ctxID=0;

function HiRow(a,b) 
{ 
  if (isIEBrowser()==true) { var obj= eval('document.all.tr'+a); } 
  else { var obj=document.getElementById('tr'+a); }
  var bFound=false;
  for(i = 0; i < document.styleSheets[0].rules.length; i++)
    if(document.styleSheets[0].rules.item(i).selectorText=='.'+b)
      { 
	obj.style.fontFamily=document.styleSheets[0].rules.item(i).style.fontFamily;
	obj.style.fontStyle=document.styleSheets[0].rules.item(i).style.fontStyle;
	obj.style.fontSize=document.styleSheets[0].rules.item(i).style.fontSize;
	obj.style.fontWeight=document.styleSheets[0].rules.item(i).style.fontWeight;
	obj.style.color=document.styleSheets[0].rules.item(i).style.color;
	obj.style.backgroundColor=document.styleSheets[0].rules.item(i).style.backgroundColor; 
	obj.style.textDecoration=document.styleSheets[0].rules.item(i).style.textDecoration;
        bFound=true;
       break;}
  if (bFound==false) obj.style.backgroundColor='lightcyan';
 } 

function DimRow(a) 
{ 
  if (isIEBrowser()==true) { var obj= eval('document.all.tr'+a); } 
  else { var obj=document.getElementById('tr'+a); }
	obj.style.fontFamily='';
	obj.style.fontStyle='';
	obj.style.fontSize='';
	obj.style.fontWeight='';
	obj.style.color='';
	obj.style.backgroundColor=''; 
	obj.style.textDecoration='';
} 


function Display(a) 
{  
  if (isIEBrowser()==true) { var obj= eval('document.all.el'+a);} 
  else { var obj=document.getElementById('el'+a); }
  if (obj.style.display =="")  obj.style.display = "none"; 
  else obj.style.display="";
}

function ColExp(a, b, c, d, p) 
{ 
  if (isIEBrowser()==true) { var obj= eval('document.all.el'+a); var ind= eval('document.all.ind'+a); } 
  else { var obj=document.getElementById('el'+a); var ind=document.getElementById('ind'+a); }
  if (obj.style.display =="") { obj.style.display = "none"; ind.src=p+"/controls/pulldn-"+b+".gif"; ind.alt=c; }
  else { obj.style.display=""; ind.src=p+"/controls/pullup-"+b+".gif"; ind.alt=d;}
   return obj.style.display;
}

function Collapse(a, b, c, p) 
{ 
  if (isIEBrowser()==true) { var obj= eval('document.all.el'+a); var ind= eval('document.all.ind'+a); } 
  else { var obj=document.getElementById('el'+a); var ind=document.getElementById('ind'+a); }  
  obj.style.display = "none"; ind.src=p+"/controls/pulldn-"+b+".gif"; ind.alt=c;
}
function Expand(a, b, c, p) 
{ 
  if (isIEBrowser()==true) { var obj= eval('document.all.el'+a); var ind= eval('document.all.ind'+a); } 
  else { var obj=document.getElementById('el'+a); var ind=document.getElementById('ind'+a); }
  obj.style.display=""; ind.src=p+"/controls/pullup-"+b+".gif";  ind.alt=c;
}

function setMnuBorderColor(a,b) { 
  if (isIEBrowser()==true) { var mnub= eval('document.all.mnub'+a); } 
  else { var mnub=document.getElementById('el'+a); }
  for(i = 0; i < document.styleSheets[0].rules.length; i++)
    if(document.styleSheets[0].rules.item(i).selectorText=='.'+b)
      { mnub.style.borderColor=document.styleSheets[0].rules.item(i).style.backgroundColor; break;}
} 

// *** begin disable contextmenu
IE4plus = (document.all) ? true : false;
NS4 = (document.layers) ? true : false;

function clickIE()
{
    if (IE4plus) document.selection.empty();
    return false;
}
function clickNS(e)
{ 
    if ((e.which==1) && NS4) return (e.target!=document);
    else if (e.which==1 || e.which==2 || e.which==3 ) return false; 
}
// *** end disable contextmenu


// *** start status bar ticker
function StatusBar_Update()
{
    if (this.loc < this.width)  
        window.status = this.spaces.substring(0,this.width-this.loc)+this.text.substring(0,this.loc);
    else
    {
        var len = (this.loc-this.width > this.text.length) ? (this.loc-this.width - this.text.length) : this.width;
        window.status = this.text.substr(this.loc-this.width,len);
    }
    this.loc++;
    if (this.loc > this.text.length+this.width) this.loc = 0;
}
function StatusBar_Start()
{
    for (var i=0;i<this.width;i++) this.spaces +=" ";
    setInterval("oStatus.Update()",this.speed);
}
function StatusBar()
{
    this.width = 100;
    this.text = "";
    this.speed = 100;
    
    this.loc = 0;
    this.spaces = "";

    this.Update = StatusBar_Update;
    this.Start = StatusBar_Start;
}
// *** end status bar ticker


/* WW: this function is not used any more
function showSlides(a, b, c){
var bSupportEffect=window.createPopup;
var slide = eval('document.images.slide'+a);
var majorInterval = c*1000;
var minorInterval=(bSupportEffect)? b*1000 : 0;
	if (!document.images) return;
	if (bSupportEffect) slide.filters[0].apply();
	slide.src=bufferArray[currentSlide].src;
	if (bSupportEffect) slide.filters[0].play();
	currentUrl=currentSlide;
	currentSlide=(currentSlide < slideArray.length-1)? currentSlide+1 : 0;
	setTimeout("showSlides('"+a+"',"+b+","+c+")",majorInterval+minorInterval);
}
*/



