var loc_val = new Array();
var loc_id = new Array();
var loc_ct = 0;
var max_change=0;


// Mobile & Tablets Related start
$(document).ready(function()
{  
	$("#brand_id").change(function() 
	{      
			$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/mobile&tablets.php",  
			data: {GET_MODEL:1,val:$(this).val()},
			beforeSend: function(){
			//location.reload(); 
			//window.lo.cation.href = window.location.href;
			},
			success: function(data)
			{  					
				$("#model").html(data);		  
			}
			});  
	});

});

/******************************** End *******************************************************/


// All Salary Related start
$(document).ready(function() {
	
	$("#min_sal").keydown(function (e) 
	{  	  
			// Allow: backspace, delete, tab, escape, enter and .
			if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
				 // Allow: Ctrl+A, Command+A
				(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || 
				 // Allow: home, end, left, right, down, up
				(e.keyCode >= 35 && e.keyCode <= 40)) {
					 // let it happen, don't do anything
					 return;
			}
			
			// Ensure that it is a number and stop the keypress
			if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
				e.preventDefault();
			}  
	});	
	
	$("#max_sal").keydown(function (e) 
	{  	  
			// Allow: backspace, delete, tab, escape, enter and .
			if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
				 // Allow: Ctrl+A, Command+A
				(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || 
				 // Allow: home, end, left, right, down, up
				(e.keyCode >= 35 && e.keyCode <= 40)) {
					 // let it happen, don't do anything
					 return;
			}
			
			// Ensure that it is a number and stop the keypress
			if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
				e.preventDefault();
			}  
			
		max_change=1;	
	});	  
	
	$("body").click(function(e) 
	{  
		if ( e.target.id == "min_sal" || $(e.target).parents("#max_sal").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				if( (($("#min_sal").val().length) < 7) && ($("#min_sal").val()!='') &&   ($("#min_sal").val() > 1000) &&(max_change==0) )
				{
					sal = parseInt($("#min_sal").val()); 
					$("#max_sal").val(sal+500);
				}
			} 
	});
});

/******************************** End *******************************************************/

// All Job Related start
$(document).ready(function() {
	
	$("#job-category").click(function(){
			$(this).next().slideDown();
			job_cat_set = 0;
	}); 
	
	
	$("body").click(function(e) 
	{  
		 if ( e.target.id == "job-category" || $(e.target).parents("#job-category-sugeetion").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				$("#job-category-sugeetion-ajax").hide(400);
				$("#job-category-sugeetion").hide(400);
			} 	
	 }); 
	 	
	$("#job-category").keyup(function() 
	{  
		//$("#job-role-ul").hide();
		$("#job-sub-category").hide();
		$("#job-sub-category").html('');
		$("#job_cat_val").val('');
		$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/job.php", 
			data: {select_job_category:1,keyword:$(this).val()},
			beforeSend: function(){ 
			},
			success: function(data)
			{  
				
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{  
					$("#job-category-sugeetion").hide(); 
					$("#job-category-sugeetion-ajax").hide();
					//$("#job-role-ul").show();		
				}else
				{  	
					source_first_name = obj[0].name; 
					source_list = '<ul class="menu-box-2">'; 
					
					for(i=0;i<obj.length;i++)			  
					source_list +='<a href="javascript:void(0)"  ><li onclick=select_role_post_job("'+encodeURIComponent(obj[i].catName)+'","'+obj[i].id+'","'+obj[i].originId+'") >'+obj[i].name+'</li></a>'
					
					source_list +='</ul>';   
					 
					$("#job-category-sugeetion-ajax").show();
					$("#job-category-sugeetion-ajax").html(source_list);
                    $("#job-category-sugeetion").hide();					
				}   
				
			}
		}); 
	});
	
});



