﻿
/***********************************************************************************************************
    Developer Notes
    Objective: JavaScript for Industry Reporting
    Code generated by : KISL Technology Center Sdn Bhd.,
***********************************************************************************************************/
/*************************************************************************************************************/
//Generic Functions
/*************************************************************************************************************/

//Name          : getObj
//Objective     : Function to Get Control Type and properties
//Used in       : This function can use in any screen.
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function getObj(name)
{
	if (document.getElementById) // test if browser supports document.getElementById
	{
		if (document.getElementById(name))
		{
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
			this.parent = document.getElementById(name).parentNode;
		}
	}
		else if (document.all) // test if browser supports document.all
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
		this.parent = document.all[name].parentElement;
	} 
		else if (document.layers) // test if browser supports document.layers
	{
		this.obj = document.layers[name];
		this.style = document.layers[name].style;
		this.parent = document.layers[name].parentNode;
	}
}

//Name          : isNumberKey
//Objective     : Function to allow only Numbers and .(decimal)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function isNumberKey(evt)
{
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode == 46)
			return true;
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

//Name          : isNumberComma
//Objective     : Function to allow only Numbers and ,(Comma)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function isNumberComma(evt)
{
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode == 44)
			return true;
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

//Name          : isNumberKey
//Objective     : Function to allow only Numbers
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function isNumberEvt(evt)
{
         var charCode = (evt.which) ? evt.which : event.keyCode
         
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

//Name          : fnFormatNumbers
//Objective     : Function to check Amount Validation
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function fnFormatNumbers(obj,FormatPosition,Digit)
{       
  if (obj.length!=0)
  {
    var sVal='';
    var minus='';
    var CommaDelimiter='';
    var num = obj.value;

	if (num!="")     
	{
		CommaDelimiter = GetCommaDelimiter(FormatPosition);
		if (num.lastIndexOf("-") == 0) 
		{
			minus='-'; 
		}
			num = FormatClean(num);
			num = parseInt(num,10);
			var samount = new String(num);
			for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
			{   
				samount = samount.substring(0,samount.length-(4*i+3)) + CommaDelimiter + samount.substring(samount.length-(4*i+3));
	       }
		    obj.value = minus+samount;
		    
        if (obj.value == 'NaN')
        {
            obj.value="";
        }//End of if (obj.value == 'NaN')
        
        if (FormatClean(obj.value).length > Digit)
        {
			alert('Notification : Allows only ' + Digit + ' Digits');
			obj.focus();
			obj.value="";
        }//End of if (FormatClean(obj.value).length > Digit)
        
    } //End if (num!="")
  }//End of if (obj.length!=0)
}

//Name          : GetCommaDelimiter
//Objective     : Function to get comma delimiter
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function GetCommaDelimiter(FormatPosition)
{
    var sRet='';
    switch (FormatPosition)
       {
           case 2:   
	            sRet = '*';
                break;
           case 3:   
                sRet = ',';
               break;
            default:
               sRet = ',';
               break;
       }
    return sRet;
}

//Name          : FormatClean
//Objective     : Function to Clean Format
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function FormatClean(num)
{
     var sVal='';
     var nVal = num.length;
     var sChar='';
   try
   {
      for(i=0;i<nVal;i++)
	  {
         sChar = num.charAt(i);
         nChar = sChar.charCodeAt(0);
        if ((nChar >=48) && (nChar <=57))
        { 
			sVal += num.charAt(i);   
        }
      }
    }
   catch (exception) 
	{ 
		AlertError("Format Clean",e); 
	}
    return sVal;
}

//Name          : findPosX
//Objective     : Function to Find X postion of a particular object
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
    while (obj.offsetParent)
    {
    curleft += obj.offsetLeft
    obj = obj.offsetParent;
    }
    }
    else if (obj.x)
    curleft += obj.x;
    return curleft;
}
//Name          : findPosY
//Objective     : Function to Find Y postion of a particular object
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
    while (obj.offsetParent)
    {
    curtop += obj.offsetTop
    obj = obj.offsetParent;
    }
    }
    else if (obj.y)
    curtop += obj.y;
    return curtop;
}

//Name          : ClientValidate
//Objective     : Function to Validate DropDownlist
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function ClientValidate(source,args)
{
    var dropDown;
    dropDown = document.getElementById(source.controltovalidate);
	if (dropDown.selectedIndex == 0 )
	{
	    args.IsValid = false ;
	}
	else
	{
	    args.IsValid = true;
	}
}

//Name          : fnValidateYear
//Objective     : Function to Find Y postion of a particular object
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function fnValidateYear(MinYear,MaxYear,txtID)
{
    if (txtID.value != '')
    {
       if (parseInt(txtID.value,10) < parseInt(MinYear,10))
       {
            alert('Notification: Value must not be less than, year ' + MinYear);
            txtID.focus()
		    txtID.select()
        }
        else if (parseInt(txtID.value,10) > parseInt(MaxYear,10))
        {
            alert('Notification: Value must not be greater than Current year');
            txtID.focus()
		    txtID.select()            
        }
    }        
}


/*************************************************************************************************************/
//Functions used in Specific screens
/*************************************************************************************************************/

//Name          : fnTabChanged
//Objective     : Function to do some action when tabs changed in Q-Survey Form
//Used in       : Survey/MDeC_IR_Survey_QSurveyForm.aspx
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function fnTabChanged(sender, args)
{
    var hd = document.getElementById('hdValue');
    var hv = document.getElementById('hdBool');
    var currIndex = hd.value;
    var bool;
    
    tabIndex = sender.get_activeTabIndex();

    if (tabIndex != currIndex)
    {
        
        bool = hv.value;

        if (bool == 'True')
        {
            hd.value = tabIndex;    
        }
        else
        {
            sender.set_activeTab(sender.get_tabs()[currIndex]);
            hd.value = currIndex;
        }
    }            
}

//Name          : fnCheckTabChange
//Objective     : Function to check whether Tab need to change or not
//Used in       : Survey/MDeC_IR_Survey_QSurveyForm.aspx
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function fnCheckTabChange()
{
    var hdVal = document.getElementById('hdBool');
	var bool;
	
	bool = confirm('Notification: Change Tab Confirm?');
	if (bool)
	{
	    hdVal.value = 'True';
    }
	else
	{
	    hdVal.value = 'False';
    }
}

//Name          : CheckCurYear
//Objective     : Function to check whether Year is Greater then Current Year
//Used in       : Master/MDeC_IR_MstTargetDtls.aspx
//Created on    : 02/12/2009
//Created By    : Chandrashekar.SN
function CheckCurYear(TextYr,CurrYr)
{
    	
	if (TextYr.value >CurrYr.value )
	{
		
		alert("Year must less then Current year.")
		TextYr.focus()
		TextYr.select()
		//obj.value = obj.value.substr(0,obj.value.length-1)
		//the above code commented by pravin on 14 july
	}
}	

