﻿// JScript File

function changeImages(arg1,arg2,ext)
{
if(document.images)
{
document.getElementById(arg1).src=arg2+((ext!=undefined)?ext:'');
}
}

function ChangeImage(ControlID,NewImage,ext)
{
    var objcontrolid = new String;
    var objimage = new String;
    objcontrolid = 'ctl00_ContentPlaceHolder1_' + ControlID;
    objimage = '/Web/Img/Buttons/'+ NewImage +((ext!=undefined)?ext:'.gif');
    var objcontrol = document.getElementById(objcontrolid);
    objcontrol.src = objimage;
}


function ChangeImage1(ControlID,NewImage)
{
    var objcontrolid = new String;
    var objimage = new String;
    objcontrolid =  ControlID;
    objimage = '/Web/Img/Buttons/'+ NewImage + '.gif'
    var objcontrol = document.getElementById(objcontrolid);
    objcontrol.src = objimage;
}


function ConfirmDelete()
{
return confirm('Do You Want To Delete This Record?'); 
}

function OpenWindow(StrLink)
	{
	window.open(StrLink,"_blank","resizable=yes,height=375,width=567,scrollbars,toolbar=yes");	
	
	} 

function OpenWindowWithoutPostBk(StrLink)
	{
	window.open(StrLink,"_blank","resizable=yes,height=375,width=567,scrollbars,toolbar=yes");
	return false;	
	
	} 
	
	function OpenBlankWindowWithoutPostBk(StrLink)
	{
	window.open(StrLink,"_blank","resizable=yes,height=375,width=567,scrollbars,toolbar=yes");
	return false;	
	
	} 
	