function select_role_post_job(name,val,originId) 
{   
	new_name =   name.replace(new RegExp("%20", "g"), ' ');     
	new_name =   new_name.replace(new RegExp("%2F", "g"), ' ');     
	$("#job-category").val(new_name);
	$("#job-category-sugeetion-ajax").hide(400);    
	$("#job-category").next().slideUp();
	$("#job_cat_val").val(val);
	
	$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/job.php", 
		data: {Check_sub_job_category:1,val:val},
		beforeSend: function(){ 
		},
		success: function(dataVal)
		{
		    if(dataVal==0)
		    {
		        $.ajax({	
        			type: "POST",
        			url: URL+"/all-ajax/job.php", 
        			data: {select_sub_job_category:1,val:val},
        			beforeSend: function(){ 
        			},
        			success: function(data)
        			{  	
        				var obj = jQuery.parseJSON(data);  
        				if(obj==null || obj=='null')
        				{  
        					 
        					$("#job-sub-category").hide();
        					//$("#job-role-ul").show(); 
        					
        				}else
        				{  	 
        			        source_list = '<a href="javascript:void(0)" id="sub_selectall" onclick=select_sub_selectall(1)>Select All</a> <span id="deselectall_label"></span><ul>';  
        					
        					for(i=0;i<obj.length;i++)			  
        					{
        					    if(obj[i].id==originId) 
        					        source_list += '<li><input type=checkbox  checked name="sub-roles[]" value="'+obj[i].id+'" />'+obj[i].name+'</li>';
        					   else
        					        source_list += '<li><input type=checkbox  name="sub-roles[]" value="'+obj[i].id+'" />'+obj[i].name+'</li>';
        					}
        				
        					source_list +='</ul>';     
        					$("#job-sub-category").show();
        					$("#job-sub-category").html(source_list); 
        				}   
        				
        			}
        	   });
		    }
		    else
		    {
		        $("#job-sub-category").hide();
		        alert("Role already used!!!");
		        $("#job-category").val("");
		        $("#job_cat_val").val("");
		    }
		}    
	});
}      

function select_sub_selectall(val)
{
	if(val==1)
	{
		$(':checkbox').each(function() 
		{  
			this.checked = true;    
			$("#deselectall_label").html('<a href="javascript:void(0)" id="sub_deselectall" onclick=select_sub_selectall(0)>Deselect All</a>');
            $("#sub_selectall").hide();				
		});
	}
	else if(val==0)
	{
		$(':checkbox').each(function() {
				this.checked = false;  
            $("#sub_selectall").show();	
            $("#sub_deselectall").hide();				
		});
	}
}
/******************************** End *******************************************************/

// All City Related start 
$(document).ready(function() {    
    $("#ul-city-ajax").hide();
	$("#job-category-sugeetion").hide();
	$("#ul-location-ajax").hide();
	$("#city").click(function(){
		//	$(this).next().slideDown();   
	});  	
	 
	
	$("body").click(function(e) 
	{  
		 	if ( e.target.id == "city" || $(e.target).parents("#city-ajax").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				$("#city").next().slideUp();
				$("#city-ajax").hide(400); 
			}


            if ( e.target.id == "ul-city-ajax" || $(e.target).parents("#city").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				
				//$("#select-sub-locations").next().slideUp();
				 
			}			
	});  

	$("#city").keyup(function() 
	{     
		$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/job.php", 
			data: {select_city:1,keyword:$(this).val()},
			beforeSend: function(){ 
			},
			success: function(data)
			{   
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{   
					$("#city-ajax").hide();
					$("#ul-city-ajax").hide(); 					
				}else
				{  	 
					source_list = '<ul class="menu-box-2">';  
					for(i=0;i<obj.length;i++)			  
					source_list +='<a href="javascript:void(0)"><li onclick=select_sub_locns("'+encodeURIComponent(obj[i].name)+'","'+obj[i].id+'") >'+obj[i].name+'</li></a>' 
					
					source_list +='</ul>';  
					$("#city-ajax").show();
					$("#city-ajax").html(source_list);
                    $("#ul-city-ajax").hide(); 					
				} 			
			}
		}); 
	  /*}	
      else 
      {
		
		//loc_id = null;
		//loc_val = null;  
		var val=$("#locations_val").val();
		console.log(val);
		var v='';
		loc_val.splice(val, 1); 
		loc_id.splice(val, 1);   
		var res = loc_id.join(",");  
		$("#locations_val").val(res);  
			
		//for (var i = 0, len = loc_val.length; i < len; i++) 
			//v += '<a  href=javascript:void(0) onclick=select_loc_id("'+i+'") >'+loc_val[i]+' X </a><br>';    
		loc_ct--;  		
		$("#locality_placed").html("");
	  }*/		  
	});	
	
	
	$("#post_job").submit(function(event)  
	{ 	 
		if ($('#post_job').valid())  
		{ 
		    $( "#PosttUpdateId" ).addClass("disableloginbtn" );    
		    if($("#job_cat_val").val()=='')
            {
                $("#PosttUpdateId").removeClass("disableloginbtn"); 
                $("#job-category").val('');
                alert("Kindly Select Role");
                event.preventDefault();
            }
	        else if($("#locations_val").val()=='')               
            {
                $("#PosttUpdateId").removeClass("disableloginbtn"); 
                alert("At least one job location required");
                event.preventDefault();
            }
	    }
	 });
	 
	$("#edit_ads").submit(function(event)  
	{ 	 
		if ($('#edit_ads').valid())  
		{ 
	        if($("#locations_val").val()=='')               
            {
                alert("Atleast one job location required");
                event.preventDefault();  
            } 
	    }    
	 });
});


