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()
{  
    $("#year_ErrMsg").html("");
    $("#ShowMyImages").hide(400); 
	$("#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 *******************************************************/

function get_year(val)
{
    var d = new Date();
    var currentYear = d.getFullYear();
    var previousYear = d.getFullYear() - 30;
    var yearDigit = /^\d{4}$/;
    if( ($("#car_year").val().match(yearDigit)) && ($("#car_year").val()!='')  )
    {
        $.ajax({	
    		type: "POST",
    		url: URL+"/all-ajax/car.php", 
    		data: {get_CarYear:1,val:val},
    		beforeSend: function(){ 
    		},
    		success: function(data)
    		{
    		    if(data==0)
    		    {
    		        $("#year_ErrMsg").html("Year should be between "+previousYear+" to "+currentYear);
    		        $("#car_year").val(" ");
    		    }
    		    else
    		    {
    		        $("#year_ErrMsg").html("");
    		    }
    		}    
        });
    }
    else 
    {
       $("#year_ErrMsg").html("Year should be between "+previousYear+" to "+currentYear);
       $("#car_year").val(" ");
    }
}    


// All Salary Related start
$(document).ready(function() {
    
    $("#car_year").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();
			}  
	});	
	
	$("#km_driven").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) < 11) && ($("#min_sal").val()!='') &&   ($("#min_sal").val() > 30000) )
			
		} 
	});
});

