//*********************************************************************
// DC_ROI.js ==> DC_ROI.asp Jacoub Sbaiti November 2001.

  
  function check_T5() {
   for (var i = 0; i < document.forms[0].T5.value.length; i++)
	{      

	 	 var ch = document.forms[0].T5.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.' ){         
		 	 //alert("\nThe Fifth field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");                                  
			 //document.forms[0].T5.select();         
			 //document.forms[0].T5.focus();                                  
			 return false;                                		 
		 }	
          document.forms[0].T6.value = parseInt(document.forms[0].T5.value) / document.forms[0].T4.value;	   
	           //document.forms[0].T7.select();         
		   document.forms[0].T7.focus();            
    }
  }

  function check_data() {
    //*****************************************************************************************
    // Checks the Decimal field. Return false if characters are not '0-9' or '.' .    

        var v_field ;  

    document.forms[0].T6.value = parseInt(document.forms[0].T5.value) / document.forms[0].T4.value;	   
	
  	for (var i = 0; i < document.forms[0].T1.value.length; i++)
	{      
	 	 var ch = document.forms[0].T1.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe First field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T1.select();         
			 document.forms[0].T1.focus();         
			 return false;   
		 }         	  	
	}      
        
	for (var i = 0; i < document.forms[0].T2.value.length; i++)
	{      
	 	 var ch = document.forms[0].T2.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe Second field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T2.select();         
			 //document.forms[0].T2.focus();         
			 return false;         
		 }	
       
	}
	
	for (var i = 0; i < document.forms[0].T3.value.length; i++)
	{      
	 	 var ch = document.forms[0].T3.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe Third field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T3.select();         
			 //document.forms[0].T3.focus();         
			 return false;         
		 }	
	}

	for (var i = 0; i < document.forms[0].T4.value.length; i++)
	{      
	 	 var ch = document.forms[0].T4.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe Fourth field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T4.select();         
			 //document.forms[0].T4.focus();         
			 return false;         
		 }	
	}
               
    
	for (var i = 0; i < document.forms[0].T7.value.length; i++)
	{      
	 	 var ch = document.forms[0].T7.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe 7th field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T7.select();         
			 //document.forms[0].T7.focus();         
			 return false;         
		 }	
	}
	
	for (var i = 0; i < document.forms[0].T8.value.length; i++)
	{      
	 	 var ch = document.forms[0].T8.value.substring(i, i + 1);   
		 if ((ch < "0" || "9" < ch) && ch != '.'){         
		 	 alert("\nThe 8th field accepts only numbers & a decimal point. \n\nPlease re-enter a number.");         
			 document.forms[0].T8.select();         
			 //document.forms[0].T8.focus();         
			 return false;         
		 }
     }
	     
		 
   // for (var i = 0; i < document.forms[0].T9.value.length; i++)		 
	//{	
         v_row1 = document.forms[0].T1.value;
         v_row2 = document.forms[0].T2.value;
         v_row8 = document.forms[0].T8.value;
          
 	     if (document.forms[0].T1.value == "" || document.forms[0].T1.value == null) {
              v_row1 = 0;
         }
         
         if (document.forms[0].T2.value == "" || document.forms[0].T2.value == null) {
              v_row2 = 0 ;
         }
                  
         if (document.forms[0].T8.value == "" || document.forms[0].T8.value == null) {
              v_row8 = 0 ;
         }
		 
     first_step  = (parseInt(v_row1) + parseInt(document.forms[0].T3.value)) * parseInt(document.forms[0].T7.value)
	 //alert ("first step: " + first_step);

     second_step = parseInt(v_row2) - parseInt(v_row1)
     	  
     //alert ("second_step: " + second_step) ;
	 
     if (second_step > 0) {
         second_step2 = second_step * (parseInt(document.forms[0].T8.value)) 
	    // alert ("second_step2 > 0 : " + second_step2 );
      }
     if (second_step <= 0) {
             second_step2 = 0
	 	     //alert ("second_step2 =0 : " + second_step2 );
      }
                 
     //alert ("first_step: " +first_step + "  second_step2: " + second_step2 )                 
     last_step = first_step + second_step2   //+ third_step         
    document.forms[0].T9.value = last_step
	      
    document.forms[0].T13.value = parseInt(document.forms[0].T5.value * .10) - document.forms[0].T9.value
    document.forms[0].T14.value = parseInt(document.forms[0].T5.value * .23) - document.forms[0].T9.value
    document.forms[0].T15.value = parseInt(document.forms[0].T5.value * .53) - document.forms[0].T9.value
    
    v_row9 =  parseInt(document.forms[0].T9.value);
    v_row13 = parseInt(document.forms[0].T13.value);
    v_row14 = parseInt(document.forms[0].T14.value);
    v_row15 = parseInt(document.forms[0].T15.value);
    
    v_row10 = (v_row13 / v_row9) * 100;
    v_row11 = (v_row14 / v_row9) * 100;
    v_row12 = (v_row15 / v_row9) * 100;

    document.forms[0].T10.value = parseInt(v_row10) + "%";
    document.forms[0].T11.value = parseInt(v_row11) + "%";
    document.forms[0].T12.value = parseInt(v_row12) + "%";
 
    // ROI Ratio Value
    document.forms[0].R1.value = Math.round(parseInt(v_row10) / 100) + " to 1" 
    document.forms[0].R2.value = Math.round(parseInt(v_row11) / 100) + " to 1" 
    document.forms[0].R3.value = Math.round(parseInt(v_row12) / 100) + " to 1" 
    
    document.forms[0].T15.focus();

  //	 }
   
 
	   	   
return true; 	    
}
//*****************************************************************************************