function select_sub_locns(name,val)
{ 
	
	$("#search_city_id_hidden").val(val);  
	new_name =   name.replace(new RegExp("%20", "g"), ' ');     
	new_name =   new_name.replace(new RegExp("%2F", "g"), ' ');     
	$("#city").val(new_name);    
	$("#city").next().slideUp();
	$("#select-sub-locations").val('');
	$("#city-ajax").hide(400);
	$("#city_val").val(val);
	$("#locations_val").val('');  
	 
    loc_val.splice(0, loc_val.length);     
    loc_id.splice(0, loc_id.length); 
	$("#locality_placed").html("");
   	
	var source_list =''; 
	$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/job.php", 
		data: {select_city_sub_location:1,ajax_set:1,city_id:$("#search_city_id_hidden").val()},
		beforeSend: function(){ 
		},
		success: function(data)
		{   			 
			var obj = jQuery.parseJSON(data);  
			if(obj==null || obj=='null')
			{		
				$("#select-sub-locations").val('Entire City');
                $("#ul-location-ajax").hide();
                $("#ul-location-ajax").remove();

                /*var val=$("#locations_val").val();
				var res = val.split(",");
				console.log(res);
			    var rec=res.pop();
			    console.log(rec);*/
				
				/*var val=$("#locations_val").val();
				console.log(val);
				console.log(typeof val);
				var res = val.split(",");
				console.log(typeof res);*/
				
				
				
				//var pp=res.pop();
				//console.log(pp);
				/*console.log(loc_val.indexOf(val));
				if(loc_val.indexOf(val)==-1)
				{
					//loc_id = null;
					//loc_val = null;  
					$("#locality_placed").html("");
					$("#locations_val").val("");		
				}*/
				
				var v='';
				//loc_val.splice(val, 1); 
				//loc_id.splice(val, 1);   
				//var res = loc_id.join(",");
                //console.log(res);				
				//$("#locations_val").val(res);  
					
				//for (var i = 0, len = loc_val.length; i < len; i++) 
					//v += '<a  href=javascript:void(0) onclick=select_loc_id("'+i+'") >'+loc_val[i]+' X </a><br>';
                //console.log(val);				
					
				//$("#locality_placed").html("");
               // $("#locations_val").val("");				
			}
			else
			{  	 
				//source_list = '<ul>';  
				for(i=0;i<obj.length;i++)			  
				source_list +='<a href="javascript:void(0)"  ><li onclick=select_location_post_job("'+encodeURIComponent(obj[i].location_name)+'","'+obj[i].id+'") >'+obj[i].location_name+'</li></a>'   
				//source_list +='</ul>';    
				$("#ul-location-ajax").html(source_list); 			
			}   
			
		}
	}); 
		
}  
/******************************** End *******************************************************/