//Name          : fnPercentage
//Objective     : Function to check whether Percentage is > 100 and checking Decimal value.
//Used in       : Master/MDeC_IR_MstTargetDtls.aspx
//Created on    : 02/12/2009
//Created By    : Chandrashekar.SN
function fnPercentage(TextPer)
{
    var x = parseFloat(TextPer.value);
    var val= TextPer.value;
    var lst= parseInt(val.lastIndexOf("."));
    var fst= parseInt(val.indexOf("."));
    var c= lst - fst;

    if(x <= 0 )
        {
    alert("Percentage must greater then Zero .")
        TextPer.focus()
		TextPer.select()
    }
    
    if (x > 100)
     {
    alert("Percentage must not exceed 100%.")
        TextPer.focus()
		TextPer.select()
    }    

     if (c > 0)
    {
    alert("too much decimal")
     TextPer.focus()
		TextPer.select()
    } 
}
	

//Name          : fnPercentage
//Objective     : Function to check whether Percentage is > 100 and checking Decimal value.
//Used in       : Master/MDeC_IR_MstTargetDtls.aspx
//Created on    : 02/12/2009
//Created By    : Satish Reddy.A
function fnQSurveyMouseOver(obj)
{
    var hd = document.getElementById('hdValue');
    
    if (obj.id == 'imgbtnSection1' && hd.value == '1')
	{
		obj.src="../Images/CBOpen.jpg";
	}
	else
	{
	
	}
	if (obj.id == 'imgbtnSection2' && hd.value == '2')
	{
		obj.src="../../Images/activities2.jpg";
	}
	else
	{
		obj.src="../../Images/contact2.jpg";
	}
	
	if (obj.id =='imgbtnSection3' && hd.value == '3')
	{
		obj.src="../../Images/info2.jpg";
	}
	else
	{
		obj.src="../../Images/info2.jpg";
	}
	
	if (obj.id =='imgbtnSection3' && hd.value == '3')
	{
		obj.src="../../Images/info2.jpg";
	}
	else
	{
		obj.src="../../Images/info2.jpg";
	}
	
}

//Name          : FnCheckAll
//Objective     : Function to check check boxes in Data Grid
//Used in       :  
//Created on    : 014/12/2009
//Created By    : Hari

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) {

//        alert(checkVal.id);
//        alert(checkVal.checked);

        re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon

        for(i = 0; i < document.forms[0].elements.length; i++) {

            elm = document.forms[0].elements[i]

            if (elm.type == 'checkbox') {

//                if (re.test(elm.name)) {

                    elm.checked = checkVal.checked

//                }
            }
        }
    }
