function settxtvis() {
	var thisLevel = document.getElementById( 'st' );
	if (thisLevel.style.display == 'none') {
		thisLevel.style.display = "";
	}
	else {
		thisLevel.style.display="none";	
	}
}
function setdetvis() {
	var thisLevel = document.getElementById( 'sd' );
	if (thisLevel.style.display == 'none') {
		thisLevel.style.display = "";
	}
	else {
		thisLevel.style.display="none";	
	}
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = document.myform.checkall.checked;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = document.myform.checkall.checked;
}

function setwindowsize(w,h) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE - Firefox comes through here
	self.resizeTo(w,h);
    //window.innerWidth=w;
    //window.innerHeight=h;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
	self.resizeTo(w,h);
	
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
	self.resizeTo(w,h);
  }
}

function isnumber(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   return IsNumber; 
}

function roundit(x) {
	if (x > 0) {
	}
	else {
		x = 0;
	}
	var rlength = 2; // The number of decimal places to round to
	var newnumber = Math.round(x*Math.pow(10,rlength))/Math.pow(10,rlength);
	return newnumber;
}

function isLetter (c) {
	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}
function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}
function isnumeric (s) {
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (! (isDigit(c) ))
        return false;
    }
    return true;
}
function isAlphanumeric (s) {
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (! (isLetter(c) || isDigit(c) || isSpecial(c)) )
        return false;
    }
    return true;
}

function round_decimals(original_number, decimals, blank) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals, blank)
}
function pad_with_zeros(rounded_value, decimal_places, blank) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }

	if (value_string == '0.00' && blank == 'y') {
		value_string=''
	}
	if (value_string == '0' && blank == 'y') {
		value_string=''
	}
	
	return value_string
}


function setpagedimentions() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  myform.page_width.value=myWidth;
  myform.page_height.value=myHeight;  
}