// Location Experience & Other...
$(document).ready(function() {   

	$("#select-sub-locations").click(function(){ 
			$(this).next().slideDown(); 
	});  
	
	$("#description").keyup(function()
	{   	 
		if(($(this).val().length < 26))
		{
		    $("DescCountId").css("color-red");
	    	$("#DescCountId").text("Total Characters: "+$(this).val().length); 
		}else
		    $("#DescCountId").text(""); 
	});	
	
	
	$("body").click(function(e) 
		{    
			
			if ( e.target.id == "select-sub-locations" || $(e.target).parents("#job-loction-sugeetion-ajax").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				$("#select-sub-locations").next().slideUp();
				$("#job-loction-sugeetion-ajax").hide(400);
			} 
			
			if ( e.target.id == "ul-location-ajax" || $(e.target).parents("#select-sub-locations").size() ) 
			{ 
				 //alert("Inside div");   
			} else 
			{    
				
				//$("#select-sub-locations").next().slideUp();
				 
			}   
			
		});      
	
	$("#select-sub-locations").keyup(function() 
	{     
		$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/job.php", 
			data: {select_city_sub_location:1,keyword:$(this).val(),city_id:$("#search_city_id_hidden").val()},
			beforeSend: function(){ 
			},
			success: function(data)
			{   
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{   
					$("#job-loction-sugeetion-ajax").hide(); 
					$("#ul-location-ajax").hide(); 
				}else
				{  	 
					source_list = '<ul class="menu-box-2">';  
					for(i=0;i<obj.length;i++)			  
					source_list +='<a href="javascript:void(0)"  ><li onclick=select_location_post_job("'+encodeURIComponent(obj[i].location_name)+'","'+obj[i].id+'") >'+obj[i].location_name+'</li></a>' 
					
					source_list +='</ul>';  
					$("#job-loction-sugeetion-ajax").show();
					$("#job-loction-sugeetion-ajax").html(source_list); 
					$("#ul-location-ajax").hide(); 
				}   
				
			}
		}); 
	}); 

		jQuery.validator.addMethod("max_sal_cal", function(value, element) {
		// allow any non-whitespace characters as the host part
		
			//if(($("#max_sal").val() < $("#min_sal").val()))
			/*if(parseInt(value) > parseInt($("#min_sal").val()))	
			{ 
				$("#max_sal").val('');
				return false;
			}else
				return true;*/
			return parseInt(value) > parseInt($("#min_sal").val());
			
		}, 'Max Salary Should Greater Than Min Salary');
		
		jQuery.validator.addMethod("max_sal_cal1", function(value, element) {
		// allow any non-whitespace characters as the host part
		
			//if(($("#max_sal").val() < $("#min_sal").val()))
			/*if(parseInt(value) > parseInt($("#min_sal").val()))	
			{ 
				$("#max_sal").val('');
				return false;
			}else
				return true;*/
			return parseInt(value) > parseInt($("#min_sal").val());
			
		}, 'Max Salary Should Greater Than Min Salary');

        
         jQuery.validator.addMethod("lettersonly", function(value, element) {
        return this.optional(element) || /^[a-z\d\-_./@+=#$&*:;()\s]+$/i.test(value);
        }, "Use letters,numbers & (_,-.()/@+=#$&*:;) only"); 
        
        
        /*jQuery.validator.addMethod("descriptionlettersonly", function(value, element) {
        return this.optional(element) || /^[a-z\d\-_.&()!%'/|:;[]{}<>+=?\s]+$/i.test(value);
        }, "Use letters,numbers & (_,-,.,&,(),!,%,',:,;,{},[],<,>,+,=,?,/,|) only"); */
        
        jQuery.validator.addMethod("descriptionlettersonly", function(value, element) {
        return this.optional(element) || /^[a-z\d\-_.,()\s]+$/i.test(value);
        }, "Use letters,numbers & (_,-.()) only");
		
		$("#post_job").validate({
		
			errorElement:'div',
			rules:{ 
				title:{
					required:true,
					minlength:5,
					lettersonly:true,
					maxlength:150 
				}, 
				description:{
					required:true,
                    minlength:25,
                    //descriptionlettersonly:true,
                    maxlength:3000
				},
				job_category:{
					required:true
					//remote: "value_check.php"			
				},
				city:{
					required:true
					//remote: "value_check.php"			
				},	
				email:{
					required:true,
					minlength:true
				},
				mobile:{
					required:true,
					number: true,
					minlength:10,
					maxlength:10 
				},
				min_sal:{
					required:true,
					number: true,
					minlength:4,
					maxlength:6 
				},
				max_sal:{
					required:true,
					number: true,
					minlength:4,
					maxlength:6,
					max_sal_cal:true	
				},
				company_name:{
				    required:true,
				    lettersonly:true,
				    minlength:3,
					maxlength:50 
				}
				
				/*,
				select_sub_locn:{
					required:true,
					remote: "value_check.php"			
					
				} 	*/	
				
				
			},
			messages:{	

				title:{
					required:"Enter Minimum 5 Characters Title",				 
					minlength:"Enter Title Atlist 5 Characters",
					maxlength:"Max 150 Characters Is Allowed"
					
				},
				min_sal:{
					required:"Please Enter  Min Salary",
					minlength:"Minimum Salary Should Greater Than 1000",	 
					maxlength:"Max 6 Digit Salary Is Allowed"	 	
				},
				max_sal:{
					required:"Please Enter  Max Salary",
					minlength:"Salary Should Greater Than 1000",	 
					maxlength:"Max 6 Digit Salary Is Allowed"	 		
				},
				email:{
					required:"",	 
					email:"Would Be Valid Email"	 
				},
				mobile:{
					required:"",	 
					minlength:"Enter 10 Digit Mobile No",	 
					maxlength:"Enter 10 Digit Mobile No"	 
				}, 
				job_category:{
					required:"Kindly Select Role"
					//remote:"Please select job category from dropdown"	
				},	
					
				city:{
					required:"Kindly Select City"
					//remote:"Please select city from dropdown"	
				}, 
				description: 
				{
					required:"Kindly Add Some Description...",
                    minlength:"Kindly Add 25 Characters Description... "					
				},
				company_name:
				{
				    required:"Please Enter Company Name",
				    minlength:"Enter Minimum 3 Characters Company Name",				 
					maxlength:"Enter Company Name Atlist 50 Characters"
				}
				/*,	
				select_sub_locn: 
				{
					required:"Kindly Select Minimum One Location",
					remote:"Please select job category from dropdown"	
				} */ 
				 
			}
		});
		
		$("#edit_ads").validate({
		
			errorElement:'div',
			rules:{ 
				
				title:{
					required:true,
					minlength:5,
					lettersonly:true,
					maxlength:150 
				}, 
				description:{
					required:true,
                    minlength:25,
                   // descriptionlettersonly:true,
                    maxlength:3000
				},			
				min_salary:{
					required:true,
					number: true,
					minlength:4,
					maxlength:6 
				},
				max_salary:{
					required:true,
					number: true,
					minlength:4,
					maxlength:6,
					max_sal_cal1:true	
				}/*,
				locations_val:{
					required:true
					//remote: "value_check.php"			
				}*/					
			},
			messages:{	
			
            	title:{
					required:"Enter Minimum 5 Characters Title",				 
					required:"Enter Title Atlist 5 Characters"				 
				},  
				min_salary:{
					required:"Please Enter  Min Salary",
					minlength:"Minimum Salary Should Greater Than 1000",	 
					maxlength:"Max 6 Digit Salary Is Allowed"	 	
				},
				max_salary:{
					required:"Please Enter  Max Salary",
					minlength:"Salary Should Greater Than 1000",	 
					maxlength:"Max 6 Digit Salary Is Allowed"	 		
				},
				description: 
				{
					required:"Kindly Add Some Description...",
                    minlength:"Kindly Add 25 Characters Description... "					
				}/*,
				locations_val:{
					required:"Kindly Select Minimum One Location"
					//remote:"Please select city from dropdown"	
				} 
				/*,	
				select_sub_locn: 
				{
					required:"Kindly Select Minimum One Location",
					remote:"Please select job category from dropdown"	
				} */ 				 
			}
		});
			
	
        $("#edit_ads").submit(function(event) 
    	{  	
    		if ( $('#edit_ads').valid()) 
    		    $( "#submitUpdate" ).last().addClass( "disableloginbtn" );  	
    	});  
    	
     
	
});

