function visi(nr, hide)
{
	if (document.layers)
	{
		vista = (hide) ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (hide) ? 'visible'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (hide) ? 'visible' : 'hidden';
		document.getElementById(nr).style.visibility = vista;

	}
}

function disp1(nr, hide)
{
	if (document.layers)
	{	
		vista = (hide) ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (hide) ? ''	: 'none';
		document.all[nr].style.display= vista;
	}
	else if (document.getElementById)
	{
		vista = (hide) ? '' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

function filterPrice(priceFilter, startPrice, endPrice) {
	var formObj = document.fastCarSearch;
	formObj.priceFilter.value = priceFilter;
	formObj.priceFrom.value = startPrice;
	formObj.priceTo.value = endPrice;
	submitFastCarSearch();
}


function populateModels(manufacturer) {
	/*if (location.href.indexOf("/personenautos.html") >= 0 ||
			location.href.indexOf("/MPV_en_Familycars.html") >= 0 ||
			location.href.indexOf("/Hybrides.html") >= 0) {
		document.fastCarSearch.action = '/Occasions_en_nieuw/alle_autos.html';
	} else {
		document.fastCarSearch.action = location.href;
	}*/
	document.fastCarSearch.action = '/Occasions_en_nieuw/Snel_een_auto_zoeken.html';
	document.fastCarSearch.submit();
}

function submitFastCarSearch() {
	//if (location.href.indexOf("/Occasions_en_nieuw/") != -1) {
		//document.fastCarSearch.action = location.href;
	//}
	document.fastCarSearch.action = '/Occasions_en_nieuw/Snel_een_auto_zoeken.html';
	document.fastCarSearch.submit();
}


var highlite_store;

/* Stores the style classname and sets a new one */
function highlite(obj) {
	highlite_store = obj.className;
	obj.className = 'results-overrow';
}

/* Restores the stored style classname */
function highlite_out(obj) {
	obj.className = highlite_store;
}
function n_over(x) {
    ChangeTextColor(x, 'red');
}
function n_out(x) {
    ChangeTextColor(x, '#000000');
}

function ChangeTextColor(a_obj,a_color){  ;
	for (i=0;i<a_obj.cells.length;i++){/* put condition before increase!!!!! */
		a_obj.cells(i).style.color=a_color;
	}
}
function showCar(carId, detailsLimitstart) {
	document.advanceSearch.carId.value= carId;
	document.advanceSearch.detailsLimitstart.value= detailsLimitstart;
	document.advanceSearch.fromURL.value= location.href;
	document.advanceSearch.action = '/index.php?option=com_carsearch&task=car_details&carId=' + carId;
	document.advanceSearch.submit();
}

function paginate(limit, limitstart) {
	document.advanceSearch.action= location.href;
	document.advanceSearch.limitstart.value = limitstart;
	document.advanceSearch.limit.value = limit;
	document.advanceSearch.submit();
}

function sort(columnId, ascending) {
	document.advanceSearch.action= location.href;
	document.advanceSearch.sortColumnId.value = columnId;
	document.advanceSearch.sortAscending.value = ascending;
	document.advanceSearch.submit();
}

function populateAdvanceModels(manufacturer) {
	document.advanceSearch.action = "/index.php?option=com_carsearch&task=search_form&Itemid=" + itemId;
	document.advanceSearch.submit();
}

function showAdvanceAll() {
	resetAdvanceMe();
	document.advanceSearch.action = "/index.php?option=com_carsearch&task=search_results&Itemid=" + itemId;
	document.advanceSearch.submit();
}
function resetAdvanceMe() {
	var formObj = document.advanceSearch;
	formObj.searchType[0].checked = 'true';
	formObj.manufacturer.selectedIndex = '0';
	formObj.model.selectedIndex = '0';
	formObj.carSubType.value = '-1';
	formObj.fuelType.selectedIndex = '0';
	formObj.transmissionType.selectedIndex = '0';
	formObj.priceFrom.selectedIndex = '0';
	formObj.priceTo.selectedIndex = '0';
	formObj.drivenKMFrom.selectedIndex = '0';
	formObj.drivenKMTo.selectedIndex = '0';
	formObj.yearFrom.selectedIndex = '0';
	formObj.yearTo.selectedIndex = '0';
}