﻿// JScript File
/*
function isNumberKey(evt)
        {
       
        var charCode = (evt.which) ? evt.which : event.keyCode
        
        if( ( charCode>47 &&  charCode<58) || ( charCode>95 &&  charCode<106 ) || charCode==110 || (charCode==46))
           return true; 
         else
           return false; 
        
        }
        */
        
 function isNumberQty(evt)
        {
       
        var charCode = (evt.which) ? evt.which : event.keyCode
        //alert(charCode);   
        if ( (charCode>47 &&  charCode<58)||charCode==8)
           return true; 
         else
         alert("Enter numeric characters only.")
           return false; 
        
        }
        
  function propertychanged(cntrl)
        {
        var val= document.getElementById(cntrl);
        var textval =val.value 
         var temp = new Array();
         
           
          if(textval.indexOf('.')!=-1)
          {
           temp = textval.split('.');
           var tmp1=temp[1];
           if (tmp1.length>=5)
            val.value=textval.substring(0,textval.length-1)
            
            
          }

        
        }
        
        function propertychanged2(cntrl)
        {
       
        var val= document.getElementById(cntrl);
        var textval =val.value 
        var temp = new Array();
         
          
        if(textval.indexOf('.')!=-1)
        {
           temp = textval.split('.');
           var tmp1=temp[1];
           if (tmp1.length>2)
           {
            //val.value=textval.substring(0,textval.length-1)
            return false;
           }
               
        }

        
        }
               
      function propertychangedUNIts(cntrl)
        {
        var val= document.getElementById(cntrl);
        var textval =val.value 
         var temp = new Array();
         
           
          if(textval.indexOf('.')!=-1)
          {
           temp = textval.split('.');
           var tmp1=temp[1];
           if (tmp1.length>=4)
            val.value=textval.substring(0,textval.length-1)
            
            
          }

        
        }
        
        function propertychangedUNIts_FD(cntrl)
        {
        var val= document.getElementById(cntrl);
        var textval =val.value 
         var temp = new Array();
         
           
          if(textval.indexOf('.')!=-1)
          {
           temp = textval.split('.');
           var tmp1=temp[1];
           if (tmp1.length>3)
           { val.value=textval.substring(0,textval.length-1)
           return false;
            }
            
          }

        
        }
          

function isAlpha(evt)
        {
       
        var charCode = (evt.which) ? evt.which : event.keyCode
        //alert(charCode);   
        if (!( charCode>45 &&  charCode<58))
           return true; 
         else
           return false; 
        
        }
        
function Alphabets(evt)
        {
       
        var charCode = (evt.which) ? evt.which : event.keyCode
           
        if(charCode==39)
        return false;
        if (!( charCode>45 &&  charCode<58))
           return true; 
         else
           return false; 
        
        }  


function isValidChar(evt) //Avoid Space Single Quote(') and semicolon(;)
        {
       
        var charCode = (evt.which) ? evt.which : event.keyCode
        //alert(charCode);   
        if (charCode==39 ||charCode==59 || charCode==32  )
           return false; 
        else
        return true;    
        
        }
        
        function IsValidDate(DtFrm , DtTo)
        {
        
        }


// function IsValidDate(Day,Mn,Yr){
//    var DateVal = Mn + "/" + Day + "/" + Yr;
//    var dt = new Date(DateVal);

//    if(dt.getDate()!=Day){
//        alert('Invalid Date');
//        return(false);
//        }
//    else if(dt.getMonth()!=Mn-1){
//    //this is for the purpose JavaScript starts the month from 0
//        alert('Invalid Date');
//        return(false);
//        }
//    else if(dt.getFullYear()!=Yr){
//        alert('Invalid Date');
//        return(false);
//        }
//        
//    return(true);
// }

function calcJulian(isDate){

gregDate = new Date(isDate);
year = gregDate.getFullYear(); 
month = gregDate.getMonth()+1; 
day = gregDate.getDate();
A = Math.floor((7*(year+Math.floor((month+9)/12)))/4);
B = day+Math.floor((275*month)/9)
isJulian = (367*year)-A+B+1721014;
return isJulian; 
}

function validate(date1,date2)
{

//    tmp = date1.split("-")
//    xDate = tmp[0]+"/"+tmp[1]+"/"+tmp[2];
//    refDate = calcJulian(xDate);

//    if(date2!="")
//    {
//        tmp = date2.split("-")
//        xDate = tmp[0]+"/"+tmp[1]+"/"+tmp[2];
//        fwdDate = calcJulian(xDate);
//    }
//    var dt=new Date();
//    curdt= dt.getDate() +"/"+dt.getMonth()+ 1 +"/"+ dt.getFullYear(); 
//    CurDate = calcJulian(curdt);

//    if(refDate>CurDate )
//    {
//         alert('Invalid Date');    
//         return 0
//    }

//    if(date2!="") //If Date2 Exist
//    { 
//        if( fwdDate>CurDate )
//        {
//             alert('Invalid To date');    
//             return 0
//        }
//        if (fwdDate < refDate)
//        {
//             alert('From Date is Less Then To Date');
//             return 0
//        }
//         else
//        {
//              return 1  
//        }
//    }   
//Bellow code add on 3 feb... 
   
    var str1  = date1;
    var str2  = date2;
    //alert(str1+ '**' + str2);
    var dt1   = parseInt(str1.substring(0,2),10); 
    var mon1  = parseInt(str1.substring(3,5),10);
    var yr1   = parseInt(str1.substring(6,10),10); 
    var dt2   = parseInt(str2.substring(0,2),10); 
    var mon2  = parseInt(str2.substring(3,5),10); 
    var yr2   = parseInt(str2.substring(6,10),10); 
    var date1 = new Date(yr1, mon1-1, dt1); 
    var dt = new Date();
    if(date2=='')
       {
        if(dt < date1)
         {
            alert('Invalid date');   
            return false; 
          }
        
       }
    
    var date2 = new Date(yr2, mon2-1, dt2); 
   
  
    if(dt < date2)
    {
        alert('Invalid To date');   
        return false; 
    }
    if(date2 < date1)
    {
      alert("To date cannot be greater than from date");
      return false; 
    } 
  return true;
}