function Addlocation(name,val)  
{ 
    new_name =   name.replace(new RegExp("%20", "g"), ' ');     
    new_name =   new_name.replace(new RegExp("%2F", "g"), ' ');  
    
    loc_val.push(new_name); 
	///loc_id.push(val); 
	loc_id.push(val.toString()); 
    loc_ct++;
}

function select_location_post_job(name,val) 
{
    val = val.toString();
	if(loc_ct < 5)
	{
	  	
	  if(loc_id.indexOf(val) < 0)
	  {
		var v='';
		new_name =   name.replace(new RegExp("%20", "g"), ' ');     
		new_name =   new_name.replace(new RegExp("%2F", "g"), ' ');     
		$("#select-sub-locations").val(new_name);
		$("#job-loction-sugeetion-ajax").hide(400);    
		$("#select-sub-locations").next().slideUp();  
		 
		
		loc_val.push(new_name); 
		loc_id.push(val);  
		var res = loc_id.join(",");  
		$("#locations_val").val(res);  
		
		for (var i = 0, len = loc_val.length; i < len; i++) 
			v += '<a  href=javascript:void(0) onclick=select_loc_id("'+i+'")  >'+loc_val[i]+' X </a>';
		 
		
		$("#locality_placed").html(v);
		$("#select-sub-locations").next().slideUp();
		$("#select-sub-locations").val('');
		 
		loc_ct++;
		
	   }
		else
		{
		    $("#select-sub-locations").next().slideUp();
		    $("#job-loction-sugeetion-ajax").hide(); 
		    $("#select-sub-locations").val('');
			alert("Location already added!");
		}
		
	}else
	{
	    $("#select-sub-locations").next().slideUp();
	    $("#job-loction-sugeetion-ajax").hide(); 
	    $("#select-sub-locations").val('');
		alert("You can't add more than 5 locations!");
	}
}
 
