//Locking all the numbers and special characters
//function chckMaxLength(para){    
//      if (para.value.length>250)
//      {
//        var desc = para.value;
//        var descstr = desc.substring(0,250);
//        var control=para;
//        document.getElementById(control.id).value = descstr; 
//        alert("Maximum length is 250");
//        return false;
//      }
//    }
 
function character_only(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (event) keycode = event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		selected_text = '';
		if(document.selection)
		{
			var selection=document.selection.createRange();
			var selected_text = selection.text;
		}
		
		//keycodes allowed but not in the beginning - space
		if( ( keycode == 32 ) && ( ((e.value).length==0) || selected_text != "") )
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode!=13)  && (keycode!=46) && (keycode!=45) && (keycode!=44)&& (keycode!=39) && (keycode!=34)&& (keycode!=95))
		{
			return false;
		}
		else return true;
	}
	
	//Locking all characters and special characters
	function number_only(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
                  
         
		//keycodes allowed but not in the beginning - 0
		if( keycode == 48 && ((e.value).length==0 || selected_text != "") )
		{
			return false;
		}
		if(!(keycode>=48 && keycode <=57) && (keycode!=13))
		{
			return false;
		}
		else return true;
	}
	
	function chk_number_only(e)
	{
		chr_allow = /[0-9]/g;
		val = e.value;
		val = val.replace(chr_allow,'');
				
		len = val.length;
		val2 = e.value;
		for(i=0;i<len;i++)
		{
			val2 = val2.replace(val.charAt(i),'');
		}
		e.value = val2;
		if(e.value !='' && e.value== 0)
		{
			alert('Invalid Number');
			e.focus();
			return false;
		}
		return false;
	}
	
	function chk_character_number(e)
	{
		chr_allow = /[a-zA-Z0-9 ]/g;
		val = e.value;
		val = val.replace(chr_allow,'');
				
		len = val.length;
		val2 = e.value;
		for(i=0;i<len;i++)
		{
			val2 = val2.replace(val.charAt(i),'');
		}
		e.value = val2;
		
		chk_blank(e);
		
		return false;
	}
	function character_number(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if( ((e.value).length==0 || selected_text != "") && (keycode == 32 || (keycode>=48 && keycode <=57) )  )
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode!=13) && (keycode!=32) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}
	
	function character_numbers_Special(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if( ((e.value).length==0 || selected_text != "") && (keycode == 32 || (keycode>=48 && keycode <=57) )  )
		{
			return false;
		}
		if(keycode !=13)
		{
		  return false;
		}
		
		else return true;
	}
	
	function getlogo()
	{
	    return 'angler technologies';
	}
	
	
	
	
	function chk_number_dot(e)
	{
		chr_allow = /[0-9]/g;
		val = e.value;
		val = val.replace(chr_allow,'');
	
		len = val.length;
		val2 = e.value;
		dot_occured = 0;
		for(i=0;i<len;i++)
		{
			if(!(dot_occured == 0 && val.charAt(i) == '.'))
			{
				val2 = val2.replace(val.charAt(i),'');
			}
			if(val.charAt(i) == '-') dot_occured = 1;
		}
		e.value = val2;

		first_chr = (e.value).charAt(0);
		if(e.value != '' && (first_chr == '.' || e.value == 0) )
		{
			alert('Invalid Number');
			e.focus();
			return false;
		}
		else if(e.value != '')
		{
			e.value = parseFloat(e.value);
		}
		return false;
	}

   //Locking the All characters and special characters except -
   function phone_number(e)
   	{
		dec_limit = arguments[1];
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;		
	
		val = e.value;
		dot_index = val.indexOf('-');

		/*if(dot_index != -1)
		{
			dec_pts = (val.length - dot_index);
			if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
			//if(dec_pts >=dec_limit) return false;
		}*/

		var selection=document.selection.createRange();
		var selected_text = selection.text;

		//keycodes allowed but not in the beginning - 0,dot
		if(	(val.length==0 || selected_text != "") && (keycode == 45) )	// || keycode==48
		{
			return false;
		}
		/*else if(dot_index != -1 && keycode == 45 )
		{
			return false;
		}*/
		else if(!(keycode>=48 && keycode <=57) && (keycode!=13) && (keycode!=45) && (keycode!=44) && (keycode!=47))
		{
			return false;
		}
		else return true;
	}
