function showLoader()
{
	if(document.getElementById("result").className != "loaderOn")
	{
		var resultTable = document.getElementById("result");
		
		var resultTableLeft = resultTable.offsetLeft;
		var resultTableTop  = resultTable.offsetTop;
		//var resultTableWidth  = resultTable.width;
		//var resultTableCenter = resultTableWidth/2;
		//alert(resultTableLeft);
		
		//alert(document.getElementById("loaderContainer").style.top + " " + resultTableTop);
		
		document.getElementById("loaderContainer").style.top = (resultTableTop + 70) + "px";
		document.getElementById("loaderContainer").style.left = "380px"; //(resultTableLeft + 170) + "px";
		
		//alert(document.getElementById("loaderContainer").style.top);
		
		document.getElementById("loaderContainer").style.display = "block";
		document.getElementById("result").className = "loaderOn";
	}	
	return false;
}

function hideLoader()
{
	document.getElementById("result").className = "result";
	document.getElementById("loaderContainer").style.display = "none";
	return false;
}

/*
function toggleLoader()
{
	//alert(document.getElementById("resultTable").className);

	if(document.getElementById("result").className == "result")
	{
		var resultTable = document.getElementById("result");
		
		var resultTableLeft = resultTable.offsetLeft;
		var resultTableTop  = resultTable.offsetTop;
		//var resultTableWidth  = resultTable.width;
		//var resultTableCenter = resultTableWidth/2;
        //alert(resultTableLeft);
		
		//alert(document.getElementById("loaderContainer").style.top + " " + resultTableTop);
		
		document.getElementById("loaderContainer").style.top = (resultTableTop + 50) + "px";
		document.getElementById("loaderContainer").style.left = "330px"; //(resultTableLeft + 170) + "px";
		
		//alert(document.getElementById("loaderContainer").style.top);
		
		document.getElementById("loaderContainer").style.display = "block";
		document.getElementById("result").className = "loaderOn";
	}
	else
	{
	  document.getElementById("result").className = "result";
	  document.getElementById("loaderContainer").style.display = "none";
	}
	
	return false;
}
*/

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function showlayer(layer){
  var myLayer = document.getElementById(layer).style.display;
	if(myLayer=="none"){
		document.getElementById(layer).style.display="";
	} else {
		document.getElementById(layer).style.display="none";
	}
}
function showlayers(basename, nrOf)
{
	for (var i=1; i<=nrOf; i++) {
		showlayer(basename + i);
	}
}


function showRows(basename, nrOf)
{
	for (var i=1; i<=nrOf; i++) {
		showRow(basename + i);
	}
}

function showRow(rowId){
  var row = document.getElementById(rowId);
  if (row.style.display == '') 
    row.style.display = 'none';
  else 
  row.style.display = '';
}

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;  	
} // Ends the "getSelectedCheckBoxValue" function  	