function select_loc_id(val) 
{      
	var v='';  
	loc_val.splice(val, 1); 
	loc_id.splice(val, 1);  
	 
	if(loc_val.length > 0)
	{
	   var res = loc_id.join(",");  
	   $("#locations_val").val(res);  
	
	  for (var i = 0, len = loc_val.length; i < len; i++) 
		v += '<a  href=javascript:void(0) onclick=select_loc_id("'+i+'") >'+loc_val[i]+' X </a>'; 
		
		
		
		$("#locality_placed").html(v); 
	    loc_ct--;
	}
	else alert("Atleast one job location required");
}




function select_exp(val)
{
	var t;
	if(val > 9)
	{
		t += '<option  value=10>10+</option>';
		$("#max_exp").html(t); 
	}
	else
	{
		var exp = parseInt(val); 
		for(i=exp+1;i<=9;i++)
			t += '<option  value="'+i+'" >'+i+'</option>';
		
		t += '<option  value=10>10+</option>';
		$("#max_exp").html(t);
	}
}


function goBack() 
{
  window.history.back();
}

function check(e) {
    var keynum
    var keychar
    var numcheck
    // For Internet Explorer
    if (window.event) {
        keynum = e.keyCode;
    }
    // For Netscape/Firefox/Opera
    else if (e.which) {
        keynum = e.which;
    }
    keychar = String.fromCharCode(keynum);
    //List of special characters you want to restrict
       if (keychar =="~" || keychar =="!" || keychar =="$" || keychar =="^" || keychar =="{" || keychar =="}" || keychar =="?") { 
        return false;
    } else {
        return true;
    }
}
