
// JavaScript Document


// drop down menu
$(document).ready(function() {
	$("li", "#topnav").hover(function(){
        $("ul", this).css("display", "block");     
    }, function(){
        $("ul", this).css("display", "none");
    });	

	
	$('.finance-tooltip-trigger').bind('mouseenter', function(){ $('.finance-tooltip').fadeIn(); });
	$('.finance-tooltip-trigger').bind('mouseleave', function(){ $('.finance-tooltip').fadeOut(); });
});


function inlineSearch(location) {
	var url = 'http://www.gkgroup.co.uk/'+location+'/search/?inline=true&keywords='+$('#keywords').val()+'&location1='+$('#location').val()+'&make='+$('#make').val()+'&model='+$('#model').val()+'&fuel='+$('#fuel').val()+'&transmission='+$('#transmission').val()+'&minprice='+$('#minprice').val()+'&maxprice='+$('#maxprice').val()+'&minage='+$('#minage').val()+'&maxage='+$('#maxage').val()+'&cartype='+$('#cartype').val()+'&vans='+$('#vans').val();
	$.ajax({
		type: "get",
		url: url,
		cache: false,
		success: function(data)
				 {
					$("#searchresults").css("display", "inline");
					$("#searchresultsNum").html(data);
				 }
	});
}

function resetform()
{
 	document.getElementById("make").value = 0;
	document.getElementById("model").value = 0;
	document.getElementById("minprice").value = 0;
	document.getElementById("maxprice").value = 0;
	document.getElementById("fuel").value = 0;
	document.getElementById("transmission").value = 0;
	document.getElementById("cartype").value = 0;	
	$("#searchresults").hide();
}


function doFilterForm()
{
 	document.filterform.submit();
}

function enquiryDropDown()
{

	if (document.getElementById("contactreason").value == 3) {
		
		$("partexchangeyesno").setStyle('display: block;');
		$("stocksearch_form").setStyle('display: none;');
		this.partexDropDown();
		
		
	} else if (document.getElementById("contactreason").value == 5) {
		$("partexchangeyesno").setStyle('display: none;');
		$("stocksearch_form").setStyle('display: block;');
		$("partexbool").value = 0;	
		this.partexDropDown();
		
	} else {
		
		$("partexbool").value = 0;
		$("partexchangeyesno").setStyle('display: none;');
		$("stocksearch_form").setStyle('display: none;');
		this.partexDropDown();
	}
	
	
}

function partexDropDown()
{
	
	if ((document.getElementById("partexbool").value == 1) || (document.getElementById("contactreason").value == 4)) {
		
		$("partexchange_form").setStyle('display: block;');
		
	} else {
	
		$("partexchange_form").setStyle('display: none;');
		
	}
}


function clearBox(input) {
	if(input.value=input.defaultValue) {
		input.value = '';	
	}
}

function resetBox(input) {
	if(!input.value) {
		input.value = input.defaultValue;	
	}
}

function toggleSearch()
{
	$(".advancedSearch").slideToggle();
}
