﻿ 
 /* To  Email Validation In Client Side */
 
 function validate(txtEmailAddress)
     {
       var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
       var address = txtEmailAddress.value;
       var flag=1;
    if (txtEmailAddress.value == "")
        {
          alert('Please Enter Email Address');
          txtEmailAddress.focus();
          flag=0;
        } 
      else if(reg.test(address) == false) 
       {
          alert('Invalid Email Address');
          txtEmailAddress.focus();
          flag=0;
       }
     if(flag == 0)
        {
         return false;
        }
      else
        {
         return true;
        }
      }
      
    /* To  Email Hide the TextBox In Client Side */  
     function disableotheronbodyload()
    {
    
    document.getElementById('txtOtherCategory').style.visibility='hidden';
    } 
      
    function checkothercategory()
    {
    if(document.getElementById('chkOtherCategory').checked==true)
    {
    //alert(document.getElementById("txtOtherCategory").) ;
    document.getElementById('txtOtherCategory').style.visibility='visible';
    }
    else
    {
    document.getElementById('txtOtherCategory').style.visibility='hidden';
    }
    }
    
 
      
  /* To Comapre  Email Ids  In Client Side */
 
 function compare(txtEmailAddress,txtConfirmEmailAddress)
     {
     var flag=1;
     if (txtEmailAddress.value == "")
        {
          alert('Please Enter Email Address For UserName');
          txtEmailAddress.focus();
          flag=0;
        }
    else if (txtConfirmEmailAddress.value == "")
        {
          alert('Please Enter Confirm Email Address');
          txtConfirmEmailAddress.focus();
          flag=0;
        }   
     else if (txtEmailAddress.value != txtConfirmEmailAddress.value )
       {
          alert('Email Addresses Is Not Match');
          txtConfirmEmailAddress.focus();
          flag =0;
       }
      if(flag == 0)
        {
         return false;
        }
      else
         {
         return true;
        }
     }
     
     /* Force the User To Enter Only Numeric Value */
     
     function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if ((charCode != 43) && (charCode != 45) && (charCode != 8) && (charCode != 47) && (charCode != 46) && (charCode < 48 || charCode > 57) ) 
            return false;
            
         return true;
      }
   /* Force the User To Enter Only Character */  
   function isCharKey(evt)
    {
       var charcode=(evt.which) ? evt.which : event.keyCode
       if((charcode!=32) && (charcode!=45) && (charcode!=46) && (charCode != 8) &&  (charcode > 21  || charcode < 19 ) && (charcode<64 || charcode > 90 ) && (charcode < 97 || charcode > 122))
          return false;
       return true;
    }
    
    /*Code to validate website */
    function TovalidateWebAddress(objWebSiteAddress)
    {  
      var companyUrl;  
      var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;  
         if(objWebSiteAddress.value!="") 
            {   
              siteUrl= objWebSiteAddress.value; 
                  if(RegExp.test(siteUrl))
                    {   
                      return true;  
                    } 
                   else
                    { 
                      alert('Please enter valid website');  
                      objWebSiteAddress.focus(); 
                      objWebSiteAddress.value="";
                      return false;
                    }
             }
    }
    
    /* Check For User Select At least One Check Box */
    function CheckItem(sender, args)
      { 
        var chkControlId = document.getElementById('<%= chklistCategory.ClientID%>');
        var options = document.getElementById(chkControlId).getElementsByTagName('input');
        var ischecked=false;
           args.IsValid =false; 
               for(i=0;i<options.length;i++)
                 {
                   var opt = options[i];
                   if(opt.type=="checkbox")
                      {  
                       if(opt.checked)
                          {
                           ischecked= true;
                           args.IsValid = true;
                           }
                       }
                  }
       } 
       
       
       
function moveUpWard(listBoxControlId) 
   {
    var listField;
    listField = document.getElementById(listBoxControlId);
    
   if (listField.length == -1) {  // If the list is empty
         alert("There are no values which can be moved!");
   }
    else
     {
      var selected = listField.selectedIndex;
      if (selected == -1) {
         alert("You must select an entry to be moved!");
      } 
      else 
      {  // Something is selected 
      if ( listField.length == 0 ) {  // If there's only one in the list
            alert("There is only one entry!\nThe one entry will remain in place.");
         }
      else
       {  // There's more than one in the list, rearrange the list order
            if ( selected == 0 ) {
               alert("The first entry in the list cannot be moved up.");
       }
        else
         {
               // Get the text/value of the one directly above the hightlighted entry as
               // well as the highlighted entry; then flip them
               var moveText1 = listField[selected-1].text;
               var moveText2 = listField[selected].text;
               var moveValue1 = listField[selected-1].value;
               var moveValue2 = listField[selected].value;
               listField[selected].text = moveText1;
               listField[selected].value = moveValue1;
               listField[selected-1].text = moveText2;
               listField[selected-1].value = moveValue2;
               listField.selectedIndex = selected-1; // Select the one that was selected before
            }  // Ends the check for selecting one which can be moved
         }  // Ends the check for there only being one in the list to begin with
      }  // Ends the check for there being something selected
   }  // Ends the check for there being none in the list
}
//*********************************************************************

//*********************************************************************
// function moveDownWard is used to move listitem in a listbox towards down
function moveDownWard(listBoxControlId) 
{
    var listField;
    listField = document.getElementById(listBoxControlId);
    
   if ( listField.length == -1) {  // If the list is empty
      alert("There are no values which can be moved!");
   } else {
      var selected = listField.selectedIndex;
      if (selected == -1) {
         alert("You must select an entry to be moved!");
      } else {  // Something is selected 
         if ( listField.length == 0 ) {  // If there's only one in the list
            alert("There is only one entry!\nThe one entry will remain in place.");
         } else {  // There's more than one in the list, rearrange the list order
            if ( selected == listField.length-1 ) {
               alert("The last entry in the list cannot be moved down.");
            } else {
               // Get the text/value of the one directly below the hightlighted entry as
               // well as the highlighted entry; then flip them
               var moveText1 = listField[selected+1].text;
               var moveText2 = listField[selected].text;
               var moveValue1 = listField[selected+1].value;
               var moveValue2 = listField[selected].value;
               listField[selected].text = moveText1;
               listField[selected].value = moveValue1;
               listField[selected+1].text = moveText2;
               listField[selected+1].value = moveValue2;
               listField.selectedIndex = selected+1; // Select the one that was selected before
            }  // Ends the check for selecting one which can be moved
         }  // Ends the check for there only being one in the list to begin with
      }  // Ends the check for there being something selected
   }  // Ends the check for there being none in the list
}
//*********************************************************************