//Name          : isNumberNeg
//Objective     : Function to allow only Numbers, - and .(decimal)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function isNumberNeg(evt,obj)
{
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (obj.value != '')
        {
            if (charCode == 45 && obj.value.lastIndexOf("-") == 0) 
            {
                return false;       
            }
        }
         if (charCode == 46 || charCode == 45)
			return true;
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

//Name          : fnFormatNegNumbers
//Objective     : Function to check Amount Validation (allows - . ,)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 25/11/2009
//Created By    : Satish Reddy.A
function fnFormatNegNumbers(obj,FormatPosition,Digit,txtPrev,currentSurvey,CurrentYear,frm) {
    
    try
    {//alert(obj + ',' + FormatPosition + ',' + Digit + ',' + txtPrev + ',' + currentSurvey + ',' + CurrentYear);
        if (obj.value.length != 0)
        {
            var txt;
            var len;
            var i;
            var text = /^[0-9,-.]+$/;

            var orgValue = obj.value;
            var firstValue;
            var secondValue;
            
            var temp = new Array();
            var tempHyp = new Array();
            
            var sVal='';
            var minus='';
            var CommaDelimiter='';
            var num;
            var preValue;
            
            temp = obj.value.split(".");
            tempHyp = obj.value.split('-');
            
            if (temp.length > 2)
            {
                alert("Notification: Only one decimal point is allowed.");
                obj.focus();
			    obj.value = "";
                return false;
            }
            
            if (tempHyp.length > 2)
            {
                alert("Notification: Only one hyphen is allowed.");
                return false;
            }
        if (temp.length == 2)
        {    if (temp[1].length > 2)
            {
                alert("Notification: Only two digists are allowed after decimal point.");
                obj.focus();
			    obj.value = "";
                return false;
            }
            
            if (FormatClean(temp[0].length).length > Digit)
            {
                alert('Notification: Only ' + Digit + ' Digits are allowed.');
			    obj.focus();
			    obj.value=""
                return false;                
            }
        }
        else
        {
            if (FormatClean(temp[0]).length > Digit)
            {
                alert('Notification: Only ' + Digit + ' Digits are allowed.');
			    obj.focus();
			    obj.value=""
                return false;                
            }
        }
         
            if ((document.getElementById(obj.id).value != "") && (!text.test(document.getElementById(obj.id).value)))
            {
                if (obj.value.length == 1)
                {
                    obj.value=0;
                }
                alert("Notification: Please enter numeric values only");
                obj.focus();
                obj.select();
            }
            
            if (temp.length == 2)
            {
                firstValue = temp[0];
                secondValue = temp[1];     
            }
            
            num = temp[0];
            
            if (num!="")
	        {
		        CommaDelimiter = GetCommaDelimiter(FormatPosition);
		        if (num.lastIndexOf("-") == 0) 
		        {
			        minus='-'; 
		        }
			    num = FormatClean(num);
			    num = parseInt(num,10);
			    var samount = new String(num);
			    if (frm != 'Humn') {
			        for (var i = 0; i < Math.floor((samount.length - (1 + i)) / 3); i++) {
			            samount = samount.substring(0, samount.length - (4 * i + 3)) + CommaDelimiter + samount.substring(samount.length - (4 * i + 3));
			        }
			    }
		        preValue = minus + samount;            
		        
		    } //End if (num!="")
            
            if (temp.length == 2)
            {
                obj.value = preValue + '.' + temp[1];
            }
            else
            {    
                obj.value = preValue;
            }
            
            if (obj.value == 'NaN')
            {
                obj.value="";
            }
            
            var V = 0;
//            var x = FormatClean(obj.value);
//            var y = FormatClean(txtPrev.value);

            var curVal;
            var prVal;

            if (obj.value.split(".").length == 1) {
                curVal = obj.value + ".00";
            }
            else {
                curVal = obj.value
            }

            if (txtPrev.value.split(".").length == 1) {
                prVal = txtPrev.value + ".00";
            }
            else {
                prVal = txtPrev.value;
            }

            var x = FormatClean(curVal);
            var y = FormatClean(prVal);

//           var x = obj.value;
//           var y = txtPrev.value;
//           alert(x);
//           alert(y);
            var qarter = FormatClean(currentSurvey.value);
            var Year = FormatClean(CurrentYear.value);
//            alert(qarter);
            if (qarter != 1)
            {
            var Pquarter = qarter - 1;
            var Pyear = Year ;
            }
            else
            {
                //            var Pquarter = 4;
                //            var Pyear = Year - 1 ; // Commented by Hari on 31/03/2011, validation of variance  removed for Quarter 1

            
            }

              var y1 = 0; 
              var y2 = 0;
              y1 = parseInt(y) + 100;
              y2 = y - 100;
            
                 if (txtPrev.value.length != 0)
                 {
                 if (y != 0 && x != 0)
                    {
//                      if (( x > y1) || ( x < y2 ))
//                     {
////                                 alert('test');
//                     
//                                bool = confirm('Warning: The data variance/difference between previous quarter ('+ Pquarter +', '+ Pyear +') and current quarter ('+ qarter + ', '+ Year + ') is found to be very high.\nThis could be due to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
//	                           if (bool)
//	                          {       
//	                   
//                              }
//	                         else
//	                          {
//	                          //txtCurr.style.backgroundColor = 'red';
//	                          txtCurr.focus();
//                              txtCurr.select();                         
//                              }  
//                     
//                     }
//                    
                                
                    
                  
                    
                        if ( parseInt(x,10) > parseInt(y,10))
                        {
//                        alert("F");
                            V = ( x - y)/y;             
                        }
                        else
                        {
//                             alert("s");
                            V = ( y - x)/x;   
                        }
                        if (V < 0)
                        {
                                 V = V * (-1);
                        }  
//                        alert(V);
                        if ( V >= 10) {

                            var prqstr;
                            var qtrstr;
                            if (parseInt(Pquarter, 10) == 1) {
                                prqstr = 'Jan - Mar'
                            }
                            else if (parseInt(Pquarter, 10) == 2) {
                                prqstr = 'Jan - Jun'
                            }
                            else if (parseInt(Pquarter, 10) == 3) {
                                prqstr = 'Jan - Sep'
                            }
                            else if (parseInt(Pquarter, 10) == 4) {
                                prqstr = 'Jan - Dec'
                            }
                            // qtr to string 
                            if (parseInt(qarter, 10) == 1) {
                                qtrstr = 'Jan - Mar'
                            }
                            else if (parseInt(qarter, 10) == 2) {
                                qtrstr = 'Jan - Jun'
                            }
                            else if (parseInt(qarter, 10) == 3) {
                                qtrstr = 'Jan - Sep'
                            }
                            else if (parseInt(qarter, 10) == 4) {
                                qtrstr = 'Jan - Dec'
                            }


                            if (frm == 'Fin') { //From Financial Tab
                                bool = confirm('Warning: The data variance/difference between  (' + prqstr + ', ' + Pyear + ') and  (' + qtrstr + ', ' + Year + ') is found to be very high.\nThis could be due to a typographical error\n1. Click OK to proceed and confirm this value, enter Reason as well.\n2. Click Cancel to re-enter the figure.');
                            }
                            else {
                                bool = confirm('Warning: The data variance/difference between  (' + prqstr + ', ' + Pyear + ') and  (' + qtrstr + ', ' + Year + ') is found to be very high.\nThis could be due to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
                            }
                               
                             // bool = confirm('Warning: The data variance/difference between previous quarter (Q1, 2010)\n and current quarter (Q2, 2010) is found to be very high. This could be due\n to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
	                          if (bool)
	                          {       
	                   
                              }
	                         else
	                          {
	                          //obj.style.backgroundColor = 'red';   
	                          obj.focus();
                              obj.select();                     
                              }  
                              
                         }//End of  ( V >= 10)
                                  
                   }//End of (y > 0)
                 
                 }// End of (Prev.value.length != 0)
             
                     
 
            
        }//End of if (obj.value.length != 0)
    }
    catch (exception) 
	{ 
//		alert('Not Valid');
	}
}

//Name          : fnGetFPVariance
//Objective     : Function to check Variance 
//Used in       : Survey/MDeC_IR_Survey_QSurveyForm.aspx
//Created on    : 25/11/2009
//Created By    : Chandrashekar.SN
function fnGetFPVariance(txtCurr,txtPrev,currentSurvey,CurrentYear)
{
     
            var V = 0;
            var x = FormatClean(txtCurr.value);
            var y = FormatClean(txtPrev.value);
            
            var qarter = FormatClean(currentSurvey.value);
            var Year = FormatClean(CurrentYear.value);
    
            if (qarter != 1)
            {
            var Pquarter = qarter - 1;
            var Pyear = Year ;
            }
            else
            {
            var Pquarter = 4;
            var Pyear = Year - 1 ;
            
            }

              var y1 = 0; 
              var y2 = 0;
              y1 = parseInt(y) + 100;
              y2 = y - 100;
            
           
//             alert(y1);
//             alert(y2);
//             alert(x);
                      
             if (txtCurr.value.length != 0)
             {
                 if (txtPrev.value.length != 0)
                 {
                    if (y != 0 && x != 0)
                    {
                    
                    
//                     if (( x > y1) || ( x < y2 ))
//                     {
//                                // alert('test');
//                     
//                                bool = confirm('Warning: The data variance/difference between previous quarter ('+ Pquarter +', '+ Pyear +') and current quarter ('+ qarter + ', '+ Year + ') is found to be very high. \nThis could be due to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
//	                           if (bool)
//	                          {       
//	                   
//                              }
//	                         else
//	                          {
//	                          //txtCurr.style.backgroundColor = 'red';
//	                          txtCurr.focus();
//                              txtCurr.select();                         
//                              }  
//                     
//                     }
                   //previous 
                    
                        if ( parseInt(x,10) > parseInt(y,10))
                        {
                            V = ( x - y)/y;             
                        }
                        else
                        {
                            V = ( y - x)/x;   
                        }
                        if (V < 0)
                        {
                                 V = V * (-1);
                        }  
                           if ( V >= 10) {

                               var prqstr;
                               var qtrstr;
                               if ( parseInt(Pquarter,10) == 1) {
                                   prqstr = 'Jan - Mar'
                               }
                               else if (parseInt(Pquarter, 10) == 2) {
                                   prqstr = 'Jan - Jun'
                               }
                               else if (parseInt(Pquarter, 10) == 3) {
                                   prqstr = 'Jan - Sep'
                               }
                               else if (parseInt(Pquarter, 10) == 4) {
                                   prqstr = 'Jan - Dec'
                               }
                               // qtr to string 
                               if ( parseInt(qarter,10) == 1) {
                                   qtrstr = 'Jan - Mar'
                               }
                               else if (parseInt(qarter, 10) == 2) {
                                   qtrstr = 'Jan - Jun'
                               }
                               else if (parseInt(qarter, 10) == 3) {
                                   qtrstr = 'Jan - Sep'
                               }
                               else if (parseInt(qarter, 10) == 4) {
                                   qtrstr = 'Jan - Dec'
                               }


                                                          //bool = confirm('Notification: Variance between previous quarter and current quarter is found to be very high,\n                        Click OK to proceed');
                               bool = confirm('Warning: The data variance/difference between  (' + prqstr + ', ' + Pyear + ')\n and  (' + qtrstr + ', ' + Year + ') is found to be very high. This could be due\n to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
	                          if (bool)
	                          {       
	                   
                              }
	                         else
	                          {
	                          //txtCurr.style.backgroundColor = 'red';
	                          txtCurr.focus();
                              txtCurr.select();                         
                              }  
                              
                         }//End of  ( V >= 10)
                                  
                     }//End of (y > 0)
                 
                 }// End of (txtPrev.value.length != 0)
             
             }// End of (txtCurr.value.length != 0)          
          			
}




function fnGetFPJobVariance(txtCurr,txtPrev,currentSurvey,CurrentYear)
{
     
            var V = 0;
            var x = FormatClean(txtCurr.value);
            var y = FormatClean(txtPrev.value);
            
            var qarter = FormatClean(currentSurvey.value);
            var Year = FormatClean(CurrentYear.value);
    
            if (qarter != 1)
            {
            var Pquarter = qarter - 1;
            var Pyear = Year ;
            }
            else
            {
            var Pquarter = 4;
            var Pyear = Year - 1 ;
            
            }

              var y1 = 0; 
              var y2 = 0;
              y1 = parseInt(y) + 100;
              y2 = y - 100;
            
           
//             alert(y1);
//             alert(y2);
//             alert(x);
                      
             if (txtCurr.value.length != 0)
             {
                 if (txtPrev.value.length != 0)
                 {
                    if (y != 0 && x != 0)
                    {
                    
                    
                     if (( x > y1) || ( x < y2 ))
                     {
                                // alert('test');
                     
                               // bool = confirm('Warning: The data variance/difference between previous quarter ('+ Pquarter +', '+ Pyear +')\n and current quarter ('+ qarter + ', '+ Year + ') is found to be very high. This could be due\n to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
                              bool = confirm('Warning: The number of jobs should ONLY reflect the number of staff employed to work on MSC Malaysia approved activities. The entered figure is found to be very high. This could be due to a typographical error. Please \n Click OK to proceed and confirm this value, or \n Click CANCEL to amend the figure.');
	                           if (bool)
	                          {       
	                   
                              }
	                         else
	                          {
	                          //txtCurr.style.backgroundColor = 'red';
	                          txtCurr.focus();
                              txtCurr.select();                         
                              }  
                     
                     }
                   //previous 
                    
//                          if (x > y)
//                        {
//                            V = ( x - y)/y;             
//                        }
//                        else
//                        {
//                            V = ( y - x)/x;   
//                        }
//                        if (V < 0)
//                        {
//                                 V = V * (-1);
//                        }  
//                           if ( V >= 10)
//                           {
//                                                          //bool = confirm('Notification: Variance between previous quarter and current quarter is found to be very high,\n                        Click OK to proceed');
//                              bool = confirm('Warning: The data variance/difference between previous quarter ('+ Pquarter +', '+ Pyear +')\n and current quarter ('+ qarter + ', '+ Year + ') is found to be very high. This could be due\n to a typographical error\n1. Click OK to proceed and confirm this value.\n2. Click Cancel to re-enter the figure.');
//	                          if (bool)
//	                          {       
//	                   
//                              }
//	                         else
//	                          {
//	                          //txtCurr.style.backgroundColor = 'red';
//	                          txtCurr.focus();
//                              txtCurr.select();                         
//                              }  
//                              
//                         }//End of  ( V >= 10)
                                  
                     }//End of (y > 0)
                 
                 }// End of (txtPrev.value.length != 0)
             
             }// End of (txtCurr.value.length != 0)          
          			
}



/*------------------------------------------------------------------------------------------------------*/
/*-------------- ANNUAL SURVEY -------------- ANNUAL SURVEY -------------- ANNUAL SURVEY ---------------*/
/*------------------------------------------------------------------------------------------------------*/


//Name          : fnCheckLength
//Objective     : Function to check the Length of the TextBox Value 
//Used in       : Annual Survey
//Created on    : 12/05/2010
//Created By    : Prasanti Prusty
function fnCheckLength(obj,Length)
{
    if (obj.value.length>eval(Length))
    {
        alert("Exceeding Maximum " + Length +" Characters")
        obj.focus()
        //obj.select()
          
        //Added Range by HariKrishna on 13/May/2010      
        if(obj.setSelectionRange)
        {
            obj.setSelectionRange(Length,obj.value.length);
        }
        else
        {
            var rnge = obj.createTextRange();
            rnge.collapse(true);
            rnge.moveEnd('character',obj.value.length);
            rnge.moveStart('character',Length);
            rnge.select();
        }
    }
}

//Name          : chkTxtBox
//Objective     : Function to Enable/Disable the relevant textbox based on the Checkbox checked/un-checked 
//Used in       : Annual Survey - Score - Section 0 - Company Information
//Created on    : 12/05/2010
//Created By    : M.HariKrishna
function chkTxtBox(chk,txtbx)
{
    var chk = document.getElementById(chk);
    var txt = document.getElementById(txtbx);
    //alert(chk.checked);
    //alert(txt.value);
    
    if (chk.checked == true)
    {
        txt.disabled = '';
        txt.focus();
    }
    else
    {
        txt.value = '';
        txt.disabled = 'disabled';
    }
}

//Name          : fnUplCheck
//Objective     : Function to check whether file selected to upload
//Used in       : Annual Survey - Score - Section H - Signatory Details
//Created on    : 17/05/2010
//Created By    : M.HariKrishna
function fnUplCheck(flupl)
{
    //alert(document.getElementById(flupl).value);
    var uplStr = document.getElementById(flupl).value;
    if(uplStr == '')
    {
        alert('Notification : Please browse to upload a file');
        return false;
    }
    else
    {
        return true;
    }
    
}

//Name          : fnSecHandOver
//Objective     : Function to change image on mouseover of each section
//Used in       : Annual Survey - BaseSCORE/SCORE List of Sections
//Created on    : 20/05/2010
//Created By    : Satish Reddy.A
function fnSecHandOver(td,hdn)
{
    //alert(document.getElementById(td));
    var lblBS = document.getElementById('lblBSText');
       
    //td.style.backgroundImage = "url('../../Images/secOver.gif')"
    //td.style.backgroundImage = "url('../../Images/animate.gif')"
    //td.style.backgroundColor = 'green';
    //alert(td.style.backgroundColor);
    //td.style.textDecoration='blink';
    td.style.fontVariant='small-caps';
    td.style.fontStyle='oblique';
    //td.style.textAlign='center';
    //td.style.verticalAlign='middle';
    //td.style.listStyle='inside';
    
          
    if (lblBS.innerText)
    {
        lblBS.innerHTML = hdn.value;
    }
    else
    {
        lblBS.innerHTML = hdn.value;
    }
}

//Name          : fnSecHandOut
//Objective     : Function to change image onmouseout of each section
//Used in       : Annual Survey - BaseSCORE/SCORE List of Sections
//Created on    : 20/05/2010
//Created By    : Satish Reddy.A
function fnSecHandOut(obj)
{
    //alert(obj);
    var lblBS = document.getElementById('lblBSText');
    var hdnBS = document.getElementById('hdBSText');
    
    //obj.style.backgroundImage = "url('../../Images/SecNormal.JPG')"
    //obj.style.backgroundImage = '';
    //obj.style.backgroundColor = '#109955';
    obj.style.fontVariant='normal';
    obj.style.fontStyle='normal';
    //obj.style.textAlign='left';
    //obj.style.verticalAlign='top';
    
     
    
    if (lblBS.innerText)
    {
        lblBS.innerHTML = hdnBS.value;
    }
    else
    {
        lblBS.innerHTML = hdnBS.value;
    }
    
}

//Name          : grdSelectAll
//Objective     : Function to select/deselect the grid checkboxes based on the parent/child checkboxes
//Used in       : Annual Survey - FactSheet and also its a generic function
//Created on    : 24/05/2010
//Created By    : M. HariKrishna
//Comments      : cntrl - parent checkbox, grd - gridName, indCat - indicator to know calling from parent(1)/child(2) checkbox

function grdSelectAll(cntrl,grd,indCat)
{
    var grdComp = document.getElementById(grd);          
    
    if(indCat == '1')    
    {
        for(i=1;i<=grdComp.getElementsByTagName('input').length-1;i++)
        {
            grdComp.getElementsByTagName('input')[i].checked = cntrl.checked;
        }
    }
    else if(indCat == '2')
    { 
        var chkInd = true;
        for(i=1;i<=grdComp.getElementsByTagName('input').length-1;i++)
        {                 
            if(grdComp.getElementsByTagName('input')[i].checked == false)
            {
                chkInd = false;
            }                    
        }
        grdComp.getElementsByTagName('input')[0].checked = chkInd;             
    }
}

//Name          : enableDisable
//Objective     : Function to enable/disable the textbox if Others(Specify) is selected
//Used in       : Annual Survey - Score
//Created on    : 25/05/2010
//Created By    : Ayaz
//Comments      : rdb - Radio button list, txt - textbox to enter the Others(Specify) description


function enableDisable(rdb,txt)
  {
   var txt=document.getElementById(txt)
   var rdblist=document.getElementById(rdb)
   var radio = rdblist.getElementsByTagName("input");
   var label = rdblist.getElementsByTagName("label");
   var isChecked=false;
   for (var i=0;i<radio.length;i++)
    {
     if (radio[i].checked)
       {
         if (label[i].innerHTML=="Others (specify)")
          {
            txt.disabled=false;
            txt.focus();
            isChecked=true;
            return isChecked;
          }
         else
          {
            txt.value='';
            txt.disabled=true;
            isChecked=true;
            return isChecked;
          }
       }
     }
  }
//Name          : enableDisablechk
//Objective     : Function to enable/disable the textbox if Others(Specify) or None is selected
//Used in       : Annual Survey - Score
//Created on    : 26/05/2010
//Created By    : Ayaz
//Comments      : chk - CheckboxList, txt - textbox to enter the Others(Specify) description
 function enableDisablechk(chk,txt)
  {
   var txt=document.getElementById(txt)
   var txtNone=document.getElementById('txtQn44None')
   var chklist=document.getElementById(chk)
   var checkbox = chklist.getElementsByTagName("input");
   var label = chklist.getElementsByTagName("label");
   var isChecked=false;
   for (var i=0;i<checkbox.length;i++)
    {
      if (label[i].innerHTML=="Others (specify)" || label[i].innerHTML=="None")
       {
         if (checkbox[i].checked)
          {
                if (label[i].innerHTML=="Others (specify)")
                 {
                   txt.disabled=false;
                   txt.focus();
                   isChecked=true;

                 }
                 else if(label[i].innerHTML=="None")
                 {
                   txtNone.disabled=false;
                   txtNone.focus();
                   isChecked=true;

                 }
          }
          else if(!checkbox[i].checked)
          {
                if (label[i].innerHTML=="Others (specify)")
                 {
                   txt.disabled=true;
                   txt.value="";
                   isChecked=true;
                   
                 }
                 else if(label[i].innerHTML=="None")
                 {
                   txtNone.disabled=true;
                   txtNone.value="";
                   isChecked=true;
                   
                 }
          }
       }
         
    }
    return isChecked;
  }
  
  
//Name          : rowTotal
//Objective     : Function to get the sum of values of two textbox and display it on label.
//Used in       : Annual Survey - Score
//Created on    : 25/05/2010
//Created By    : Ayaz
//Comments      : txt1 - TextBox1, txt2 - TextBox2, lbl - Label to display the sum of txt1 and txt2
  function rowTotal(txt1,txt2,lbl)
         {  
             var textVal1 = document.getElementById(txt1);   
             var textVal2 = document.getElementById(txt2);   
             var lblVal = document.getElementById(lbl);   
             textVal1 = textVal1.value == null ? 0 : Number(textVal1.value);   
             textVal2 = textVal2.value == null ? 0 : Number(textVal2.value);   
             
             if(lblVal.innerText)
             {
                lblVal.innerText = textVal1 + textVal2;   
             }
             else
             {
                lblVal.innerHTML = textVal1 + textVal2;
             }
         }
         
//Name          : colTotal
//Objective     : Function to get the sum of values in TextBox and Label (columnwise) and display it on label.
//Used in       : Annual Survey - Score
//Created on    : 25/05/2010
//Created By    : Ayaz
//Comments      : 
  function colTotal()
         {
             var lblPHD=document.getElementById('lblPHDTotal');
             var lblDegree=document.getElementById('lblDegreeTotal');
             var lblDiploma=document.getElementById('lblDiplomaTotal');
             var lblCertification=document.getElementById('lblCertfctTotal');
             var lblM5=document.getElementById('lblMoreThn5Total');
             var lblGT1=document.getElementById('lblGrntTotal');
                          
             if(lblGT1.innerText)
             {
                lblGT1.innerText = Number(lblPHD.innerText)+ Number(lblDegree.innerText)+ Number(lblDiploma.innerText)+ Number(lblCertification.innerText)+ Number(lblM5.innerText);
             }
             else
             {
                lblGT1.innerHTML = Number(lblPHD.innerHTML)+ Number(lblDegree.innerHTML)+ Number(lblDiploma.innerHTML)+ Number(lblCertification.innerHTML)+ Number(lblM5.innerHTML);
             }
             
             var txtPHD2=document.getElementById('txtPHDKnwWr');
             var txtDegree2=document.getElementById('txtDegreeKnwWr');
             var txtDiploma2=document.getElementById('txtDiplomaKnwWr');
             var txtCertification2=document.getElementById('txtCertificateKnwWr');
             var txtM2=document.getElementById('txtMoreThan5YrKnwWr');
             var lblGT2=document.getElementById('lblGrntTotalKnwWr');
             
             if(lblGT2.innerText)
             {
                lblGT2.innerText = Number(txtPHD2.value) + Number(txtDegree2.value) + Number(txtDiploma2.value) + Number(txtCertification2.value) + Number(txtM2.value);
             }
             else
             {
                lblGT2.innerHTML = Number(txtPHD2.value) + Number(txtDegree2.value) + Number(txtDiploma2.value) + Number(txtCertification2.value) + Number(txtM2.value);
             }
             
             var txtPHD3=document.getElementById('txtPHDFrKnwWr');
             var txtDegree3=document.getElementById('txtDegreeFrKnwWr');
             var txtDiploma3=document.getElementById('txtDiplomaFrKnwWr');
             var txtCertification3=document.getElementById('txtCertificateFrKnwWr');
             var txtM3=document.getElementById('txtMoreThan5FrnWr');
             var lblGT3=document.getElementById('lblGrntTotalFrKnwWr');
                          
             if(lblGT3.innerText)
             {
                lblGT3.innerText = Number(txtPHD3.value) + Number(txtDegree3.value) + Number(txtDiploma3.value) + Number(txtCertification3.value) + Number(txtM3.value);
             }
             else
             {
                lblGT3.innerHTML = Number(txtPHD3.value) + Number(txtDegree3.value) + Number(txtDiploma3.value) + Number(txtCertification3.value) + Number(txtM3.value);
             }
             
         }

//Name          : ValidateSecB
//Objective     : Function to validate RadioButtonList.
//Used in       : Annual Survey - Score
//Created on    : 31/05/2010
//Created By    : Ayaz
//Comments      : QnFrom - First Question of section B, QnTo-Last Quetion of Section B
    function ValidateSecB(QnFrom,QnTo)
       {
       var res=new Boolean(true);
       for (var i = QnFrom; i <= QnTo; i++)
       {
        var radioButtons = document.getElementsByName('rdb'+i);
        if(radioButtons.length==0)
        {
        continue;
        }
        //Validate RadioButtonList
        if (radioButtons.length !=0)
        {
        //var lbl = document.getElementById('lbl'+i)
        var lbl = document.getElementById('lblMsgCap')
        var lbl1 = document.getElementById('lblMsgData')
         
        var bool=new Boolean(false);
        for (var j = 0; j < radioButtons.length; j++)
        {
            if (radioButtons[j].checked) 
            {
                 bool=true;
                 break;
            }
        }
        if (bool==false)
        {
        lbl.innerHTML="<font color='red'><b>Notification:</b></font>";
        lbl1.innerHTML="<font color='red'>Please Choose the answer for Qno " + i +"</font>";
        //res=false;
           //lblMsgCap.Text = "<font color='red'>Notification: </font>"
            //    lblMsgData.Text = "<font color='red'>Record Not saved </font>"
        return false;
        }
        else
        {
        lbl.innerHTML="";
        lbl1.innerHTML="";
        }
        }
     }
     return res;
    }
//Name          : ValidatetxtSecB
//Objective     : Function to validate TextBox.
//Used in       : Annual Survey - Score
//Created on    : 31/05/2010
//Created By    : Ayaz
//Comments      : txtID1 - txt28, txtID2-txt29, BID1-BehaviorId of ValidateCallOutExtender for txt28, BID2-BehaviorId for ValidateCallOutExtender for txt29
  function ValidatetxtSecB(txtID1,txtID2,BID1,BID2)
    {
    var txt1 = document.getElementById(txtID1);
    var txt2 = document.getElementById(txtID2);
    var bool = new Boolean(true);
    if (txt1 != null)
    {
    if (txt1.value == "" ) // added by bhaskar on 09/06/2010, txt1.value== null as value passed is null
       {
         $find(BID1)._ensureCallout();
         $find(BID1).show();
         bool = false;
       }
    }
    if (txt2 != null)
    {
    
    if (txt2.value == "" )   // added by bhaskar on 09/06/2010, txt2.value== null as value passed is null
       {
         $find(BID2)._ensureCallout();
         $find(BID2).show();
         bool = false;
       }
    }
       return bool;
    }       
      


//Name          : valdate
//Objective     : Function to validate checkboxes and relevant textboxes
//Used in       : Annual Survey - Score - MDeC_AS_SP_CompanyInformation.aspx
//Created on    : 27/05/2010
//Created By    : M. HariKrishna
//Comments      : Need to check the textbox is empty if relevant checkbox is selected
function valdate(chk1,txt1,chk2,txt2,chk3,txt3)
{
    var dispMsg = '';
    //alert(document.getElementById(chk1));
    var chkOne = document.getElementById(chk1);
    var txtOne = document.getElementById(txt1);
    var chkTwo = document.getElementById(chk2);
    var txtTwo = document.getElementById(txt2);
    var chkThree = document.getElementById(chk3);
    var txtThree = document.getElementById(txt3);
                
    if(chkOne.checked == true)
    {
        if(txtOne.value.length<1||!txtOne.value.match(/[^\s]/))
        {
            dispMsg = 'Please enter SMIDEC Grant Description\n';
        }
    }
    if(chkTwo.checked == true)
    {
        if(txtTwo.value.length<1||!txtTwo.value.match(/[^\s]/))
        {
            dispMsg += 'Please enter MSC Grant Description\n';
        }
    }
    if(chkThree.checked == true)
    {
        if(txtThree.value.length<1||!txtThree.value.match(/[^\s]/))
        {
            dispMsg += 'Please enter Others Description';
        }
    }
    
    if(dispMsg!='')
    {
        alert(dispMsg);
        return false;
    }
    else
    {
        return true;
    }
    
}


//Name          : fnAsFormatNegNumbers
//Objective     : Function to check Amount Validation (allows - . ,)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 31/05/2010
//Created By    : Satish Reddy.A
function fnAsFormatNegNumbers(obj,FormatPosition,Digit)
{
    try
    {
        if (obj.value.length != 0)
        {
            var txt;
            var len;
            var i;
            var text = /^[0-9,-.]+$/;

            var orgValue = obj.value;
            var firstValue;
            var secondValue;
            
            var temp = new Array();
            var tempHyp = new Array();
            
            var sVal='';
            var minus='';
            var CommaDelimiter='';
            var num;
            var preValue;
            
            temp = obj.value.split(".");
            tempHyp = obj.value.split('-');
            
            if (temp.length > 2)
            {
                alert("Notification: Only one decimal point is allowed.");
                obj.focus();
			    obj.value = "";
                return false;
            }
            
            if (tempHyp.length > 2)
            {
                alert("Notification: Only one hyphen is allowed.");
                obj.focus();
			    obj.value = "";
                return false;
            }
            //alert(obj.value.indexOf('.')+','+obj.value.indexOf('-'));
            
            //Start - Added by HariKrishna
            if(obj.value.indexOf('-') != 0 && obj.value.indexOf('-') != -1)
            {
                alert("Notification: Hyphen must be at first position.");
                obj.focus();
			    obj.value = "";
                return false;
            }
            //alert(obj.value.indexOf('.'));
            
            if(obj.value.indexOf('.') != -1 && obj.value.indexOf('-') != -1)
            {            
                if((parseInt(obj.value.indexOf('.'),10)+1 == parseInt(obj.value.indexOf('-'),10)) ||  (parseInt(obj.value.indexOf('.'),10)-1 == parseInt(obj.value.indexOf('-'),10)))
                {
                    alert("Notification: Hyphen must not be allowed before/after decimal.");
                    obj.focus();
			        obj.value = "";
                    return false;
                }
            }
            //End - Added by HariKrishna
            
        if (temp.length == 2)
        {    if (temp[1].length > 2)
            {
                alert("Notification: Only two digits are allowed after decimal point.");
                obj.focus();
			    obj.value = "";
                return false;
            }            
            if (FormatClean(temp[0]).length > Digit)
            {                
                alert('Notification: Only ' + Digit + ' digits are allowed.');
			    obj.focus();
			    obj.value=""
                return false;                
            }
        }
        else
        {
            if (FormatClean(temp[0]).length > Digit)
            {                
                alert('Notification: Only ' + Digit + ' digits are allowed.');
			    obj.focus();
			    obj.value=""
                return false;                
            }
        }
         
            if ((document.getElementById(obj.id).value != "") && (!text.test(document.getElementById(obj.id).value)))
            {
                if (obj.value.length == 1)
                {
                    obj.value=0;
                }
                alert("Notification: Please enter numeric values only");
                obj.focus();
                obj.select();
            }
            
            if (temp.length == 2)
            {
                firstValue = temp[0];
                secondValue = temp[1];     
            }
            
            num = temp[0];
            
            if (num!="")
	        {
		        CommaDelimiter = GetCommaDelimiter(FormatPosition);
		        if (num.lastIndexOf("-") == 0) 
		        {
			        minus='-'; 
		        }
			    num = FormatClean(num);
			    num = parseInt(num,10);
			    var samount = new String(num);
			    for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
			    {
				    samount = samount.substring(0,samount.length-(4*i+3)) + CommaDelimiter + samount.substring(samount.length-(4*i+3));
	            }
		        
		        preValue = minus + samount;            
		        
		    } //End if (num!="")		   
		    objlen=((obj.value.split(",")).length);		    	    
		   if(!(objlen>=2))	 
		   {      		            		    
               obj.value=CommaFormatted(obj.value);            
           }
        }//End of if (obj.value.length != 0)
    }
    catch (exception) 
	{ 
		alert('Not Valid');
	}
}


//Name          : confDel
//Objective     : Function to show a confirmation message before deleting a record
//Used in       : MDeC_AS_FS_FactSheet
//Created on    : 02/06/2010
//Created By    : M. HariKrishna
function confDel()
{
    if(confirm('This record will be deleted permanently.Confirm ?'))
    {
        return true;
    }
    else
    {
        return false;
    }
}

//Name          : txtOthers
//Objective     : Function to display Others description textbox when selected Others in the dropdown list
//Used in       : MDeC_AS_FS_FactSheet
//Created on    : 02/06/2010
//Created By    : M. HariKrishna
function txtOthers(ddl,txtbox)
{
    var ddlst = document.getElementById(ddl);
    var txt = document.getElementById(txtbox);
 /// alert(ddlst.options[ddlst.selectedIndex].value+' , '+txtbox);
    if(ddlst != null && txt != null)
  {
    
        if(ddlst.options[ddlst.selectedIndex].value == 'OTA')
        {
            
            txt.style.visibility = 'visible';
        }
        else
        {
            txt.style.visibility = 'hidden';
            txt.value = '';
        }
     }
}

//Name          : txtOthersReadOnly
//Objective     : Function to set Readonly for Others description textbox when selected other than Others in the dropdown list
//Used in       : MDeC_AS_FS_FactSheet
//Created on    : 02/06/2010
//Created By    : M. HariKrishna
function txtOthersReadOnly(ddl, txtbox) {
 
    var ddlst = document.getElementById(ddl);
    var txt = document.getElementById(txtbox);
   
    /// alert(ddlst.options[ddlst.selectedIndex].value+' , '+txtbox);
    if (ddlst != null && txt != null) {

        if (ddlst.options[ddlst.selectedIndex].value == 'OTH') {

            //txt.style.visibility = 'visible';
            txt.disabled = '';
        }
        else {
            txt.disabled = 'disabled';
            //txt.style.visibility = 'hidden';
            txt.value = '';
        }
    }
}



//Name          : showToolTip
//Objective     : Function to assign Tooltip for each and every item in the drop down list
//Used in       : MDeC_AS_FS_FactSheet
//Created on    : 02/06/2010
//Created By    : M. HariKrishna
function showToolTip(id)
{
    var ddl = document.getElementById(id);
        
    if(ddl != null)
    { 
        ddl.title=ddl.options[ddl.selectedIndex].text;
        //alert(ddl.options[ddl.selectedIndex].value);
        //alert(ddl.options[1].text);
        for(i=0;i<=ddl.options.length-1;i++)
        {
            ddl.options[i].title=ddl.options[i].text;
        }
        //alert(id);
    }
}
//Name : txtOthersKey
//Objective : Function to display Others description textbox when selected Others in the dropdown list
//Used in : KeyChallenges
//Created on : 11/06/2010
//Created By : K Sarathbabu
function txtOthersKey(ddl,txtbox,value)
{
    var ddlst = document.getElementById(ddl);
    var txt = document.getElementById(txtbox);
    /// alert(ddlst.options[ddlst.selectedIndex].value+' , '+txtbox);
    if(ddlst != null && txt != null)
    {
        if(ddlst.options[ddlst.selectedIndex].value == value)
        {
            txt.style.visibility = 'visible';
        }
        else
        {
            txt.style.visibility = 'hidden';
        }
    }
}
   
//Name : fngetDate
//Objective : Function to check whether the selected textbox value year is greater than current year
//Used in : BaseScore\Financial Performance
//Created on : 03/07/2010
//Created By : Bhaskar
function fngetDate(txt)
{
    var curTime = new Date()
    //alert(document.getElementById(txt).value);
    var dt=document.getElementById(txt).value;
    var dtarray=dt.split("/");
    //alert(dtarray[2]);
    if(dtarray[2] > curTime.getFullYear())
    {
        alert("Notification: Year must not be greater than current year!")
        document.getElementById(txt).value = '';
    }
}


//Name          : CheckAllGridViewCheckBoxes
//Objective     : Function to check check boxes in GridView
//Used in       :  Common\ReAssign AM
//Created on    : 20/07/2010
//Created By    : M.Vijayraj



function CheckAllGridViewCheckBoxes(checkVal) {
        
        for(i = 0; i < document.forms[0].elements.length; i++) {

            elm = document.forms[0].elements[i]

            if (elm.type == 'checkbox') {
            
                if(elm.disabled==false){                                   

                    elm.checked = checkVal.checked

                }
            }
        }//end of for loop
    }//end CheckAllGridViewCheckBoxes
    
 //Name          : UncheckGridViewCheckBoxHeader
//Objective     : Function to uncheck check box Header in GridView
//Used in       :  Common\ReAssign AM
//Created on    : 20/07/2010
//Created By    : M.Vijayraj
//Modified By   : M.Vijayraj. To check select header checkbox, if all checkboxes are selected
      
    function UncheckGridViewCheckBoxHeader(elm){
        str=elm.id;
        if(document.getElementById('gvAssignAM_ctl01_chkSelect').checked){				        				      
				        if(document.getElementById(str).checked)
				        {
				            document.getElementById(str).checked=true;				          
				        }
				        else{
				            document.getElementById('gvAssignAM_ctl01_chkSelect').checked=false;  
					        document.getElementById(str).checked=false;					        
				        }
		}
		else
		{
		         flag=0;		        		               
		         for(i = 0; i < document.forms[0].elements.length; i++) {		          
                    elm = document.forms[0].elements[i];                    
                    if(elm.id!='gvAssignAM_ctl01_chkSelect')
                    {
                        if (elm.type == 'checkbox') {                                          
                          if(elm.disabled==false){if(elm.checked==true){flag=1;} else{flag=0;break;}}
                        }
                    }
                }//end of for loop                
                if(flag==1)
                    document.getElementById('gvAssignAM_ctl01_chkSelect').checked=true;  
		}
                      
    }
    
    
    //this function is added by akhtar for Outlook object on 01-02-07
		function SendAttach(strMailBody,to1,cc1,subject1,mailbdywithoutlook)
		{	
			
			var to;	
			var cc;
			var subject;
			var body;
			var strMailBdy;		
			try
			{					
			 to =to1 ;
			 cc =cc1;						 
			 subject = subject1;			
			 strMailBdy = mailbdywithoutlook;			
			 body = strMailBody; //document.getElementById('HiddenBody').value					 
			 var theApp = new ActiveXObject("Outlook.Application");
			 var theMailItem = theApp.CreateItem(0); // value 0 = MailItem											
			 theMailItem.To = (to);
			 theMailItem.CC=(cc);	
			 theMailItem.Subject = (subject);
			 theMailItem.BodyFormat=3;
			 theMailItem.HTMLbody = (body);				 
			 theMailItem.display();			
			}			
			catch(err)
			{
			//alert("Outlook object cannot be created.");						
			var msg = strMailBdy			   		
			var intIndexOfMatch = msg.indexOf( "<BR>" );
				while (intIndexOfMatch != -1)
					{
						msg = msg.replace( "<BR>", "%0D%0A" )
						intIndexOfMatch = msg.indexOf( "<BR>" );
					}											
			msg = msg.replace('<font style= "FONT-SIZE: 11pt; FONT-FAMILY: Optima">',"");			
			msg = msg.replace("</font>","");						
		  //window.navigate("mailto:" + to + "?CC=" + cc + "&Subject=" + subject + "&body=" + msg);	
		    if(cc!='')
		        window.location.href =  "mailto:" + to + "?CC=" + cc + "&Subject=" + subject + "&body=" + msg ;
		    else
		        window.location.href =  "mailto:" + to + "?Subject=" + subject + "&body=" + msg ;
			return;
			}												
		}	
    
    
//Name : fnChkDate
//Objective  : Function to check whether the selected textbox value Date is greater than current Date
//Used in    : Transition Report
//Created on : 21/07/2010
//Created By : Prasanti
function fnChkDate(txt)
{
    var curTime = new Date()
    var dd1 = parseInt(curTime.getDate(),10);
    var mm1 = parseInt(curTime.getMonth()+1,10);
    var yyyy1 = parseInt(curTime.getFullYear(),10);
    var date1 = new Date(yyyy1, mm1, dd1);
      
    var DtVal  = document.getElementById(txt).value;
    var dd2   = parseInt(DtVal.substring(0,2),10);
    var mm2   = parseInt(DtVal.substring(3,5),10);
    var yyyy2 = parseInt(DtVal.substring(6,10),10);
    var date2 = new Date(yyyy2, mm2, dd2);     
   
    if(date2 > date1)
    {
        alert("Notification: Date must not be greater than current Date!")
        document.getElementById(txt).value = '';
    }
}

    
//Name : getGridTextBoxTotal
//Objective  : Function to Calculate the sum of Max Score in Master Screens
//Used in    : SCORE PLUS Master Screen
//Created on : 23/09/2010
//Created By : Prasanti
    function getGridTextBoxTotal(obj)
    {
        try
        {
            var gvDrv = document.getElementById(obj);
            var scr = document.getElementById('hdscore');
            
            for(i=1; i<gvDrv.rows.length-1; i++)
            {
                var cell = gvDrv.rows[i].cells[4];
                for (j=0; j<cell.childNodes.length-1; j++)
                {    
                    if (cell.childNodes[j].type == "text")
                    { 
                        var MS=0;
                        if (String(Number(cell.childNodes[j].value))  != 'NaN')
                        {
                            MS = Number(cell.childNodes[j].value);
                        }
                        scr.value = parseFloat(scr.value) + parseFloat(MS);
                    }
                }
            } 

            if(scr.value != Number(100))
            {
                if (confirm("Total Score of all the Sections is not equal to 100. Do you want to continue ?"))
                {
                    document.getElementById('hdsave').value=1  ;                 
                }
                else
                {
                    document.getElementById('hdsave').value=0 ;     
                }
            }
        }
        catch (exception) 
	    { 
		    alert(exception + s ); 
	    }
    }
    
    
    
//Name : fnValEq
//Objective  : Function to Calculate check Decilmal point 
//Used in    : Base SCORE Screen
//Created on : 25/10/2010
//Created By : Prasanti
function fnValEq(obj)
{
	
	if ((obj.length)!=0)
	{
		var temp = new Array();
		temp = obj.value.split(".");

		if ( temp.length == 1 || temp.length == 2)
		{
			var prec = temp[0];
			var dec = temp[1];

			if (eval(prec) > 100)
			{
				alert("Notification: Value must not exceed 100.");
                obj.focus();
			    obj.value = "";
				return false;
			}
			else if (dec !=undefined)
			{
				if (eval(prec) == 100)
				{
					alert("Notification: Value must not exceed 100.");
                    obj.focus();
			        obj.value = "";
					return false;
				}
				else if (dec.length > 2)
				{
					alert("Notification: Only two digits are allowed after the decimal point.");
                    obj.focus();
			        obj.value = "";
					return false;
				}
			}
			return true;
		}	//temp.length End
		else if (temp.length > 1)
		{
			alert("Notification: Only one decimal point is allowed.");
            obj.focus();
		    obj.value = "";
			return false;
		}
		else 
		{
			return true;
		}
	}	//if ((obj.length)!=0) End
}	//Function End


//Name : isNumberdrop
//Objective  : Function to allow only Numbers 
//Used in    : Base SCORE Screen
//Created on : 27/10/2010
//Created By : Vijayaraj M
function isNumberondrop(obj)
{        
        numlen=obj.value.length;         
        formatnumlen=FormatClean(obj.value).length;       
         if (formatnumlen < numlen)
        {
			alert("Notification: Please enter numeric values only");
            obj.focus();
            obj.select();
			return false;
        }//End of if (FormatClean(obj.value).length > Digit)               

         return true;
}

//Name          : isNumberNeg
//Objective     : Function to allow only Numbers, -, , and .(decimal)
//Used in       : Generic Function, it can be used in any screen
//Created on    : 27/10/2010
//Created By    : Vijayaraj M
function isNumberHypComaDec(evt,obj)
{
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (obj.value != '')
        {
            if (charCode == 45 && obj.value.lastIndexOf("-") == 0) 
            {
                return false;       
            }
        }
         if (charCode == 46 || charCode == 45 || charCode == 44)
			return true;
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

//Name          : isDecimal
//Objective     : Function to Check Decimal
//Used in       : Generic Function, it can be used in any screen
//Created on    : 27/10/2010
//Created By    : Vijayaraj M
function isDecimal(num)
{
     var sVal='';
     var nVal = num.length;
     var sChar='';
   try
   {
      for(i=0;i<nVal;i++)
	  {
         sChar = num.charAt(i);
         nChar = sChar.charCodeAt(0);
        if ((nChar >=48) && (nChar <=57) || (nChar==46))
        { 
			sVal += num.charAt(i);   
        }
      }
    }
   catch (exception) 
	{ 
		AlertError("isDecimal",e); 
	}
    return sVal;
}
//Name          : isDecimal
//Objective     : Function to Remove Commas
//Used in       : Generic Function, it can be used in any screen
//Created on    : 27/10/2010
//Created By    : Vijayaraj M
function fnRemoveComma(obj)
{        
      var comalen=((obj.value.split(",")).length)-1;                     
     if(comalen>0)
     {
        for(i=0;i<comalen;i++)
            obj.value=obj.value.replace(",","");
     }               
}
//Name          : isDecimal
//Objective     : Function to Add Commas
//Used in       : Generic Function, it can be used in any screen
//Created on    : 27/10/2010
//Created By    : Vijayaraj M
function CommaFormatted(amount)
{
    
	var delimiter = ","; // replace comma if desired
	var a= amount.split('.',2);	
	var d='';	
	var i;   
	if((amount.split('.').length)>1)
	     d = a[1];
	if((a[0].length)<1)	 return 0 + "." + d;  else i= parseInt(a[0],10); //Modified by HariKrishna on 22/Dec/2010
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	 
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	
	amount = minus + amount;
	
	return amount;
}
// end of function CommaFormatted()