//Price lock
    function number_dot(e)
	 {
		dec_limit = arguments[1];
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;		
	
		val = e.value;
		dot_index = val.indexOf('.');

		if(dot_index != -1)
		{
			dec_pts = (val.length - dot_index);
			if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
			//if(dec_pts >=dec_limit) return false;
		}

		var selection=document.selection.createRange();
		var selected_text = selection.text;

		//keycodes allowed but not in the beginning - 0,dot
		if(	(val.length==0 || selected_text != "") && (keycode == 46) )	// || keycode==48
		{
			return false;
		}
		else if(dot_index != -1 && keycode == 46 )
		{
			return false;
		}
		else if(!(keycode>=48 && keycode <=57) && (keycode!=13) && (keycode!=46) && (keycode!=36) )
		{
			return false;
		}
		else return true;
	}
	
	
      function onkeyup(e)
	{
      	if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;

      	var pressedKey = String.fromCharCode(keycode).toLowerCase();
      	if (event.ctrlKey && (pressedKey == "v")) // pressedKey == "c" ||
      	{
      		// disable key press porcessing
        		event.returnValue = false;
        	}
      }  
      
      //Locking the All special characters except @ and _
	  function username(e)
	  {
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))// || (keycode>=48 && keycode <=57)))
		{
			return false;
		}
		if(!(keycode>=64 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode!=95) && (keycode!=13)  && (keycode!=46) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}
	
	//Open new window
	
	function acceptUserNameWithOutSpace(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		if((keycode >= 65 && keycode <= 132) || (keycode >= 97 && keycode <= 122) || (keycode >= 48 && keycode <= 57) || (keycode==46) || (keycode==64) || (keycode==95))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
 
 //Accept space only after character
   function spaceAfterChr(e)
	  {
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))// || (keycode>=48 && keycode <=57)))
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122)  && (keycode!=13) && (keycode!=32) && (keycode!=46) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;	
	}
						
	//Initial
	function acceptInitial(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}		
		if((keycode==32) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122) || (keycode==46))
		{
			return true
		}
		else
		{
			return false;	
		}
	}
	
	function acceptSocialSecurityNumber(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}		
		//if((keycode>=48 && keycode<=57) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122) || (keycode==40) || (keycode==41) || (keycode==45))
		//{
		//	return true
		//}
		if((keycode>=48 && keycode<=57)  || (keycode==40) || (keycode==41) || (keycode==45))
		{
			return true
		}
		else
		{
			return false;	
		}
	}	
	
	function acceptAddress(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}		
		//Address accept all keys	
		/*if((keycode>=48 && keycode<=57) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122) || (keycode==32) || (keycode==35) || (keycode==44) || (keycode==46))
		{
			return true
		}
		else
		{
			return false;	
		}	*/
	}
	
	function acceptPhoneNumbers(e)
	{	
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}			
		if((keycode>=48 && keycode<=57) || (keycode==32) || (keycode==43) || (keycode==45) || (keycode==40) || (keycode==41))
		{
			return true
		}
		else
		{
			return false;	
		}	
	}
	
	function acceptZipCode(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}			
		if((keycode>=48 && keycode<=57) || (keycode==45))
		{
			return true
		}
		else
		{
			return false;	
		}	
	}
	
	function acceptOccupation(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}			
		if((keycode>=97 && keycode<=122) || (keycode>=65 && keycode<=90)  || (keycode==32) || (keycode==44))
		{
			return true
		}
		else
		{
			return false;	
		}	
	}
	
	function acceptNames(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}			
		if((keycode>=97 && keycode<=122) || (keycode>=65 && keycode<=90)  || (keycode==32) || (keycode==46))
		{
			return true
		}
		else
		{
			return false;	
		}
	}
	
	
	function acceptVisitTime(e)
	{	
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "")&& (keycode==32))
		{
			return false;
		}			
		if((keycode>=48 && keycode<=57 || (keycode==58)))
		{
			return true
		}
		else
		{
			return false;	
		}	
	}
	
	function acceptCharacterNumber(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode == 32))
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode!=13) && (keycode!=32) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}
	
	function acceptLicenseNumbers(e)
	{	
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}			
		if((keycode>=48 && keycode<=57) || (keycode==45) || (keycode>=65 && keycode <=90) || (keycode>=97 && keycode <=122))
		{
			return true
		}
		else
		{
			return false;	
		}	
	}
	
	//Time check
	
	function number_colon(e)
	 {
		dec_limit = arguments[1];
		var keycode;
		if (window.event) keycode = window.event.keyCode;		
		else if (e) keycode = e.which;		
		else return true;		    
	    	    
		val = e.value;		
				
		dot_index = val.indexOf(':');					

		if(dot_index != -1)
		{			
			dec_pts = (val.length - dot_index);			
			if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
			//if(dec_pts >=dec_limit) return false;
		}

		var selection=document.selection.createRange();
		var selected_text = selection.text;		
		
        // commented by christopher for not accepting 0 in Leave Policy permission txt box
		//keycodes allowed but not in the beginning - 0,dot
//		if(	(val.length==0 || selected_text != "") && (keycode == 48))//||(keycode==48))
//		{	
//			return false;
//		} else
	   if(dot_index != -1 && keycode == 58 )
		{			
			return false;
		}
		else if(!(keycode>=48 && keycode <=57) && (keycode!=13) && (keycode!=58))
		{			
			return false;
		}	
		
		else return true;
		
	}
	
	
	//Date Checking	
 function Date_format(e)
   	{
		dec_limit = arguments[1];
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;		
	
		val = e.value;
		dot_index = val.indexOf('-');

		/*if(dot_index != -1)
		{
			dec_pts = (val.length - dot_index);
			if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
			//if(dec_pts >=dec_limit) return false;
		}*/

		var selection=document.selection.createRange();
		var selected_text = selection.text;

        if(((e.value).length==0 || selected_text != "") && (keycode==32))
		{
			return false;
		}	
        
		//keycodes allowed but not in the beginning - 0,dot
		if(	(val.length==0 || selected_text != "") && (keycode == 45) )	// || keycode==48
		{
			return false;
		}
		/*else if(dot_index != -1 && keycode == 45 )
		{
			return false;
		}*/
		else if(!(keycode>=48 && keycode <=57) && (keycode!=13) && (keycode!=47))// && (keycode!=44) && (keycode!=45))//&& (keycode!=32))
		{
			return false;
		}
		else return true;
	}

    
    //av - without space
    function character_number_nospace(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if( ((e.value).length==0 || selected_text != "") && (keycode == 32 )  )
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode!=13) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}