/******************************** 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);
			} 	
	 }); 
	 
	$("#min_sal").keyup(function() 
    {
            if($(this).val()!='')
            {
            res = parseFloat($(this).val().replace(/,/g, ''));  
            out = parseFloat(res).toLocaleString('en-IN'); 
            $("#min_sal").val(out); 
            }
    });
	 	
	//$("#job-category").keyup(function() 
	$('#job-category').on("change", function()
	{
	    $('#job-sub-category').val("");
	    $('#car-max_salary').val("");
	    $('#job_cat_val').val("");
	    $("#job_cat_val").val($('#job-category').val());
	    $.ajax({	
		type: "POST",
		url: URL+"/all-ajax/car.php", 
		data: {select_sub_job_category:1,val:$('#job-category').val()},
		beforeSend: function(){ 
		},
		success: function(data)
		{  	
			var obj = jQuery.parseJSON(data);  
			if(obj==null || obj=='null')
			{
				source_list = '<select id="job-sub-category" class="inputText type"><option value="0">Models Not Available</option></select>';
				$("#job-sub-category").show();
				$("#job-sub-category").html(source_list); 
				
				source_list1 = '<select id="car-max_salary" class="inputText type"><option value="0">Variant Not Available</option></select>';
				$("#car-max_salary").show();
				$("#car-max_salary").html(source_list1);
			}
			else
			{ 
		        source_list = '<select id="job-sub-category" class="inputText type"><option value="">Popular Models</option>';  
				
				for(i=0;i<obj.length;i++)			  
				{
				   source_list += '<option value="'+obj[i].id+'" >'+obj[i].name+'</option>';
				}
			
				source_list +='</select>';     
				$("#job-sub-category").show();
				$("#job-sub-category").html(source_list); 
			}   
			
		}
     });
	});
	
	$('#job-sub-category').on("change", function() 
    {
        $.ajax({	
			type: "POST",
			url: URL+"/all-ajax/car.php", 
			data: {select_modalVariant:1,val:$('#job-sub-category').val()},
			beforeSend: function(){ 
			},
			success: function(data)
			{  	
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{
					source_list = '<select id="car-max_salary" class="inputText type"><option value="0">Variant Not Available</option></select>';
					$("#car-max_salary").show();
					$("#car-max_salary").html(source_list); 
				}else
				{ 
			        source_list = '<select id="car-max_salary" class="inputText type"><option value="">Model Variant</option>';  
					
					for(i=0;i<obj.length;i++)			  
					{
					        source_list += '<option value="'+obj[i].id+'" >'+obj[i].name+'</option>';
					}
				
					source_list +='</select>';     
					$("#car-max_salary").show();
					$("#car-max_salary").html(source_list); 
				}   
				
			}
	    });
    });
	
});



function select_role_post_job(name,val) 
{   
	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/car.php", 
		data: {Check_sub_job_category:1,val:val},
		beforeSend: function(){ 
		},
		success: function(dataVal)
		{
		    if(dataVal==0)
		    {
		        $.ajax({	
        			type: "POST",
        			url: URL+"/all-ajax/car.php", 
        			data: {select_sub_job_category:1,val:val},
        			beforeSend: function(){ 
        			},
        			success: function(data)
        			{  	
        				var obj = jQuery.parseJSON(data);  
        				if(obj==null || obj=='null')
        				{
        					source_list = '<select id="job-sub-category" class="inputText type"><option value="0">Models Not Available</option></select>';
        					$("#job-sub-category").show();
        					$("#job-sub-category").html(source_list); 
        					
        					source_list1 = '<select id="car-max_salary" class="inputText type"><option value="0">Variant Not Available</option></select>';
        					$("#car-max_salary").show();
        					$("#car-max_salary").html(source_list1);
        				}
        				else
        				{ 
        			        source_list = '<select id="job-sub-category" class="inputText type"><option value="">Popular Models</option>';  
        					
        					for(i=0;i<obj.length;i++)			  
        					{
        					        source_list += '<option value="'+obj[i].id+'" >'+obj[i].name+'</option>';
        					}
        				
        					source_list +='</select>';     
        					$("#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/car.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(); 					
				} 			
			}
		}); 
	});	
	
	
	$("#post_job").submit(function(event)  
	{ 	 
	    var fuelValue = $("input[name='fuel']:checked").val();
	    var transmissionValue = $("input[name='transmission']:checked").val();
	    
		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();
            }
            else if(!fuelValue)               
            {
                $("#PosttUpdateId").removeClass("disableloginbtn"); 
                alert("Kindly Select Fuel");
                event.preventDefault();
            }
            else if(!transmissionValue)               
            {
                $("#PosttUpdateId").removeClass("disableloginbtn"); 
                alert("Kindly Select Transmission");
                event.preventDefault();
            }
	    }
	 });
	 
	$("#edit_ads").submit(function(event)  
	{ 	 
		if ($('#edit_ads').valid())  
		{ 
	        if($("#locations_val").val()=='')               
            {
                alert("At least 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/car.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 v='';
			}
			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/car.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
		
			res = parseFloat(value.replace(/,/g, '')); 
			return (res) >= parseFloat(30000);
			
		}, 'Price Should Greater Than Or Equal To 30000');
		
		jQuery.validator.addMethod("max_sal_calc", function(value, element) {
		// allow any non-whitespace characters as the host part
		
			res = parseFloat(value.replace(/,/g, '')); 
			return (res) <= parseFloat(100000000);
			
		}, 'Price Should upto 10,00,00,000');
		
		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");
        
       
		
		$("#post_job").validate({
		
			errorElement:'div',
			rules:{ 
				title:{
					required:true,
					minlength:5,
					//lettersonly:true,
					maxlength:150 
				}, 
				job_category:{
					required:true		
				},
				sub_category:{
					required:true		
				},
				car_variant:{
					required:true		
				},
				description:{
					required:true,
                    minlength:25,
                    //descriptionlettersonly:true,
                    maxlength:3000
				},
				city:{
					required:true
					//remote: "value_check.php"			
				},	
				email:{
					required:true,
					minlength:true
				},
				mobile:{
					required:true,
					number: true,
					minlength:10,
					maxlength:10 
				},
				car_year:{
					required:true,
					number: true,
					//minlength:4,
					//yearRange:true,
					maxlength:4 
				},
				km_driven:{
					required:true,
					number: true,
					maxlength:6 
				},
				no_owner:{
					required:true
				},
				min_sal:{
					required:true,
					minlength:5,
					maxlength:9,
					max_sal_cal:true,
					max_sal_calc:true
				},
				locations_val:{
					required: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"
				},
				job_category:{
					required:"Kindly Select Brand"
					//remote:"Please select job category from dropdown"	
				},
				sub_category:{
					required:"Kindly Select Modal"
				},
				car_variant:{
					required:"Kindly Select Variant"
				},
				description: 
				{
					required:"Kindly Add Some Description...",
                    minlength:"Kindly Add 25 Characters Description... "					
				},
				car_year:{
					required:"Please Enter Min Year",
					//minlength:"Minimum Year Should Greater Than 1990",	 
					maxlength:"Max 4 Digit Year Is Allowed"	 	
				},
				km_driven:{
					required:"Please Enter Km Driven ",	 
					maxlength:"Max 6 Digit Km Is Allowed"	 	
				},
				no_owner:{
					required:"Kindly Select No. of Owners"
				},
				min_sal:{
					required:"Please Enter  Min Price",
					minlength:"Minimum Price Should Greater Than 30000",	 
					maxlength:"Max 9 Digit Price Is Allowed"	 	
				},
				email:{
					required:"",	 
					email:"Would Be Valid Email"	 
				},
				mobile:{
					required:"",	 
					minlength:"Enter 10 Digit Mobile No",	 
					maxlength:"Enter 10 Digit Mobile No"	 
				}, 
				city:{
					required:"Kindly Select City"
					//remote:"Please select city from dropdown"	
				},
				locations_val:{
					required:"Kindly Select Location"
					//remote:"Please select city from dropdown"	
				}/*, 
				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"	
				} */ 
				 
			}
		});
		
		 /*$.validator.addMethod("yearRange", function (value, element) 
		 {
            var minVal = "<?php echo date('Y',strtotime('-30 year'));?>";//new Date(1991);
            var maxVal = "<?php echo date('Y');?>";//new Date(2021);
            var inputDate = new Date(value);
            if (inputDate < minVal || inputDate > maxVal)
                return false;
            return true;
        }, "Year should be between "+minVal+" to "+maxVal);*/
		
		/*$("#edit_ads").validate({
		
			errorElement:'div',
			rules:{ 
				
				title:{
					required:true,
					minlength:5,
					maxlength:150 
				}, 
				description:{
					required:true,
                    minlength:25,
                    maxlength:3000
				},			
				min_salary:{
					required:true,
					number: true,
					maxlength:6 
				},
				max_salary:{
					required:true,
					number: true,
					minlength:4,
					maxlength:6,
					max_sal_cal1:true	
				}					
			},
			messages:{	
			
            	title:{
					required:"Enter Minimum 5 Characters Title",				 
					required:"Enter Title Atlist 5 Characters"				 
				}, 
				min_salary:{
					required:"Please Enter Min Price",
					maxlength:"Max 10 Digit Price 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... "					
				}				 
			}
		});*/
		
		$("#edit_ads").validate({
		
			errorElement:'div',
			rules:{ 
				title:{
					required:true,
					minlength:5,
					maxlength:150 
				},
				sub_category:{
					required:true		
				},
				car_variant:{
					required:true		
				},
				description:{
					required:true,
                    minlength:25,
                    maxlength:3000
				},
				city:{
					required:true
				},	
				email:{
					required:true,
					minlength:true
				},
				mobile:{
					required:true,
					number: true,
					minlength:10,
					maxlength:10 
				},
				car_year:{
					required:true,
					number: true,
					maxlength:4 
				},
				km_driven:{
					required:true,
					number: true,
					maxlength:6 
				},
				no_owner:{
					required:true
				},
				min_sal:{
					required:true,
					minlength:5,
					maxlength:9,
					max_sal_cal:true,
					max_sal_calc:true
				},
				locations_val:{
					required:true
				}
			},
			messages:{	

				title:{
					required:"Enter Minimum 5 Characters Title",				 
					minlength:"Enter Title Atlist 5 Characters",
					maxlength:"Max 150 Characters Is Allowed"
				},
				sub_category:{
					required:"Kindly Select Modal"
				},
				car_variant:{
					required:"Kindly Select Variant"
				},
				description: 
				{
					required:"Kindly Add Some Description...",
                    minlength:"Kindly Add 25 Characters Description... "					
				},
				car_year:{
					required:"Please Enter Min Year",
					maxlength:"Max 4 Digit Year Is Allowed"	 	
				},
				km_driven:{
					required:"Please Enter Km Driven ",	 
					maxlength:"Max 6 Digit Km Is Allowed"	 	
				},
				no_owner:{
					required:"Kindly Select No. of Owners"
				},
				min_sal:{
					required:"Please Enter  Min Price",
					minlength:"Minimum Price Should Greater Than 30000",	 
					maxlength:"Max 9 Digit Price Is Allowed"	 	
				},
				email:{
					required:"",	 
					email:"Would Be Valid Email"	 
				},
				mobile:{
					required:"",	 
					minlength:"Enter 10 Digit Mobile No",	 
					maxlength:"Enter 10 Digit Mobile No"	 
				}, 
				city:{
					required:"Kindly Select City"
				},
				locations_val:{
					required:"Kindly Select Location"
				}
			}
		});
			
	
        $("#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) 
{
    new_name =   name.replace(new RegExp("%20", "g"), ' ');     
    new_name =   new_name.replace(new RegExp("%2F", "g"), ' ');     
    $("#select-sub-locations").val(new_name);
    $("#locations_val").val(val);
    $("#job-loction-sugeetion-ajax").hide(400);    
    $("#select-sub-locations").next().slideUp();
    /*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 titlecheck(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;
    }
}
