var paneSize = 711;
var paneActive = false;

function lastPane() {
	if (!paneActive) {
		var oldLeft = parseInt($("#showroom-container-inner").css("left"));

		if (isNaN(oldLeft)) oldLeft = 0;
		var newLeft = parseInt(oldLeft)+paneSize;

		if (newLeft <= 0) {
			paneActive = true;
			$("#showroom-container-inner").animate({left:newLeft+"px"}, 1000, function() { paneActive = false; });
			trackEvent('Homepage', 'Showroom', 'Scroll Back');
		}
	}
}

function nextPane() {
	if (!paneActive) {
		var oldLeft = parseInt($("#showroom-container-inner").css("left"));

		if (isNaN(oldLeft)) oldLeft = 0;
		var newLeft = parseInt(oldLeft)-paneSize;

		if (newLeft > -(numPanes*paneSize)) {
			paneActive = true;
			$("#showroom-container-inner").animate({left:newLeft+"px"}, 1000, function() { paneActive = false; });
			trackEvent('Homepage', 'Showroom', 'Scroll Forward');
		}
	}
}

function toggleCheck(checkObj, groupName) {
	
	$chk = $(checkObj);
	var newChk = ($chk.attr("checked") == true) ? true:false;

	if ($chk.attr("id") == groupName+"_all") {
		var $allChks = $("input[name='"+groupName+"']");
		$allChks.attr("checked", newChk);
	} else {
		//if (newChk) $("#"+groupName+"_all").attr("checked", false);
	}


}

function filterVehicles(checkObj, vType) {
	$chk = $(checkObj);
	var chkVal = ($chk.attr("checked") == true) ? true:false;
	var childType = (vType == undefined) ? '':'.'+vType;

	if (chkVal) {
		$("#showroom-container-inner div"+childType).find("img, div").show();
		$("#showroom-container-inner div"+childType).animate({width:"167px"}, 500);
	} else {
		$("#showroom-container-inner div"+childType).animate({width:"0px"}, 500, function() {
			$(this).find("img, div").hide();
		});
	}
}