// menu needle render 
$(document).ready(function(){
	$("#menu .m_home").click(function() {
		$(".needle").animate({ 
	        marginLeft: "67px",
	      }, 1500, function() { gotoPage('home'); } );
		
	});
	
	$("#menu .m_occasion").click(function() {
		$(".needle").animate({ 
	        marginLeft: "179px",
	      }, 1500, function() { gotoPage('occasions'); } );
	});
	
	$("#menu .m_cosignatie").click(function() {
		$(".needle").animate({ 
	        marginLeft: "324px",
	      }, 1500, function() { gotoPage('consignatie'); } );
	});
	
	$("#menu .m_parts").click(function() {
		$(".needle").animate({ 
	        marginLeft: "526px",
	      }, 1500, function() { gotoPage('parts'); } );
	});
	
	$("#menu .m_contact").click(function() {
		$(".needle").animate({ 
	        marginLeft: "758px",
	      }, 1500, function() { gotoPage('contact'); } );
	});
	
	$(".car_scroller").scrollable({size: 2}).autoscroll({autoplay: true, interval: 4000, steps: 2});

	
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
});

gotoPage = function(page) { 
	switch(page) { 
		case 'home':
			url = 'index.php';
			break;
		case 'occasions':
			url = 'occasions.php';
			break;
		case 'consignatie':
			url = 'consignatie.php';
			break;
		case 'parts':
			url = 'onderdelen_en_goodies.php';
			break;
		case 'contact':
			url = 'contact.php';
			break;	
	}
	window.location = url;
}

editCar = function(carid) { 
	window.location = 'admin.php?occID='+carid;
}

deleteCar = function(carid) {
	var answer = confirm("Weet je zeker dat je dit item wilt verwijderen?")
	if (answer){
		$('#c_'+carid).fadeOut();
		
		$.post("admin.php", { ajax: "true", car: carid },
		function(data){ });
	}
}

deleteLink = function(linkid) {
	var answer = confirm("Weet je zeker dat je dit item wilt verwijderen?")
	if (answer){
		$('#l_'+linkid).fadeOut();
		
		$.post("admin.php", { ajax: "true", link: linkid },
		function(data){ });
	}
}

filterSubmit = function() { 
	$('#filter_form').submit();
}
