// JScript File

        function checkall()
        {
            for(intCounter=0; intCounter<(document.getElementsByName('chkBox').length); intCounter++)
		    {		        
			    document.getElementsByName("chkBox")[intCounter].checked = document.getElementById("chkAll").checked;
		    }
        }
        
        function checkManual()
        {
             var intCheckVal;
            intCheckVal = 1;
            for(intCounter=0; intCounter<(document.getElementsByName('chkBox').length); intCounter++)
		    {
			    if(document.getElementsByName("chkBox")[intCounter].checked == false)
			        intCheckVal = 0;
		    }
		    if(intCheckVal == 1)
		        document.getElementById("chkAll").checked = true;
		    else
		        document.getElementById("chkAll").checked = false;
        }
        
        function ConfirmForDelete()
        {
            return confirm('Are you sure you want to delete Record(s)?');
        }
        function confirmforDeletecategory()
        {
          return confirm('Are you sure you want to delete this category. Maybe the category has clinics.');
        }
        
        function ConfirmForMessage(msgType)
        {
            return confirm('Are you sure you want to '+msgType+' Record?');
        }
        
        function ConfirmForReset()
        {
            return confirm('Are you sure you want to Reset Password?');
        }
        
        function selected(string)
        {           
            var intCountControls=0;
            for(intCounter=0; intCounter<(document.getElementsByName('chkBox').length); intCounter++)
            {               
                if(document.getElementsByName("chkBox")[intCounter].checked == true)
                {
                   intCountControls++;
                }
            }
            if(intCountControls == 0)
            {            
                if (string == "delete")
                    alert('Please Select a Record(s) to delete.');
                else if (string == "active")
                    alert('Please Select a Record(s) to change the status.');
                else if (string == "inactive")
                    alert('Please Select a Record(s) to change the status.');
                else if (string == "archiv")
                    alert('Please Select a Record(s) to archive.');                
                return false;
            }    
            else if(intCountControls > 0)
            {         
                if (string == "delete")
                {            
                   return confirm('Are you sure you want to delete Record(s)?');
                }
                else if(string=="active")
                {
                   return confirm('Are you sure you want to active Record(s)?');
                }  
                else if (string=="inactive")        
                {
                   return confirm('Are you sure you want to inactive Record(s)?');                   
                }
                 else if (string == "archiv")
                 {
                    alert('Are you sure you want to archive Record(s)?.');
                 }
            }
        }
        
        
        function IsNumeric(val)        
        {
            var strValidChars = "0123456789.";//"0123456789.-";
            var strChar;
            var blnResult = true;

            if (val.length == 0) 
                return false;
            
            for (i = 0; i < val.length && blnResult == true; i++)
            {
              strChar = val.charAt(i);
              if (strValidChars.indexOf(strChar) == -1)
              {
                 blnResult = false;
              }
            }
            return blnResult;
        }
        
        function IsValidInt(val)        
        {
            var strValidChars = "0123456789";//"0123456789.-";
            var strChar;
            var blnResult = true;

            if (val.length == 0) 
                return false;
            
            for (i = 0; i < val.length && blnResult == true; i++)
            {
              strChar = val.charAt(i);
              if (strValidChars.indexOf(strChar) == -1)
              {
                 blnResult = false;
              }
            }
            return blnResult;
        }
        
         function IsPhoneNumber(val)        
        {
            var strValidChars = "0123456789.()+-";//"0123456789.-";
            var strChar;
            var blnResult = true;

            if (val.length == 0) 
                return false;
            
            for (i = 0; i < val.length && blnResult == true; i++)
            {
              strChar = val.charAt(i);
              if (strValidChars.indexOf(strChar) == -1)
              {
                 blnResult = false;
              }
            }
            return blnResult;
        }
        
        function IsAlphabetic(val)
        {
            if (val.match(/^[a-zA-Z ]+$/))
            {
                return true;
            }
            else
            {
                return false;
            } 
        }
       
        function IsAlphaNumeric(val)
        {
            if (val.match(/^[a-zA-Z0-9 .,;]+$/))
            {
                return true;
            }
            else
            {
                return false;
            } 
        }   
        
        
        function IsValidEmail(EmailString)
        {
            var FilterString=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	        if (FilterString.test(EmailString))
                return true;
            return  false;
        }
        
        function IsValidURL(url)
        {
            var RegExp = /^(ftp|https?):\/\/+(www\.)+[a-z0-9\-\.]{3,}\.[a-z]{2,4}$/;
            if(RegExp.test(url))
            {
                return true;
            }
            else
            {
                return false;
            }
        } 
        
        function IsValidImageFile(FileName)
        {
            var RegExp = /^(.*?)\.(jpg|jpeg|gif|bmp)$/;
            if(RegExp.test(FileName))
            {
                return true;
            }
            else
            {
                 return false;
            }    
        } 
        
        function IsValidVideoFile(FileName)
        {
            var RegExp = /^(.*?)\.(wmv|WMV|flv|FLV|mpeg|MPEG|mpg|MPG|mp4|MP4|mov|MOV)$/;
            if(RegExp.test(FileName))
            {
                return true;
            }
            else
            {
                 return false;
            }    
        }
        
        function Trim(OriString) 
        {
            while ((OriString.substring(0,1) == ' ') || (OriString.substring(0,1) == '\n') || (OriString.substring(0,1) == '\r'))
            {
                OriString = OriString.substring(1,OriString.length);
            }
            while ((OriString.substring(OriString.length-1,OriString.length) == ' ') || (OriString.substring(OriString.length-1,OriString.length) == '\n') || (OriString.substring(OriString.length-1,OriString.length) == '\r'))
            {
                OriString = OriString.substring(0,OriString.length-1);
            }
            return OriString;
        } 

        function PopItUp(URL)
        {
            newwindow=window.open(URL,'name','height=200,width=200,left=500,top=250,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
            if (window.focus)
            {
                newwindow.focus();
            }
            return false;
        } 
        
        function PopUpWindow(URL)
        {
            newwindow=window.open(URL,'name','height=500,width=450,left=500,top=250,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1');
            if (window.focus)
            {
                newwindow.focus();
            }
            return false;
        } 
        
        function PopUpWindow(URL,Width,Height)
        {
            newwindow=window.open(URL,'name','height=' + Height + ',width=' + Width + ',left=500,top=250,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1');
            if (window.focus)
            {
                newwindow.focus();
            } 
            return false;          
        } 
        
         function PopUpWindow(URL,Name,Width,Height)
        {
            newwindow=window.open(URL,name,'height=' + Height + ',width=' + Width + ',left=500,top=250,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1');
            if (window.focus)
            {
                newwindow.focus();
            } 
            return false;          
        } 
        
        function IsValidDigit(events)
        {   
	        val = events.charCode? events.charCode :events.keyCode;
	        
	        if(val<48 && val!=46 && val != 8)
	          return false;
	        if(val>57)
	          return false;
	        return true;
        } 
        
        function IsValidQty(events)
        {             
	        val = events.charCode? events.charCode :events.keyCode;
	        
	        if((val<48 && val != 8) || val==46)
	          return false;	        
	        if(val>57)
	          return false;
	        return true;
        }   
        

function Highlight(e)
        {
	        if(e.className!="raw_selectedcolor")
		        e.className="raw_mouseoverbg";
        }
        
        function UnHighlight(e,classname)
        {
        //	alert(e.className)
	        if(e.className!="raw_selectedcolor")
		        e.className=classname;
        }
        
        function showhiderght(tdid)
        {           
            if(document.getElementById(tdid).style.visibility == "visible")
            {
                document.getElementById(tdid).style.visibility = "hidden";
                document.getElementById(tdid).style.display = "none";
                document.getElementById('rghtimg').src='images/left-arrow.gif';
            }
            else
            {                
                document.getElementById(tdid).style.visibility = "visible";
                document.getElementById(tdid).style.display = "";
                document.getElementById('rghtimg').src='images/right-arrow.gif';
            
            }
        }
        
        
        
        // it validates the input string as per masked '(__)____-_____
        function ValidMaskedPhone(maskedNumber)
        {
            try
            {   
                 maskedNumber = maskedNumber.replace(/_/g,'');
                 
                 if(maskedNumber.length == 3)
                 {
                    return true;
                 }                 
                 return false;                 
            }
            catch(err)
            {
            }
            
        }
        
        
    function KeyNumeric(e)
    {	
	    var KeyID = (window.event) ? event.keyCode : e.which;	
    
	    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) ||
	        (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) ) 
        {
		    return false;
	    }
	    if(KeyID == 32)
	    {
	        return false;
	    }	
    }
    
    function ShowPopUpWindow(url,windowtitle)
    {
        window.open(url,windowtitle,'resizable=yes,scrollbars=yes,width=450,height=450,left=150,top=50,status=yes');      
    }
    function selected(string)
{           
    var intCountControls=0;
    for(intCounter=0; intCounter<(document.getElementsByName('chkBox').length); intCounter++)
    {               
        if(document.getElementsByName("chkBox")[intCounter].checked == true)
        {
           intCountControls++;
        }
    }    
    if(intCountControls == 0)
    {  
        if (string == "delete")
        alert('Please select record(s) to delete');
        else if(string == "deleteassociation")
            alert('Please select record(s) to delete association');
       else if(string=="changesssociation")
            alert('Please select record(s) to reset association');
       else if (string == "inactive")
            alert('Please select record(s) to change the status');
        else if (string == "new")
            alert('Please select record(s) to change the status');
        else if (string == "approve")
            alert('Please select record(s) to change the status');
        else if (string == "deny")
            alert('Please select record(s) to change the status');
        else if (string == "success")
            alert('Please select record(s) to change the status');
        else if (string == "fail")
            alert('Please select record(s) to change the status');
        else if (string == "unasaign")
            alert('Please select record(s) to change the status');
        return false;
    }   
    else if (intCountControls > 1000)
    {
        if (string == "delete")
            alert('You can delete only 1000 Records at a time.');
        else if(string == "deleteassociation")
            alert('You can delete only 1000 Records at a time');
        else if(string=="changesssociation")
             alert('You can change only 1000 Records at a time');
        else if (string == "active")
            alert('You can active only 1000 Records at a time.');
        else if (string == "inactive")
            alert('You can inactive only 1000 Records at a time.');
        else if (string == "new")
            alert('You can make new only 1000 Records at a time.');
        else if (string == "approve")
            alert('You can approve only 1000 Records at a time.');
        else if (string == "deny")
            alert('You can deny only 1000 Records at a time.');
        else if (string == "success")
            alert('You can make success only 1000 Records at a time.');
        else if (string == "fail")
            alert('You can make fail only 1000 Records at a time.');
        else if (string == "unasaign")
            alert('You can unasaign only 1000 Records at a time.');
        return false;
    } 
    else if(intCountControls > 0)
    {         
         if (string == "delete")
        {            
           return confirm('You are about to delete selected clinics. Are you sure?');
        }
        else if(string == "deleteassociation")
        {
            return confirm('You are about to delete selected association. Are you sure?');
        }
        else if(string=="changesssociation")
        {
           return confirm('You are about to reset selected associations. Are you sure?');
        }  
        else if (string=="inactive")        
        {
           return confirm('Are you sure you want to inactive record?');
        }
        else if (string == "new")
        {            
           return confirm('Are you sure you want to merk these as New?');
        }
        else if(string=="approve")
        {
           return confirm('Are you sure you want to mark these as Approved?\n');
        }  
        else if (string=="deny")        
        {
           return confirm('Are you sure you want to mark these as Denied?\n');
        }          
        else if(string=="success")
        {
           return confirm('Are you sure you want to mark these as a Success?');
        }  
        else if (string=="fail")        
        {
           return confirm('Are you sure you want to mark these as Failed?');
        }          
        else if (string=="unassign")        
        {
           return confirm('Are you sure you want to mark these as Unassign?');
        }          
    }
}
    
   
