﻿// JScript File

//js script for the button click 
function clickButton(e, buttonid){ 
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      }
} 

//JS to focus to next control
function FocusToNext(event,control)
    {
      if(event.which || event.keyCode) 
        {
            if ((event.which == 13) || (event.keyCode == 13))
                  {
                    document.getElementById(control).Focus();
                    return false;
                  }
                 
           
        }
       
           return true ;    
     }  

//JS to Valiadet Text Start
function ValidateText()
{

    var ctrl=document.getElementsByTagName("input");
    //TextBox Validation
    //&& ctrl[i].name.tolower().indexof('txtphone') <0
    for (i=0;i<ctrl.length;i++)
    {
        if(ctrl[i].type=="text" && ctrl[i].id!='ctl00_cphAdmin_txtLongitude' && ctrl[i].id!='ctl00_cphAdmin_txtPhone' && ctrl[i].id!='ctl00_cphAdmin_txtMobile' && ctrl[i].id!='ctl00_cphAdmin_Ctrlmember1_txtPhone' && ctrl[i].id!='ctl00_cphAdmin_Ctrlmember1_txtFax' && ctrl[i].id!='ctl00_cphDetails_Ctrlclientuser1_txtPhone' && ctrl[i].id!='ctl00_cphDetails_Ctrlclientuser1_txtFax' && ctrl[i].id!='ctl00_cphAdmin_Ctrlmember1_txtMobile' && ctrl[i].id!='ctl00_cphAdmin_txtFax')
             {
             if (document.getElementById(ctrl[i].id).value.length>0)
                {
                    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
                    if (iChars.indexOf(document.getElementById(ctrl[i].id).value.charAt(0)) != -1)
                    {
                        alert ("Special characters are not allowed at the beginning of the text.\n Please remove them and try again.");
                        document.getElementById(ctrl[i].id).select();
                        return false;
                    }
                }
            }
     }

//TextArea Validation .....
    ctrl=document.getElementsByTagName("textarea");
    for (i=0;i<ctrl.length;i++)
    {
        if (document.getElementById(ctrl[i].id).value.length>0)
        {
            var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
            if (iChars.indexOf(document.getElementById(ctrl[i].id).value.charAt(0)) != -1)
            {
                alert ("Special characters are not allowed at the beginning of the text.\n Please remove them and try again.");
                document.getElementById(ctrl[i].id).select();
                return false;
            }
        }
    }


 return true;

}


/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
-------------------------------------------------------------
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
-------------------------------------------------------------
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


 