var got_cars = new Array();

          function togDisplay(id) {
            var style = document.getElementById(id).style;
      
            if (style.display == 'none') {
              style.display = 'block';
            } else {
              style.display = 'none';
            }
          }



function processGetPost() {
        var myajax=ajaxpack.ajaxobj
        var myfiletype=ajaxpack.filetype
        if (myajax.readyState == 4){ //if request of file completed
                if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
             		if (myfiletype=="txt") {
				document.getElementById(targetID).innerHTML = myajax.responseText;
                	} else {
                	        alert(myajax.responseXML)
			}
                }
        }
}

          var targetID;

          function togSummaryDetails(summary, details, maker_F, model_F, registration_number, teletext_phone_number_1, from_price_F, to_price_F, from_age_F, to_age_F, body_type_F, proximity_F, email_F, teletext_client_yn, town, county, location, selling_point, dealer_group_id_in)
          {
            togDisplay(summary);
            togDisplay(details);
            if (document.getElementById(summary).style.display == 'none') {
              current_car_id = details.substr(8);
              if (!got_cars[current_car_id]) {
		targetID = details;
                ajaxpack.getAjaxRequest('/ajax-vehicle-details.php', 'car_id_F='+escape(current_car_id)+'&maker_F='+maker_F+'&model_F='+model_F+'&registration_number_F='+escape(registration_number)+'&teletext_phone_number_1='+escape(teletext_phone_number_1)+'&from_price_F='+from_price_F+'&to_price_F='+to_price_F+'&from_age_F=' + from_age_F + '&to_age_F=' + to_age_F + '&body_type_F=' + body_type_F + '&proximity_F=' + proximity_F + '&email_F='+escape(email_F)+'&teletext_client_yn='+teletext_client_yn+'&town_F='+escape(town)+'&county_F='+escape(county)+'&location_F='+escape(location)+'&selling_point_F='+selling_point+'&dealer_group_id_in_F='+dealer_group_id_in, processGetPost, 'txt');
                got_cars[current_car_id] = 1;
              }
            }
          }
					
function refine_search_results(sorted, transmission, fuel, keyword, maker, model, from_price, to_price, postcode, distance, email, id, action) {
	document.refine_form.per_page_param.disabled = true;
	document.refine_form.sort_by_param.disabled = true;
	//document.search_form.transmission_F.value = transmission;
	//document.search_form.fuel_F.value = fuel;
	//document.search_form.keyword_F.value = keyword;
	//document.search_form.maker_F.value = maker;
	//document.search_form.model_F.value = model;
	//document.search_form.from_price_F.value = from_price;
	//document.search_form.to_price_F.value = to_price;
	//document.search_form.postcode_F.value = postcode;
	//document.search_form.distance_F.value = distance;
	//document.search_form.email_F.value = email;
	
	//if (action) document.search_form.action = action;
	
	document.refine_form.cars_per_page_F.value = document.refine_form.per_page_param.value;
	document.refine_form.sort_order_F.value = document.refine_form.sort_by_param.value;

	if (sorted == 'Y' && document.refine_form.sort_by_param.value != 'S')
	{
		document.refine_form.sorted_F.value = 'Y';
	}
	else 
	{
		document.refine_form.sorted_F.value = 'N';
	}

	// To display both C2C and private results
	document.refine_form.sorted_F.value = 'Y';

	document.refine_form.submit();
}

function cf_refine_search_results() {
    if (!validate_email (document.newCarFinder.new_email_F.value) || document.newCarFinder.new_email_F.value == 'Enter email address here...' && document.newCarFinder.new_email_F.value == '') {
        alert("Please, enter a valid email address.");
    } else {
        document.search_form.cf_from_F.value = 'Y';
        document.search_form.email_F.value = document.newCarFinder.new_email_F.value;
        document.search_form.submit();
    }
}
