function uploadAndSave()
{	
	//var fieldID = 'resume';
	var inputs = jQuery('#form_car').find('input');
	 var textarea = jQuery('#form_car').find('textarea');
	/*for (i = 0; i < (inputs.length - 1); i++)
	{
		var third = (i == 3) ? 'email' : ((i == 7) ? 'file' : 'input');
		if(i!=6)
		{
			validate(jQuery(inputs[i]), true, third);
		}
	} */

  
  //  alert(jQuery(inputs[4]));
	validate(jQuery(inputs[0]), true, 'input');
	validate(jQuery(inputs[1]), true, 'email');
	 validate(jQuery(inputs[3]), true, 'input');
	
	 validate(jQuery(textarea[1]), true, 'input'); 

   
	
	


	if(jQuery('.eclass').length > 0)
	{
	
			return false;
	}
	
	/*if (img.length > 0)
	{
		return;
	} */

	var data = {
			ajax: true,
            action:	'saveAndSend',
			c_name:	jQuery('#c_name').val(),
			c_email:	jQuery('#c_email').val(),
			c_phone:	jQuery('#c_phone').val(),
			c_subject:	jQuery('#c_subject').val(),
			c_address:	jQuery('#c_address').val(),
			c_comment:	jQuery('#c_comment').val()
			
		};
		jQuery.ajax({
			type: "POST",
			url: 'contact_mail_send.php',
			data: data,
			dataType: 'json',
			success: function(jData){

				//alert(jData.html);
               // jQuery('#contactingform').slideUp('slow');
				//jQuery('#contactformresponse').html(jData.html);
				
				//jQuery('#contactformresponse').show();
				//jQuery('#contactformresponse').slideDown();
				
				jQuery('#contactingform').slideUp('slow',function(){
							
							jQuery('#contactingform').html('<strong>'+jData.html+'</strong>');
							jQuery('span.cmsdtl').html('');
							jQuery('#contactingform').slideDown('slow');
								});
								
								
				
				
				
			}
		});
		return false;
	




}

function test()
{
 document.getElementById("myhidden").value = 'jhbbb';
 
  return true;
}


function removeValidationImg(elem)
{
	jQuery(elem)
		.nextAll('img[@alt="wrong"]')
			.remove();
	jQuery(elem).removeClass('eclass');
	jQuery(elem)
		.nextAll('img[@alt="correct"]')
			.remove();
	jQuery(elem).removeClass('cclass');
}
function validate(elem, mandatory, type)
{
	removeValidationImg(elem);
	if (mandatory)
	{
		if (jQuery(elem).isEmpty())
		{
			jQuery(elem).after('<img src="images/wrong_icon.gif" align="absmiddle" style="padding-left:10px;" alt="wrong">');
			jQuery(elem).addClass('eclass');
		}
		else if(type=='input')
		{
					jQuery(elem).after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
					jQuery(elem).addClass('cclass');
					jQuery(elem).next('img').fadeOut("slow");
		}
		else
		{
			if (type == 'email')
			{
				if (!jQuery(elem).emailCheck())
				{
					jQuery(elem)
						.after('<img src="images/wrong_icon.gif" align="absmiddle" style="padding-left:10px;" alt="wrong">');
						jQuery(elem).addClass('eclass');
				}
				else
				{
					jQuery(elem).after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
					jQuery(elem).addClass('cclass');
					jQuery(elem).next('img').fadeOut("slow");
				}
				return;
			}
			


			else if(type == 'capcha')
			{
			  var flag;
						var data = {
						ajax: true,
                        action:	'capchaChk',
						txtCaptcha:	jQuery('#txtCaptcha').val()
						
						
					};
					jQuery.ajax({
						type: "POST",
						url: 'contact_mail_send.php',
						data: data,
						dataType: 'json',
						success: function(jData){
						
						//alert("FDFD");
						var t=setTimeout("test()",2000);
						
						
                          flag=jData.html;	
						  
							/*if((jData.html)) {							
							 jQuery(elem).after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
			                 jQuery(elem).addClass('cclass');
			                 jQuery(elem).next('img').fadeOut("slow");
							 
			
							}
							else
							{
							jQuery(elem).after('<img src="images/wrong_icon.gif" align="absmiddle" style="padding-left:10px;" alt="wrong">')
										.addClass('eclass');
										
					
                            }*/
							
								if (flag)
				{
				//alert("if");
		
					jQuery(elem).after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
					jQuery(elem).addClass('cclass');
					jQuery(elem).next('img').fadeOut("slow");	
					alert("false0");
				}
				else
				{
				
		
						//alert("else");
					jQuery(elem).after('<img src="images/wrong_icon.gif" align="absmiddle" style="padding-left:10px;" alt="wrong">');
						jQuery(elem).addClass('eclass');
						alert("false1");
						return;
				}
				
				
						}
					});
				
			
					return;
			}


			



			
			
			//jQuery(elem).after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
			//jQuery(elem).addClass('cclass');
			
			
			
			//jQuery(elem).next('img').fadeOut("slow");
		}
	}

	else if (type == 'email')
	{
		if (!jQuery(elem).emailCheck())
		{
			jQuery(elem).after('<img src="images/wrong_icon.gif" align="absmiddle" style="padding-left:10px;" alt="wrong">');
			jQuery(elem).addClass('eclass');
			return;
		}
		jQuery(elem)
			.after('<img src="images/correct_icon.gif" align="absmiddle" style="padding-left:10px;" alt="correct">');
			jQuery(elem).addClass('cclass');
			jQuery(elem).next('img').fadeOut("slow");
	}

}