function validateExpiry(date1,date2)
{

   
    var str1  = date1;
    var str2  = date2;
    //alert(str1+ '**' + str2);
    var dt1   = parseInt(str1.substring(0,2),10); 
    var mon1  = parseInt(str1.substring(3,5),10);
    var yr1   = parseInt(str1.substring(6,10),10); 
    var dt2   = parseInt(str2.substring(0,2),10); 
    var mon2  = parseInt(str2.substring(3,5),10); 
    var yr2   = parseInt(str2.substring(6,10),10); 
    var date1 = new Date(yr1, mon1-1, dt1); 
    var dt = new Date();
    if(date2=='')
       {
        if(dt < date1)
         {
           // alert('Invalid date');   
            return false; 
          }
        
       }
    
    var date2 = new Date(yr2, mon2-1, dt2); 
   
  
   
    if(date2 < date1)
    {
      alert("Investment Date cannot be greater than Expiry date");
      return false; 
    } 
  return true;
}

function addCommas(nStr)
    {
       nStr += '';
       x = nStr.split('.');
       x1 = x[0];
       x2 = x.length > 1 ? '.' + x[1] : '';
       var rgx = /(\d+)(\d{3})/;
       while (rgx.test(x1)) {
               x1 = x1.replace(rgx, '$1' + ',' + '$2');
       }
       alert(x1+x2);
       return x1 + x2;
    }
    
    
  function f(o)
  {
   o.value=o.value.toUpperCase().replace(/([^0-9A-Z ])/g,"");
  }
  
  function getMousePosition(e) 
            { 
            
              return e.pageX ? {'x':e.pageX, 'y':e.pageY} : {'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; 
            } 
		

 var previousRow;
      function ChangeRowColor(row,obj)
        {
           var div = document.getElementById(obj);
           var img = document.getElementById('img' + obj);
           
           //If last clicked row and the current clicked row are same
            if (previousRow == row)
                return;//do nothing
            //If there is row clicked earlier
            else if (previousRow != null)
                //change the color of the previous row back to white
                {
                document.getElementById(previousRow).style.fontWeight = "normal";
               //  document.getElementById(row).style.color ="#5C5C5C" ;
                }
            //#5c5c5c
            //change the color of the current row to light yellow
      
            document.getElementById(row).style.fontWeight="bold" ;
            //document.getElementById(row).style.color ="Black" ;
            //assign the current row id to the previous row id 
            //for next row to be clicked
            previousRow = row;
        
        }
        
        
 function roundNumber(rnum, rlength)
  { 

    var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
   return newnumber; 
 }


    <!--
    javascript:window.history.forward(1);
    //-->


function pausecomp(millis) 
{
var date = new Date();
var curDate = null;
millis=0
do { curDate = new Date(); } 
while(curDate-date < millis);
} 



function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{

if(document.layers)        //NN4+
{
document.layers[szDivID].visibility = iState ? "show" : "hide";
}
else if(document.getElementById)          //gecko(NN6) + IE 5+
{
var obj = document.getElementById(szDivID);
obj.style.display = iState ? "block" : "none";
}
else if(document.all)   // IE 4
{
document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
}
}

function HideLoding()
{

  parent.menu.HideLoad();
}

function HideLodingFromAssets()
{

  parent.menu.HideLoadFromAccets();
}

function Loadings(objload)
    {
     objload.style.display=""  ;
     
    }  
    
function MaskMoney(evt,MaxVal) 
    {
      if (!(evt.keyCode == 9|| evt.keyCode == 46||evt.keyCode == 39||evt.keyCode == 37|| evt.keyCode == 190 || evt.keyCode == 8 || evt.keyCode == 46 || (evt.keyCode >=96 && evt.keyCode <= 105) || evt.keyCode==110 || (evt.keyCode >= 48 && evt.keyCode <= 57))) return false;
      var parts = evt.srcElement.value.split('.');
      if (evt.keyCode == 46 || evt.keyCode==8 || evt.keyCode==39|| evt.keyCode==37||evt.keyCode == 9) return true;
      
    if (parts.length > MaxVal) return false;
    if (evt.keyCode == 46) return (parts.length == 1);
    if (parts[0].length >= 14) return false;
    if (parts.length == 2 && parts[1].length >= MaxVal) return false;
    }


function EnbleSave(btn)
{
  btn.src = "image/save.jpg"; 
  btn.disable=false;
}
