function getDefaultFeatures()
{
	return "";
}

function getDialogBoxFeatures(width, height, resize)
{

  if(window.innerWidth)
    w = window.innerWidth;
  else
    w = 750;
    
  if(window.innerHeight)
	  h = window.innerHeight;
  else
  	h = 550;
    
  if (window.screenLeft)
    x = window.screenLeft;
  else if (window.screenX)
    x = window.screenX;
  else
    x = 0;
    
  if (window.screenTop)
    y = window.screenTop;
  else if (window.screenY)
    y = window.screenY;
  else
    y = 0;
  
  posx = Math.max(0, x + (w - width)/2);
  posy = Math.max(0, y + (h - height)/2);
  //posy = y;
  
  
  features = "left=" + posx + ",top=" + posy + ",screenX=" + posx + ",screenY=" + posy + ",";
	features = features + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height="+ height;
	
	if(resize) {
		features = features + ",resizable=yes";
	} else {
		features = features + ",resizable=no";
	}
	
	return features;
}


function popupWindow(url, name, features, returnNothing)
{
  popupWin = window.open(url, name, features);
  popupWin.opener.top.name = "opener";

  if (popupWin.focus) popupWin.focus();

  if(!returnNothing) {
    return popupWin;
  }
}

var gl_activeDialogBox = null;
function openDialogBox(url, w, h)
{
	if (gl_activeDialogBox != null) closeDialogBox(false);
	
	gl_activeDialogBox = popupWindow(url, "dialogBox", getDialogBoxFeatures(w, h));
}

function closeDialogBox(do_reload)
{
	gl_activeDialogBox.close();
	gl_activeDialogBox = null;
	if (do_reload) location.reload();
}

function closeDialogBoxwithURL(do_reload, url)
{
	gl_activeDialogBox.close();
	gl_activeDialogBox = null;
	if (do_reload){
	   if (url.length > 0 ){
	   		window.location = url;
	   }
	   else{ 
		location.reload();
	   }	
	}   
}


function onUnloadEvent()
{
	if (gl_activeDialogBox != null) closeDialogBox(false);
}

function onLoadEvent()
{
	//if(document.getElementById)
	//	document.getElementById("cm-toolbar").style.visibility="hidden";
}

   function setCookie (name, value, expires) {
   
      if (!expires) expires = new Date();
	  document.cookie = name + "=" + escape (value) +    
      "; expires=" + expires.toGMTString() +  "; path=/";
   	  return;
    }                                                      

	function setTimedCookie(name,value) {

	  var expdate = new Date ();
	  expdate.setTime (expdate.getTime() + (1000 * 60 * 60 * 24 * 1));
	  setCookie (name, value, expdate);
	  return;
	}	  
  
    function getCookie (name) {
    var dcookie = document.cookie; 
    var cname = name + "=";
    var clen = dcookie.length;
    var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
            if (dcookie.substring(cbegin, vbegin) == cname) { 
            var vend = dcookie.indexOf (";", vbegin);
                if (vend == -1) vend = clen;
            return unescape(dcookie.substring(vbegin, vend));
            }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
            if (cbegin == 0) break;
        }
    return null;
   }
 
 function hideTopTen(ElementStyle, Heading, rightArrow) {
 	
 	ElementStyle.visibility = 'hidden';
    ElementStyle.display = 'none';
    Heading.innerHTML = '<img src="' + rightArrow + '" alt="+" border="0">';
	setTimedCookie("TopTenStat","0");
	return;
 }
 
 function showTopTen(ElementStyle, Heading, downArrow) {
 	
 	ElementStyle.visibility = 'visible';
    ElementStyle.display = 'block';
    Heading.innerHTML = '<img src="' + downArrow + '" alt="-" border="0">';
	setTimedCookie("TopTenStat","1");
	return;
 }
 
 function initTopTen(rightArrow, downArrow) {
    Heading = document.getElementById('favoriteexpand');
    ElementStyle = document.getElementById('favoritelist').style;
		
	var visible = getCookie("TopTenStat");
	
	
	
	if (visible == "1")
		showTopTen(ElementStyle, Heading, downArrow);
	else
		hideTopTen(ElementStyle, Heading, rightArrow);
	return;
 }  
 
 function alterTopTen(rightArrow, downArrow) {
     
     Heading = document.getElementById('favoriteexpand');
     ElementStyle = document.getElementById('favoritelist').style;
	
	if(ElementStyle.visibility == 'visible') {
           hideTopTen(ElementStyle, Heading, rightArrow);
     } else {
           showTopTen(ElementStyle, Heading, downArrow);
     }
 	return;
 }

 function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
 } 

 function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
 } // Ends the "getSelectedRadio" function
  	
 function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function toggleTable(headingid, tableid, collapsedsrc, expandedsrc) {
	Heading = document.getElementById(headingid);
	ElementStyle = document.getElementById(tableid).style;

	// alert(Heading.innerHTML);

	if(ElementStyle.visibility == 'visible') {
		ElementStyle.visibility = 'hidden';
		ElementStyle.display = 'none';
		
		if(collapsedsrc) {
			Heading.innerHTML = '<img src="' + collapsedsrc + '" alt="+" border="0">';
		} else {
			Heading.innerHTML = '+';
		}
	} else {
		ElementStyle.visibility = 'visible';
		ElementStyle.display = 'block';
		
		if(expandedsrc) {
			Heading.innerHTML = '<img src="' + expandedsrc + '" alt="-" border="0">';
		} else {
			Heading.innerHTML = '-';
		}
   }
}

function setPointer() 
{
	document.body.style.cursor = 'wait'; 
} 

function resetPointer() 
{ 
	document.body.style.cursor = 'default'; 
} 

	function highlightCell(cell) {
	    for(row = 1; row <= 999; row++) {
			if(document.getElementById('row' + row)) {
				document.getElementById('row' + row).style.background = "";
			
			    // single cell code disabled, but I'm keeping it around as a reference
				for(col = 1000; col <= 999; col++) {
					if(document.getElementById('row' + row + 'col' + col)) {
						document.getElementById('row' + row + 'col' + col).style.background = "";
					} else {
						// alert("Stopping at row " + row + ", col " + col);
						break;
					}
				}
			} else {
				// alert("Stopping at row " + row);
				break;
			}
		}
	
		cell.style.background = "#E0E0E0";
	}



