

// -----------------------------------------------------------------------------
// COLLECTION SCROLLER
// -----------------------------------------------------------------------------

var speed;
var doScroll;
var widthScrollContainer;

jQuery(document).ready(function() {
	$("#scrollLeft").mouseover(function() {
		speed = -6;
		doScroll = setInterval("scroll()", 15);
	}).mouseout(function() {
		speed = 0;
		clearInterval(doScroll);
	});

	$("#scrollRight").mouseover(function() {
		speed = 6;
		doScroll = setInterval("scroll()", 15);
	}).mouseout(function() {
		speed = 0;
		clearInterval(doScroll);
	});
});

function scrollerInit(width) {
	if (width < 756) {
		$("#scrollContent").css("width", width + "px").css("margin", "0 auto");
		$(".scrollArrow").css("visibility", "hidden");
		widthScrollContainer = width;
	} else 	{
		widthScrollContainer = 756;
	}
}

function scroll() {
	if (speed != 0)
	{
		var $container= $("#scrollerContainer");
		var scrollWidth = $container[0].scrollWidth
		var scrollLeft = $container.scrollLeft();
		
		if (scrollLeft > (2/3*scrollWidth))	{
			$container.scrollLeft($container.scrollLeft() - (1/3*scrollWidth) + speed);
		} else if (scrollLeft < (1/3*scrollWidth ))					{
			$container.scrollLeft($container.scrollLeft() + (1/3*scrollWidth) + speed);
		} else {

			$container.scrollLeft($container.scrollLeft() + speed);
		}
	}
}

// -----------------------------------------------------------------------------
// ???
// -----------------------------------------------------------------------------

// -- ??? ---
var hoverup = false;
jQuery(document).ready(function() {
	$("#shareContent").hover(function() {
		hoverup = true;
	}, function() {
		hoverup = false;
	});

	$("#share").click(function() {
		hoverup = true;
		$("#shareContent").css("display", "block");
	});

	$(window).click(function() {
		if (hoverup == false)
		{
			$("#shareContent").css("display", "none");
		}
	});

	// --- productInfo table tomfoolery ---
	
	$("#topMenu li:last").css("border-right", "0px");
	$("#fabricSmall").mouseover(function() {
		$("#fabricPopup").css("display", "block");

	}).mouseleave(function() {
		$("#fabricPopup").css("display", "none");
	});

	$("#fabricPopup").mouseover(function() {
		$("#fabricPopup").css("display", "block");

	}).mouseleave(function() {
		$("#fabricPopup").css("display", "none");
	});

	$("#productInfo table:first").css("width", "160px");

	$("#productInfo table:eq(2)").addClass("sizes");
	$(".sizes tr").each(function() {
		$(this).children("td").eq(0).css( { textAlign: "left", paddingLeft: "0px" });
	});
	$(".sizes tr").css( { background: "url('images/borderBottom.png') repeat-x bottom" } );
	$(".sizes tr:last").css( { background: "none" } );
	$(".sizes tr").children("td").css( { paddingBottom: "10px",paddingTop: "10px" } );

	$("#footer tr:first").css("background", "url('images/borderBottom.png') repeat-x bottom");
	$("#footer tr:first td").css("paddingBottom", "5px");
	$("#footer tr:last td").css("paddingTop", "5px");
	
	// --- ---
	
	$("#aboutsubmenu").css("left", $("#menuabout").position().left + "px");

	$(".leftMenuSubitem").css("height", $(".leftMenuSubitemoverlay").height() + "px");

	$("#languages").mouseleave(function() {
		$("#otherLanguages").css("display", "none");
	});

	
	$(".section2link:last").css("background", "transparent");
});

// -----------------------------------------------------------------------------
// CONTACT
// -----------------------------------------------------------------------------

var uploadifyUploaded = true;
var submitAfterUpload = false;

function uploadifyInit(opts)
{
	$('#file_upload').uploadify({
		'uploader'  : 'uploadify.swf',
		'script'    : opts.script,
		'cancelImg' : 'images/cancel.png',
		'folder'    : '',
		'auto'      : true,
		'height' : '17',
		'buttonImg'   : opts.buttonImg,
		'rollover'    : true,
		'removeCompleted' : false,
		onSelect: function (event, ID, fileObj) {
			uploadifyUploaded = false;
		},
		onComplete: function (a, b, c, d, e) {
			$("#file").val(d);
			uploadifyUploaded = true;
			if (submitAfterUpload == true)
			{
				document.getElementById("contact").submit();
			}
		}
	});
}

// -----------------------------------------------------------------------------
// MISC
// -----------------------------------------------------------------------------

function menuAboutInit()
{
	$("#menuabout").mouseover(function() {
		$("#aboutsubmenu").css("display", "block");
	}).mouseleave(function() {
		$("#aboutsubmenu").css("display", "none");
	});

	$("#aboutsubmenu").mouseover(function() {
		$("#aboutsubmenu").css("display", "block");
	}).mouseleave(function() {
		$("#aboutsubmenu").css("display", "none");
	});
}

function language() {
	$("#otherLanguages").css("display", "block");
}


// -----------------------------------------------------------------------------
// SERVICE
// -----------------------------------------------------------------------------

function showService() {
	$("#overlay").css("display", "block");
	document.getElementById("marketingtoolFrame").src = 'marketingtool.php';
}

function hideService() {
	$("#overlay").css("display", "none");
}