//av - without space - PWD
    function character_number_nospace_pwd(e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space		
		if( ((e.value).length==0 || selected_text != "") && ((keycode == 32)||(keycode == 39)||(keycode == 126)||(keycode == 96)||(keycode == 33)||(keycode == 64)||(keycode == 35)||(keycode == 36)||(keycode == 37)||(keycode == 94)||(keycode == 38)||(keycode == 42)||(keycode == 40)||(keycode == 41)||(keycode == 45)||(keycode == 95)||(keycode == 61)||(keycode == 43)||(keycode == 92)||(keycode == 124)||(keycode == 91)||(keycode == 123)||(keycode == 93)||(keycode == 125)||(keycode == 44)||(keycode == 60)||(keycode == 46)||(keycode == 62)||(keycode == 47)||(keycode == 63)||(keycode == 34)))
		{			
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122)&& !(keycode>=33 && keycode <=47) && (keycode!=13) && !(keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}
	
	// Locking All the Special Characters 
	  function LockSpecialCharacters(e)
	  {
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
            
		var selection=document.selection.createRange();
		var selected_text = selection.text;
		
		//keycodes allowed but not in the beginning - space
		if(((e.value).length==0 || selected_text != "") && (keycode==32))// || (keycode>=48 && keycode <=57)))
		{
			return false;
		}
		if(!(keycode>=65 && keycode <=90) && !(keycode>=97 && keycode <=122) && (keycode=95) && (keycode!=13) && (keycode=46) && (keycode>=48 && keycode <=57) )
		{
			return false;
		}
		else return true;
	}