// JavaScript Document for Sokol Layout
var blShowroomVisible = false;

function InitShowroom() {
	$("#divShowroom").click(function() {
		if(blShowroomVisible) {
			blShowroomVisible = false;
			$("#divShowroomInfo").slideUp();
		} else {
			blShowroomVisible = true;
			$("#divShowroomInfo").slideDown();
		}
	});
}



//FEATURE BOX
//var intSliderX, intSliderWidth, t;
var arSliderX = new Array();
var arSliderWidth = new Array();
var arT = new Array();

function InitSlider(strBoxId) {
//	if ($("#".strBoxId).length) {
		//element exists
		var position = $("#"+strBoxId+" .slider").position();
		arSliderX[strBoxId] = position.left;
		arSliderWidth[strBoxId] = $("#"+strBoxId+" .slider").width();
		if(arSliderWidth[strBoxId]<=blBodyWidth) {
			$("#"+strBoxId+" .scrollLeft").hide();
			$("#"+strBoxId+" .scrollRight").hide();
		} else {
			ResetTimer(strBoxId);
			//set button actions
			$("#"+strBoxId+" .scrollLeft").click(function() {
				Slide('left', strBoxId);
			});
			$("#"+strBoxId+" .scrollRight").click(function() {
				Slide('right', strBoxId);
			});
		}
//	}
}
function Slide(strDir, strBoxId) {
	var intDir;
	if(strDir=="left")	intDir = 560;
	else				intDir = -560;
	arSliderX[strBoxId] += intDir;
	
	if(arSliderX[strBoxId]>0)										arSliderX[strBoxId] = -(arSliderWidth[strBoxId]-560);
	else if(Math.abs(arSliderX[strBoxId]) > (arSliderWidth[strBoxId]-560))	arSliderX[strBoxId] = 0;
	
	$("#"+strBoxId+" .slider").animate({left:arSliderX[strBoxId]}, 500, function() {
		ResetTimer(strBoxId);
	});
}
function ResetTimer(strBoxId) {
	$("#"+strBoxId+" .slider").stop();
	clearTimeout(arT[strBoxId]);
	arT[strBoxId] = setTimeout("Slide('right', '"+strBoxId+"')",15000);
}

