function setFilter(type, value) {
	$(type).value=value;
	document.filter_form.submit();
}

function showFilter( list ) {
	hideFilters();
	$(list).style.display = 'block';
}

function hideFilters() {
	hideFilter('brand_list');
	hideFilter('dekade_list');
	hideFilter('location_list');
}

function hideFilter( list ) {
	$(list).style.display = 'none';
}

var cobj;

function changeImage( obj ) {
	
	if( cobj!=undefined){
		cobj.children[0].style.border = "solid #999999 1px";
	}
	
	cobj = obj;
	
	var reg = /\/([^\/]+)\"/;
	var reg1 = /thumbnail_wdg_(.+)\"/i;
	var reg2 = /thumbnail_wsk_(.+)\"/i;
	var ex = reg.exec(obj.innerHTML);
	var ex1 = reg1.exec();
	var ex2 = reg.exec($('vehicle_image_big').innerHTML);

	var str = "_"+obj.children[1].src+"\"";
	var i1 = reg1.exec( reg.exec( $('vehicle_image_big').innerHTML ) );
	var i2 = reg2.exec( reg.exec( str ) );
	
	obj.children[0].style.border = "solid #ff2705 1px";
	
	//obj.innerHTML = "<img src='/data/uploads/thumbnail_wsk_"+i1[1]+"' />"
	$('vehicle_image_big').innerHTML = "<a onclick='return PictureViewer.showPicture(this)' href='/data/uploads/slideshow_"+i2[1]+"' target='_blank'><img style='cursor:pointer;' src='/data/uploads/thumbnail_wdg_"+i2[1]+"' /></a>"
}

function showBP(pic) {
	var reg = /\/([^\/]+)\"/;
	var reg1 = /thumbnail_wdg_(.+)\"/i;
	var str = "_"+pic.src+"\"";
	var i1 = reg1.exec( str );
	showOverlay("slideshow_"+i1[1]);
}

function hideOverlay() {
	$('overlay').style.display = 'none';
	$('popupbox').style.display = 'none';
}

function showOverlay(pic) {
	$('overlay').style.display = 'block';
	$('popupbox').style.display = 'block';
	$('popupbox').children[1].innerHTML = "<img src='data/uploads/"+pic+"' />";
	$('popupbox').setStyle('left', '50%');
	$('popupbox').setStyle('top', '50%');
	$('popupbox').setStyle('margin-left', '-320px');
	$('popupbox').setStyle('margin-top', '-240px');
}

var ref_c=0;

function changeRefs() {
	$('ref_bilder').innerHMTL = "";
	var img = new Element('img', {src:'data/uploads/thumbnail_ref_'+refcars[ref_c].img});
	$('ref_bilder').innerHTML = "<img src='data/uploads/thumbnail_ref_"+refcars[ref_c].img+" />";
	//$('ref_bilder').inject( img );
	//$('ref_bilder').innerHTML = "32423 ->"+ref_c;
	
	if( ref_c == refcars.length-1 ) {
		ref_c=0;
	} else {
		ref_c++;
	}
	
	window.setTimeout( changeRefs, 5000 );
}

var gallery_images=Array();
var current_gallery_index = 0;

function prev() {
	current_gallery_index--;
	if(current_gallery_index<0) {
		current_gallery_index = gallery_images.length-1;
	}
	
	showImageById(current_gallery_index);
}

function next() {
	current_gallery_index++;
	if(current_gallery_index > gallery_images.length-1) {
		current_gallery_index = 0;
	}

	showImageById(current_gallery_index);
}

function showImageById( id ) {
	$('popupbox').children[1].innerHTML = "<img src='data/uploads/slideshow_"+gallery_images[id]+"' />";
}

function getImageByIndex( id ) {
	
}

function getIndexByName( str ) {
	return 1;
}
