/********************************************************************************
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts. This may be used freely as long as this msg is intact!
I will also appriciate any links you could give me.
********************************************************************************/
//Default browsercheck, added to all scripts!
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()

//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	if(obj.visibility=='visible' || obj.visibility=='show') obj.visibility='hidden'
	else obj.visibility='visible'
}

//Shows the div
function show(div,nest,div2,nest2){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='visible'
	obj=bw.dom?document.getElementById(div2).style:bw.ie4?document.all[div2].style:bw.ns4?nest2?document[nest2].document[div2]:document[div2]:0;
	obj.visibility='hidden'
}

//Hides the div
function hide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='hidden'
}

<!-- Comment out script for old browsers
function propertysheet(thingid,masterthingid,cornerid,siteid,settingssetid,settingssiteid) { popupWin = window.open("https://triton.infosys.tamus.edu/pls/portal/PORTAL.wwv_thinghtml.showpropertysheet?p_thingid="+thingid+"&p_masterthingid="+masterthingid+"&p_cornerid="+cornerid+"&p_siteid="+siteid+"&p_settingssetid="+settingssetid+"&p_settingssiteid="+settingssiteid,"Property_Sheet","statusbar=Y,resizable,scrollbars,width=450,height=450"); popupWin.focus(); } //-->

<!-- Comment out script for old browsers
function folderpropertysheet(cornerid,siteid,settingssetid,settingssiteid) { popupWin = window.open("https://triton.infosys.tamus.edu/pls/portal/PORTAL.wwpob_page.propertysheet?p_cornerid="+cornerid+"&p_siteid="+siteid+"&p_settingssetid="+settingssetid+"&p_settingssiteid="+settingssiteid,"Property_Sheet","statusbar=Y,resizable,scrollbars,width=450,height=450"); popupWin.focus(); } //-->

function show_task_help() {
   newWindow = window.open("https://triton.infosys.tamus.edu/portalHelp/ohw/?locale=en", "Help", "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=700,height=500");
}

//mainsrvc----------------------------------------------------------------------
function mainsrvc(checkme,from) {
// return radio array value for main service
   if (from > -1) return from;
}

function floorme(amount) {
// returns the amount in the .99 format
    amount -= 0;
    if (isNaN(amount)) return 0;
    else {
       amount = (Math.round(amount*100))/100;
       return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
    }
}

function floorme2(what) {  if (what.length == 0) return 0;
  var number1 = what;
  var number2 = parseInt(number1).toString();
  if (number1.length == number2.length && number2 != "NaN")  return number1;
  else {
    if (number1.indexOf('.') > -1) {
       number1 = number1.substring(number1.indexOf('.'),-number1.indexOf('.'));
       number2 = parseInt(number1).toString();
       if (number1.length == number2.length && number2 != "NaN")  return number1;
       else  return 0;
    }
    else  return 0;
  }
}

//fulljs------------------------------------------------------------------------

function checkm(whatnow,wherenow) {
// checking Required Selections
   var what;
   var where;

   if (whatnow.substring(0,1) == "m")  {
      what = whatnow;
      document.regoptions.holdmainid.value = what.substring(1);
   } else {
      what = "m" + whatnow;
      document.regoptions.holdmainid.value = what;
   }
   where = mainsrvc(what,wherenow);

//checkm_initialize-------------------------------------------------------------

//checkm_process----------------------------------------------------------------

   calcAll();
}
//checki_main-------------------------------------------------------------------

//checki_optn-------------------------------------------------------------------


function check101027(what) {
// optional service with single only
 if (what == "qty101027") {
    if (floorme2(document.regoptions.qty101027.value) == 1)     document.regoptions.opt101027.checked = true;
    else                                                       document.regoptions.opt101027.checked = false;
 } else if (what == "opt101027") {
    if (document.regoptions.opt101027.checked == false)   document.regoptions.qty101027.value = 0;
    else if (floorme2(document.regoptions.qty101027.value) < 1) document.regoptions.qty101027.value = 1;
 }
 if (floorme2(document.regoptions.qty101027.value) > 1) document.regoptions.qty101027.value = 1;
 //Disable other radio box if this one is checked
 
 calcAll();
}

function check101028(what) {
// optional service with single only
 if (what == "qty101028") {
    if (floorme2(document.regoptions.qty101028.value) == 1)     document.regoptions.opt101028.checked = true;
    else                                                       document.regoptions.opt101028.checked = false;
 } else if (what == "opt101028") {
    if (document.regoptions.opt101028.checked == false)   document.regoptions.qty101028.value = 0;
    else if (floorme2(document.regoptions.qty101028.value) < 1) document.regoptions.qty101028.value = 1;
 }
 if (floorme2(document.regoptions.qty101028.value) > 1) document.regoptions.qty101028.value = 1;
 //Disable other radio box if this one is checked
 
 calcAll();
}

//checkall----------------------------------------------------------------------

function checkAll() {
// force check/recalculation of all selections then grand total
   checkm(document.regoptions.holdmainid.value);

   check101027("opt101027");
   check101028("opt101028");
   calcAll();
}

//allqtytot---------------------------------------------------------------------

function allqtytot() {

   document.regoptions.qty101027.value  =  Math.abs(floorme2(document.regoptions.qty101027.value));
   document.regoptions.tot101027.value  = floorme(floorme2(document.regoptions.qty101027.value)  * floorme(document.regoptions.rte101027.value));
   document.regoptions.qty101028.value  =  Math.abs(floorme2(document.regoptions.qty101028.value));
   document.regoptions.tot101028.value  = floorme(floorme2(document.regoptions.qty101028.value)  * floorme(document.regoptions.rte101028.value));
}

//calcall-----------------------------------------------------------------------

function calcAll() {
// make sure quantities are positive, calculate totals and grand total
   allqtytot();
   document.regoptions.ttotal.value =   floorme(
                ((document.regoptions.qty101027.value-0)  * (document.regoptions.rte101027.value-0)) + 
				((document.regoptions.qty101028.value-0)  * (document.regoptions.rte101028.value-0))
             );

}
//submitme----------------------------------------------------------------------


function checkSubmit() {
   checkAll();
   document.regoptions.rno.value='X';
   document.regoptions.submit();
}