function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}
var http = createRequestObject(); 
function valid(edit) {
 var alphaExp = /^[0-9a-zA-Z]+$/;
 var emailExp=/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/;
 var numExp =/^[0-9]+$/;
 var illegalChars = /\W/; 
function isNotEmpty(val){
  return ((trim(val)).length>0);
}
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

  if (edit.vehicle_title.value== '') {
   document.getElementById('vehicle_title').innerHTML = 'Please introduce Vehicle Title.';
    edit.vehicle_title.style.backgroundColor='#3976A3';
	edit.vehicle_title.style.color='#000000';
    return false;
  }
  else { 
  	edit.vehicle_title.style.backgroundColor=''; 
	document.getElementById('vehicle_title').innerHTML = '';
  } 
  
  if (edit.make.value == '0') {
		document.getElementById('make').innerHTML = 'Please select Vehicle Make.';
		edit.make.style.backgroundColor='#3976A3'; 
        edit.make.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.make.style.backgroundColor='';
	 document.getElementById('make').innerHTML = '';
  }
  
  if (edit.bodystyle.value == '0') {
		document.getElementById('bodystyle').innerHTML = 'Please select Vehicle Category.';
		edit.bodystyle.style.backgroundColor='#3976A3'; 
        edit.bodystyle.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.bodystyle.style.backgroundColor='';
	 document.getElementById('bodystyle').innerHTML = '';
  }
  
  if (edit.year.value == '0') {
		document.getElementById('year').innerHTML = 'Please select Year built.';
		edit.year.style.backgroundColor='#3976A3'; 
        edit.year.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.year.style.backgroundColor='';
	 document.getElementById('year').innerHTML = '';
  }
  
  if (edit.condition.value == '0') {
		document.getElementById('condition').innerHTML = 'Please select the car Condition.';
		edit.condition.style.backgroundColor='#3976A3'; 
        edit.condition.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.condition.style.backgroundColor='';
	 document.getElementById('condition').innerHTML = '';
  }
   if (edit.drivetype.value == '0') {
		document.getElementById('drivetype').innerHTML = 'Please select the Drive Type.';
		edit.drivetype.style.backgroundColor='#3976A3'; 
        edit.drivetype.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.drivetype.style.backgroundColor='';
	 document.getElementById('drivetype').innerHTML = '';
  }
   if (!numExp.test(edit.mila.value)) {
    document.getElementById('mila').innerHTML = 'Please introduce the Mileage.';
    edit.mila.style.backgroundColor='#3976A3';
	edit.mila.style.color='#000000';
    return false;
  }
  else { 
  	edit.mila.style.backgroundColor=''; 
	document.getElementById('mila').innerHTML = '';
  } 
    if (edit.transmissions.value == '0') {
		document.getElementById('transmissions').innerHTML = 'Please select the type of the transmissions.';
		edit.transmissions.style.backgroundColor='#3976A3'; 
        edit.transmissions.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.transmissions.style.backgroundColor='';
	 document.getElementById('transmissions').innerHTML = '';
  }
  if (!numExp.test(edit.price.value)) {
    document.getElementById('price').innerHTML = 'Please introduce the Price !';
    edit.price.style.backgroundColor='#3976A3';
	edit.price.style.color='#000000';
    return false;
  }
  else { 
  	edit.price.style.backgroundColor=''; 
	document.getElementById('price').innerHTML = '';
  } 
  
 if (edit.hpower.value == '0') {
		document.getElementById('hpower').innerHTML = 'Please select the Horse Power.';
		edit.hpower.style.backgroundColor='#3976A3'; 
        edit.hpower.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.hpower.style.backgroundColor='';
	 document.getElementById('hpower').innerHTML = '';
  }
  
  if (edit.towingcapacity.value == '0') {
		document.getElementById('towingcapacity').innerHTML = 'Please select the Towing Capacity.';
		edit.towingcapacity.style.backgroundColor='#3976A3'; 
        edit.towingcapacity.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.towingcapacity.style.backgroundColor='';
	 document.getElementById('towingcapacity').innerHTML = '';
  }
  
   if (!numExp.test(edit.fregist.value)) {
    document.getElementById('fregist').innerHTML = 'Please introduce the First Registrationof the car.';
    edit.fregist.style.backgroundColor='#3976A3';
	edit.fregist.style.color='#000000';
    return false;
  }
  else { 
  	edit.fregist.style.backgroundColor=''; 
	document.getElementById('fregist').innerHTML = '';
  } 
  
  if (!isNotEmpty(edit.busi.value)) {
		document.getElementById('busi').innerHTML = 'Please introduce the Business, Ex-/Import.';
		edit.busi.style.backgroundColor='#3976A3'; 
        edit.busi.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.busi.style.backgroundColor='';
	 document.getElementById('busi').innerHTML = '';
  }
  
  if (edit.engine.value == '0') {
		document.getElementById('engine').innerHTML = 'Please select the Engine.';
		edit.engine.style.backgroundColor='#3976A3'; 
        edit.engine.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.engine.style.backgroundColor='';
	 document.getElementById('engine').innerHTML = '';
  }
  
  if (edit.exteriorc.value == '0') {
		document.getElementById('exteriorc').innerHTML = 'Please selct the Exterior Color.';
		edit.exteriorc.style.backgroundColor='#3976A3'; 
        edit.exteriorc.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.exteriorc.style.backgroundColor='';
	 document.getElementById('exteriorc').innerHTML = '';
  }
  
  if (edit.interiorc.value == '0') {
		document.getElementById('interiorc').innerHTML = 'Please select the Interior Color.';
		edit.interiorc.style.backgroundColor='#3976A3'; 
        edit.interiorc.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.interiorc.style.backgroundColor='';
	 document.getElementById('interiorc').innerHTML = '';
  }
  
 if (!emailExp.test(edit.email.value)) {
    document.getElementById('email').innerHTML = 'Please introduce a valid email address.';
	edit.email.style.backgroundColor='#3976A3'; 
	edit.email.style.color='#000000';
    return false;
  }
  else { 
 	 edit.email.style.backgroundColor='';
	 document.getElementById('email').innerHTML = '';
   }
   
   if (edit.fuel.value == '0') {
		document.getElementById('fuel').innerHTML = 'Please select the Fuel Type.';
		edit.fuel.style.backgroundColor='#3976A3'; 
        edit.fuel.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.fuel.style.backgroundColor='';
	 document.getElementById('fuel').innerHTML = '';
  }
  
  if (edit.doors.value == '0') {
		document.getElementById('doors').innerHTML = 'Please select the doors numbers.';
		edit.doors.style.backgroundColor='#3976A3'; 
        edit.doors.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.doors.style.backgroundColor='';
	 document.getElementById('doors').innerHTML = '';
  }
   
  if (edit.mpgcombined.value == '0') {
		document.getElementById('mpgcombined').innerHTML = 'Please select MPG.';
		edit.mpgcombined.style.backgroundColor='#3976A3'; 
        edit.mpgcombined.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.mpgcombined.style.backgroundColor='';
	 document.getElementById('mpgcombined').innerHTML = '';
  }
  
  if (edit.country.value == '0') {
		document.getElementById('country').innerHTML = 'Please select the country.';
		edit.country.style.backgroundColor='#3976A3'; 
        edit.country.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.country.style.backgroundColor='';
	 document.getElementById('country').innerHTML = '';
  }
  
   if (!isNotEmpty(edit.region.value)) {
    document.getElementById('region').innerHTML = 'Please introduce the Region.';
    edit.region.style.backgroundColor='#3976A3';
	edit.region.style.color='#000000';
    return false;
  }
  else { 
  	edit.region.style.backgroundColor=''; 
	document.getElementById('region').innerHTML = '';
  } 
  
   if (!alphaExp.test(edit.city.value)) {
    document.getElementById('city').innerHTML = 'Please introduce the City.';
    edit.city.style.backgroundColor='#3976A3';
	edit.city.style.color='#000000';
    return false;
  }
  else { 
  	edit.city.style.backgroundColor=''; 
	document.getElementById('city').innerHTML = '';
  } 
   if (!numExp.test(edit.zipcod.value)) {
    document.getElementById('zipcod').innerHTML = 'Please introduce the Zipcod.';
    edit.zipcod.style.backgroundColor='#3976A3';
	edit.zipcod.style.color='#000000';
    return false;
  }
  else { 
  	edit.zipcod.style.backgroundColor=''; 
	document.getElementById('zipcod').innerHTML = '';
  } 
   if (!isNotEmpty(edit.location.value)) {
    document.getElementById('location').innerHTML = 'Please introduce the Location.';
    edit.location.style.backgroundColor='#3976A3';
	edit.location.style.color='#000000';
    return false;
  }
  else { 
  	edit.location.style.backgroundColor=''; 
	document.getElementById('location').innerHTML = '';
  } 
   if (!isNotEmpty(edit.description.value)) {
		document.getElementById('description').innerHTML = 'Please introduce a Description.';
		edit.description.style.backgroundColor='#3976A3'; 
        edit.description.style.color='#000000';
    	return false;
  }
  else { 
 	 edit.description.style.backgroundColor='';
	 document.getElementById('description').innerHTML = '';
  }
 
  return true;
}