function CloseWindow()
{
	window.close();
}
/////////////////////////////////////////////////////////////
//          Author: Vishram Margaj
 // Fuction used to populate dropwdown on the ONCHANGE Attributes of another DropDown  
      
      var req;
      var objtoPoplulate,objtoSetValue,ValueField,TextField,AsDrp,objFunction;
     
      function PopulateDrpDwn(obj,obj1,obj2,Function,Parameter,Column1,Column2)
		{
		//alert("in");
		objtoPoplulate=obj1;               //DropDown Which you want to populate
		objtoSetValue=obj2;                // HiddenVariable in which yoy want to store selected value of objtoPoplulate
		ValueField=Column1;                // Column Name of ds which you want as value of DropDown
		TextField=Column2;                 // Column Name of ds which you want as text of DropDown
		objFunction=Function;
		AsDrp=obj;
		var Code;
		var count;
				count=document.getElementById(obj.id).length 
	     for(i=0;i<count;i++)
		 {
		  
		  if (document.getElementById(obj.id).options[i].selected == true)
		  {
		  
		   Code=document.getElementById(obj.id).options[i].value;   // code to find selected value of DropDown i.e. from which we want to populate another dropdown
		  }
	     }
	       loadXMLDoc('/web/' + 
          'WebService/PopulateData.asmx/'+ Function +'?'+ Parameter + '=' + Code )
	   }
      
      function loadXMLDoc(url) 
       {
        //branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) 
        {
         req = new XMLHttpRequest();
         req.onreadystatechange = processReqChange;
         req.open("GET", url, true);
         req.send(null);
        //branch for IE/Windows ActiveX version
        } 
         else if (window.ActiveXObject) 
        {
		  isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
          }
       }
     }
    
    function processReqChange() 
     {
     //alert("IN PROCESS");
      var response,count,totalCld,i;
      var Value,Text;
      if (req.readyState == 4) 
       {
         if (req.status == 200) 
          {
          	response  = req.responseXML.documentElement;
			totalCld=response.getElementsByTagName(ValueField).length   //gives length of child nodes
		    Count=document.getElementById(objtoPoplulate.id).length;
	   
	   // Code to remove old records from State DropDown
	        for(i=0;i< Count ;i++)
	         {
	         document.getElementById(objtoPoplulate.id).remove(0);
             document.getElementById(objtoPoplulate.id).remove(1);
	         }
		  
	 // Code to Insert records from State DropDown
		    for(i=0;i < totalCld ;i++)
		     {	
//		      var StrCode,StrText;	
//		      var newOption = document.createElement('<option value=StrCode>');
//			  document.getElementById(objtoPoplulate.id).options.add(newOption);
//		       if(i==0)
//		       {
//		       StrCode="All";
//		       StrText="All";
//		       }
//		       else
//		       {
//		        StrCode=response.getElementsByTagName(ValueField)[i-1].firstChild.data;
//		        StrText=response.getElementsByTagName(TextField)[i-1].firstChild.data;
//		        }
//		           if(StrCode != null)
//			       {
//			        newOption.text = StrText;
//			       newOption.value=StrCode;
//			        }

              var StrCode,StrText;
              StrCode=response.getElementsByTagName(ValueField)[i].firstChild.data;
	          StrText=response.getElementsByTagName(TextField)[i].firstChild.data;
	         
              if(StrCode != null)
	           {	
	           var newOption = document.createElement("Option");
			   document.getElementById(objtoPoplulate.id).options.add(newOption);
			   newOption.text = StrText;
		       newOption.value=StrCode;
		       }
			  }
	         
	       if(document.getElementById('ctl00_ContentPlaceHolder1_HdnCopyAddress')&& (document.getElementById(AsDrp.id).id)==(document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnCurCountry').id))
	       	{
	       	     if(document.getElementById('ctl00_ContentPlaceHolder1_chkASAbove').checked == true)
	       	     {
	                var clength,plength,country,Countper;      
                     clength=document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnCurCountry").length;
			     
	                for(i=0;i<clength;i++)
		             {
		              if (document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnCurCountry").options[i].selected == true)
		                 {
		                country = document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnCurCountry").options[i].value;
		                  }
	                   }
	
			             plength=document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerCountry").length;
			     
	                   for(i=0;i < plength;i++)
		                {
		                 if (document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerCountry").options[i].value == country)
		                  {
		                  document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerCountry").options[i].selected=true;
		                    document.getElementById("ctl00_ContentPlaceHolder1_HdnPerCountry").value=country;
		                  }
	                   }
	               Countper=document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').length;
	   
	 
	        for(i=0;i< Countper ;i++)
	         {
	           document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').remove(0);
	           document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').remove(1);
	         }
	                for(i=0;i < totalCld ;i++)
	       		   {
	       		   var StrCodeper,StrTextper;
              StrCodeper=response.getElementsByTagName(ValueField)[i].firstChild.data;
	          StrTextper=response.getElementsByTagName(TextField)[i].firstChild.data;
	       			 var newOption1 = document.createElement("Option");
			         document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').options.add(newOption1);
			         newOption1.text = StrTextper;
                     newOption1.value=StrCodeper;    
	               }
	           document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').options[0].selected=true; 
	              SetValue(document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState'),document.getElementById('ctl00_ContentPlaceHolder1_HdnPerState'))  
	       	    }    
	         }
	         
	         document.getElementById(objtoPoplulate.id).options[0].selected=true;
	       		
	          SetValue(objtoPoplulate,objtoSetValue)
	          if (objFunction=="GetStateCodeWithAll")
		      {
		        document.getElementById(objtoPoplulate.id).value ="0"
		      }

		    }
		   } 
         }
        
        function SetValue(obj,obj1)
		  {
		  var count;
		  count=document.getElementById(obj.id).length 
	      for(i=0;i<count;i++)
		   {
		    if (document.getElementById(obj.id).options[i].selected == true)
		    {
		     document.getElementById(obj1.id).value =document.getElementById(obj.id).options[i].value;
		       }
	       }
	            if(document.getElementById('ctl00_ContentPlaceHolder1_HdnCopyAddress')&& (document.getElementById(obj.id).id)==(document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnCurState').id))
	       	{
	       	var Count;
	       	   Count=document.getElementById('ctl00_ContentPlaceHolder1_DrpDwnPerState').length;
	   
	 
	        for(i=0;i< Count ;i++)
	         {
	               
	                if (document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerState").options[i].value == document.getElementById(obj1.id).value)
		                  {
		                  document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerState").options[i].selected=true;
		                    document.getElementById("ctl00_ContentPlaceHolder1_HdnPerState").value=document.getElementById("ctl00_ContentPlaceHolder1_DrpDwnPerState").options[i].value;
		                  }
	               }
	       	
	       	}
	         }
		 
		  
		 function condt(obj) 
		 {
		 
           var dt = new String;
           var DateArr =new String();
           var mm,dd,yy;
           var y;
           var m;
           var d;
           y="false";
           m="false";
           d="false";


          dt= document.getElementById(obj.id).value;

             DateArr =dt.split("/")
             if(DateArr.length ==1)
             {
                DateArr=dt.split("-")
              }
           
           
           if (DateArr[0] > 12 && DateArr[0] > 31 && DateArr[0]>= 1800 && y != "true")
             {
              yy = DateArr[0];
               y = "true";
             }
          
          else if (DateArr[0] <= 12 && m != "true")
           {
            if (DateArr[0].length < 2)
            {
                mm = "0" + DateArr[0];
                }
           else
            {
                mm = DateArr[0];
          }
            m = "true";
        }
            else if (DateArr[0] > 12 && DateArr[0] <=31 && d != "true" )
             {
              if (DateArr[0].length < 2)
               {
                dd = "0" + DateArr[0];
                }
               else
                {
                 dd = DateArr[0];
                } 
             d = "true";
            }
        


         if (DateArr[1] > 12 && DateArr[1] > 31 && DateArr[1]>=1800 && y != "true")
           {
               yy = DateArr[1];
             y = "true";
           }
         
         else if (DateArr[1] <= 12 && m != "true")
       {
       
        if (DateArr[1].length < 2)
            {
            mm = "0" + DateArr[1];
            }
            else
            {
                mm = DateArr[1];
            }
            m = "true";
               }
		 
		  else if (DateArr[1] <=31 && d != "true")
           {
            if (DateArr[1].length < 2)
            {
            dd = "0" + DateArr[1];
            }
            else
            {
               dd = DateArr[1];
            }
            d = "true";
            }
		  
		 if (DateArr[2] <= 12 && m != "true")
       {
            if (DateArr[2].length < 2)
            {
                mm = "0" + DateArr[2];
                }
            else
            {
                mm = DateArr[2];
          }
            m = "true";
      }
      
        else if (DateArr[2] <=31 && d != "true")
        {
            if (DateArr[2].length < 2)
            {
            dd = "0" + DateArr[2];
            }
            else
            {
                dd = DateArr[2];
           }
            d = "true";
            }
            
       else if (DateArr[2] > 12 && DateArr[2] > 31 && DateArr[2]>=1800 && y != "true")
        {
             yy = DateArr[2];
             y = "true";
         }
         
                 if (d =="false" || m =="false" || y =="false")
        {
         alert("invalid date");
         document.getElementById(obj.id).value="";
         }
         
         else
         {
         document.getElementById(obj.id).value=mm+"/"+dd+"/"+yy
         }
         var newDate=new String;
          var ValidDateArr =new String();
          newDate=mm+"/"+dd+"/"+yy;
          
         ValidDateArr=newDate.split("/");
         if(ValidDateArr[0] < 8 && ValidDateArr[0]% 2 != 0 )
           {
             if(ValidDateArr[1]>31)
             {
               alert("Invalid Date");
               document.getElementById(obj.id).value="";
             }
          }
          else if(ValidDateArr[0] < 8 && ValidDateArr[0]% 2 == 0)
          {
             if(ValidDateArr[0]== 2 )
               {
                if(ValidDateArr[2]% 4 ==0)
                  {
                    if(ValidDateArr[1]>29)
                     {
                        alert("Invalid Date");
                        document.getElementById(obj.id).value="";
                     }
                  } 
                else
                 {
                   if(ValidDateArr[1]>28)
                    {
                      alert("Invalid Date");
                      document.getElementById(obj.id).value="";
                    }
                 }
              }
             else if(ValidDateArr[1]>30)
              {
                alert("Invalid Date");
                document.getElementById(obj.id).value="";
              }
           }
           
         else if(ValidDateArr[0] > 8 && ValidDateArr[0]% 2 != 0 )
            {
           if(ValidDateArr[1]>30)
            {
               alert("Invalid Date");
               document.getElementById(obj.id).value="";
            }
          }
       
         else if(ValidDateArr[0] >= 8 && ValidDateArr[0]% 2 != 0 )
            {
           if(ValidDateArr[1]>31)
            {
               alert("Invalid Date");
               document.getElementById(obj.id).value="";
            }
          }
         
      }
         
         // function to populate BirthDay dropdown on the ONCHANGE attributes of BirthYear and BirthMonth
var ObjDay,ObjHdn;
 function PopulateBDays(obj,obj1,obj2,obj3)
		{
		ObjDay=obj2;
		ObjHdn=obj3;
	 	    var Year_Code,Month_Code;
		    var Y_count,M_Count;
		    Y_count=document.getElementById(obj.id).length;
		    M_Count=document.getElementById(obj1.id).length;
	     
	     for(i=0;i<Y_count;i++)
		  {
		   if (document.getElementById(obj.id).options[i].selected == true)
		    {
		     Year_Code=document.getElementById(obj.id).options[i].value;
		    }
	      }
		 
		 for(i=0;i<M_Count;i++)
		  {
		   if (document.getElementById(obj1.id).options[i].selected == true)
		    {
		     Month_Code=document.getElementById(obj1.id).options[i].value;
		    }
	      }
	       loadDoc('/web/' + 
          'WebService/PopulateData.asmx/GetBirthDay?Year='+ Year_Code +'&Month='+Month_Code );
	   }
       
      function loadDoc(url) 
       {
   	   //branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) 
        {
         req = new XMLHttpRequest();
         req.onreadystatechange = processChange;
         req.open("GET", url, true);
         req.send(null);
        //branch for IE/Windows ActiveX version
        } 
         else if (window.ActiveXObject) 
        {
		  isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
            req.onreadystatechange = processChange;
            req.open("GET", url, true);
            req.send();
          }
       }
     }
    
    function processChange() 
     {
      var response,count,totalCld,i;
      var Value,Text;
      if (req.readyState == 4) 
       {
         if (req.status == 200) 
          {
          	response  = req.responseXML.documentElement;
			totalCld=response.getElementsByTagName('Birth_Day').length   //gives length of child nodes
		    Count=document.getElementById(ObjDay.id).length;
		   
		   for(i=0;i< Count ;i++)
		  {
		   document.getElementById(ObjDay.id).remove(0);
	       document.getElementById(ObjDay.id).remove(1);
	       }
		
	 // Code to Insert records from State DropDown
		    for(i=0;i < totalCld ;i++)
		     {		
		       var StrCode,StrText;
		       StrCode=response.getElementsByTagName('Day_Value')[i].firstChild.data;
		       StrText=response.getElementsByTagName('Birth_Day')[i].firstChild.data;
		       if(StrCode != null)
			     {
			       var newOption = document.createElement("Option");
			       document.getElementById(ObjDay.id).options.add(newOption);
			       newOption.text = StrText;
			       newOption.value=StrCode;
			    }
	         }
	         localSetValue(document.getElementById(ObjDay.id),document.getElementById(ObjHdn.id))
		    }
		   } 
         }
        
        function localSetValue(obj,obj1)
		  {
		  var count;
		  count=document.getElementById(obj.id).length 
	      for(i=0;i<count;i++)
		   {
		    if (document.getElementById(obj.id).options[i].selected == true)
		    {
		     document.getElementById(obj1.id).value =document.getElementById(obj.id).options[i].value;
		    }
	       }
		  }
		  
/////////////////////////////////////////////////////////////
//          Function Name: ChangeMenuImages()
//          Author: Mahendra M.Bhatt
//          Purpose: This function changes menu images i.e. restores the images which are clicked previously
//          Parameters:
//          1. argid : Id of the menu clicked
//          2.strSession : Session variable which decides the menu items
//          Create Date: 01 Feb 2007
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////

function ChangeMenuImages(argid,strsession)
{
    if (strsession==1 || strsession==3)
    {
        count = 4;
    }
    else if (strsession==2)
    {
        count = 4;
    }
    for(i=0;i<=count;i++)
    {
        if(i != argid)
        {
            var str = new String;
            var obj = document.getElementById(i);
            str = obj.src;
            if (str.lastIndexOf("_") > 0)
            {
                obj.src = str.substring(0,str.lastIndexOf("_"))+'.gif';                
            }
        }
    }
}

    function SetData(Idh_ID,FtpPath,UName,Pwd,FtpFolder,LPath)
    {
        var i;
        var j;
        var CntrlFp,CntrlDh,CntrlCaptureData;
        var OldImg,NewImg,bool;
        bool="0";
        for(i=1;i<3;i++)
        {
            for(j=0;j<5;j++)
            {
                //CntrlFp="ctl00_ContentPlaceHolder1_HdnFP_" + i + "_" +  j;
                CntrlDh="ctl00_ContentPlaceHolder1_HdnDHID_" + i + "_" +  j;
                CntrlCaptureData="ctl00_ContentPlaceHolder1_HdnStrFp_" + i + "_" +   j;
                if(document.getElementById(CntrlCaptureData))
                { 
                    //alert(document.getElementById(CntrlCaptureData).value);
                    if(document.getElementById(CntrlCaptureData).value !="")
                    {
                        document.getElementById(CntrlDh).value= Idh_ID + "_" + i + "_" +  j;
                        //document.getElementById(CntrlFp).value=document.getElementById(CntrlCaptureData).value;
                       
                        OldImg = LPath + "/New_"+ i + "_" + j + ".bmp"
                        NewImg = FtpFolder + Idh_ID + "_" + i + "_" + j + ".bmp"
                        document.FingerPrint.UploadFile(FtpPath,UName,Pwd,OldImg,NewImg,'cptrfp'); 
                        bool="1";
                    }
                   
                }
            }      
        }
        
        if(bool=="0")
        {
            alert("Please Capture Atleast One Finger Print To Save.")
            return false;
        }
        else
        {
            return true;
        }
    }
    
     
//     function CreateFolder(Lpath)
//      {
//       //alert(Lpath);
//        var fso; 
//        fso  = new ActiveXObject("Scripting.FileSystemObject");
//        
//       if(fso.FolderExists(Lpath) == false)
//       {  
//           fso.CreateFolder(Lpath);
//       }
//       
//       return false;
//      }  
      
      function SetVerifyData()
      {
             //alert(document.getElementById("ctl00_ContentPlaceHolder1_HdnStrIdentify").value);
            if(document.getElementById("ctl00_ContentPlaceHolder1_HdnStrIdentify"))
            { 
                if(document.getElementById("ctl00_ContentPlaceHolder1_HdnStrIdentify").value !="")
                {
                    //alert(document.getElementById("ctl00_ContentPlaceHolder1_HdnStrIdentify").value);
                    //document.getElementById("ctl00_ContentPlaceHolder1_HdnSrchFP").value=document.getElementById("HdnStrIdentify").value;
                    return true;
                }
                else
                {
                    alert("Please Capture Finger Print To Verify")
                    return false;
                }
                   
            }
      }
      
      /////////////////////////////////////////////////////////////
//          Function Name: DoToggelPanel
//          Author: Beena Shah
//          Purpose: This function toggels the panel visible and invisible
//          Parameters:
//          1. ImageId: Image id on click of which panel should toggle
//          2. DivId  : Div id which should toggle 
//
//          Create Date: 25 May 2006
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
function DoToggelPanel(ImageId,DivId)
{
    DivId="ctl00_ContentPlaceHolder1_"+DivId;
    if (document.getElementById(DivId).style.display=="none")
    {
        document.getElementById(DivId).style.display="";
        ChangeImage(ImageId,"uparrow");
    }
    else
    {
        document.getElementById(DivId).style.display="none";
        ChangeImage(ImageId,"downarrow");
    }
}


function NavigateURL(url){
    window.location = url;
    return false;
}
//Added By Himabindu
//Date:09-09-2008 Phone format like XXX-XXX-XXXX
var newtext;
var s=new String;
function PhoneFormat(obj,evt)
  {
    var FmtStr="";
    var index = 0;
    var LimitCheck;
    var s=document.getElementById(obj.id).value;
    var evt= (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);

   var selectedText = document.selection;
   if(charCode!=8 & charCode!=46 & charCode !=37 & charCode!=35 & charCode !=36 & charCode !=16 & charCode !=39 & selectedText.type != 'Text')
   {
    if(document.selection)
    {
        LimitCheck = s.length;
        while (index != LimitCheck)
       {
              if (isNaN(parseInt(s.charAt(index))))
              {}
             else
             {
                 FmtStr = FmtStr + s.charAt(index); }
                 index = index + 1;
            }
       
            if (FmtStr.length == 10)
            {
                 FmtStr =FmtStr.substring(0,3) +"-" + FmtStr.substring(3,6) + "-" + FmtStr.substring(6,10);
                 document.getElementById(obj.id).value=FmtStr;
            }
      
        }
        
        }
    return FmtStr;

  }
  
//Added By Himabindu On 03-10-2008
//Desc: For Setting the Maxlength of textarea.

function SetMaxLength(obj, Maxlen)
 {

    if (obj.value.length > Maxlen)
    {
        obj.value = obj.value.substring(0, Maxlen);
    } 
}


function getPageEventCoords(evt) {

var coords = {left:0, top:0};
    evt = (evt) ? evt : event;
    if (evt.pageX) {
        coords.left = evt.pageX;
        coords.top = evt.pageY;
    } else if (evt.clientX) {
        coords.left = evt.clientX + document.body.scrollLeft - document.body.clientLeft;
        coords.top = evt.clientY + document.body.scrollTop - document.body.clientTop;
        // include html element space, if applicable
        if (document.body.parentElement && document.body.parentElement.clientLeft) {
            var bodParent = document.body.parentElement;
            coords.left += bodParent.scrollLeft - bodParent.clientLeft;
            coords.top += bodParent.scrollTop - bodParent.clientTop;
        }
    }

    return coords;
}


function setColor(evt,obj){
    var coords = getPageEventCoords(evt);
    var strHTML = '<table cellspacing="2" cellpadding="2" style="border:solid 1px #808080;" width="100%">';
        strHTML += '<tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#993300; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#003366; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#000080; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#333399; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#800000; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ff6600; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr><tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#808000; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#008000; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#008080; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#0000ff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#666699; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#808080; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr><tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#ffff99; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ccffcc; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ccffff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#99ccff; height:15px; width:15px; " onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#cc99ff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#aaaaff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#ff0000; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ff9900; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#99cc00; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#339966; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#33cccc; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#3366ff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr><tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#800080; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#999999; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ffffff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ffcc00; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ffff00; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#00ffff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr><tr>';
        strHTML += '<td style="cursor:crosshair; background-color:#00ff00; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#00ccff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#993366; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#c0c0c0; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ffffff; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '<td style="cursor:crosshair; background-color:#ffcc99; height:15px; width:15px;" onmousedown="CallColor(this.style.backgroundColor,'+"'"+obj+"'"+');"></td>';            
        strHTML += '</tr>';
        strHTML += '</table>';
    
    document.getElementById('color').style.display = '';
    document.getElementById('color').style.left = (coords.left-70)+'px';
    document.getElementById('color').style.top = coords.top+18+'px';
    document.getElementById('color').innerHTML = strHTML;
}

function AutoHide(div,mode){
    var tmr = setTimeout('document.getElementById('+"'"+div+"'"+').style.display="none";',5000);;
    if(mode=='Show'){
        clearTimeout(tmr);
    }
}


function CallColor(Col,obj)
{
    document.getElementById('ctl00_ContentPlaceHolder1_'+obj).value = Col;
    document.getElementById('ctl00_ContentPlaceHolder1_HdnColorCode').value = Col;
    document.getElementById('ctl00_ContentPlaceHolder1_tdColor').style.background = Col;
    document.getElementById('color').style.display = 'none';    
}


function getColToHex(colstr){
    colstr = colstr.substring('rgb('.length,colstr.lastIndexOf(')')).split(',');
    var r=colstr[0],g=colstr[1],b=colstr[2];
    var sr = Math.floor(r/16);
    var sr1 = (r - (sr*16));
    var sg = Math.floor(g/16);
    var sg1 = (g - (sg*16));
    var sb = Math.floor(b/16);
    var sb1 = (b - (sb*16));
    var arrcol = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
    var arrcoln = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; 
    for(i=0;i<arrcol.length;i++){
        if(sr==arrcoln[i]){
           sr=arrcol[i];
        }
        if(sr1==arrcoln[i]){
           sr1=arrcol[i];
        }
        if(sg==arrcoln[i]){
           sg=arrcol[i];
        }
        if(sg1==arrcoln[i]){
           sg1=arrcol[i];
        }
        if(sb==arrcoln[i]){
           sb=arrcol[i];
        }
        if(sb1==arrcoln[i]){
           sb1=arrcol[i];
        }
    }    
    var hex = new String();
    hex = sr+sr1+sg+sg1+sb+sb1;   
    return hex;   
}

function ValidateDecimalValue(evt,len,decimalPoint) 
{
    var str = evt.srcElement.value;
    if (!(evt.keyCode == 46 || evt.keyCode == 8 || evt.keyCode == 9 || evt.keyCode == 16 || evt.keyCode == 36 || evt.keyCode == 35 || evt.keyCode == 37 || evt.keyCode == 39)) // User should be allowed to use backspace, delete, shift, home, end, right and left arrow keys
    {
        if(evt.keyCode >= 65 && evt.keyCode <= 90) return false; //User can enter only numeric or decimal values
        var i = str.indexOf(".");
        if (i > 0)
        {
            var val = evt.srcElement.value.split('.');
            if(val[1].length >= decimalPoint) return false; //Allow only till the decimal point given
        }
        if(str.length >= len) return false; //Allow only till the total length given
    }
}
