//=============================================================================
TSaylor = {};

//=============================================================================
TSaylor.OnInit = function() {
	$("a[rel^=Lightbox]").lightBox();
	
	// Main menu hovers
	$(".MenuItem").hover(function(){
		//$(this).css("color", "#ffffff");
		//$(this).css("background-color", "#406285");
		$(this).css("text-decoration", "underline");
	}, function(){
		//$(this).css("color", "#000000");
		//$(this).css("background-color", "transparent");
		$(this).css("text-decoration", "none");
	});
	
	// Quick Quote textbox defaults
	$('#QuickQuoteForm .Textbox277').focus(function(){
		if($(this).attr('value') == "Quote Question") { $(this).attr('value', ''); }
	}).blur(function(){
		if($(this).attr('value') == "") { $(this).attr('value', 'Quote Question'); }
	});
	
	// Stay In Touch checkboxes
	$('#StayInTouchForm .Checkbox').click(function(){
		if($(this).hasClass('Checked')) {
			$(this).removeClass('Checked');
			$(this).children('input').attr('value', '0');
		} else {
			$(this).addClass('Checked');
			$(this).children('input').attr('value', '1');
		}
	});
}

//-----------------------------------------------------------------------------
TSaylor.SearchGo = function() {
	var Keywords = $('#SiteSearchForm #Query').attr('value');

	Keywords = Keywords.replace(/\//g, "-");

	document.location.href = '/search/' + Keywords;
}

//=============================================================================
TSaylor.AddToCart = function(ProductID) {
	var NormalID			= parseInt($("#NormalOptionID").attr("value"));
	var Quantity			= parseInt($("#Quantity").attr("value"));
	var ProductsShippingMethodsID = parseInt($("#ProductsShippingMethodsID").attr("value"));
	var Max					= parseInt($("#Max").attr("value"));

	if(Quantity <= 0) {
		alert("Please enter a valid quantity.");
		$("#Quantity").focus();
		return;
	}else
	if(Quantity > Max && Max > 0) {
		alert("You are not allowed to purchase more than " + Max + " of this product.");
		$("#Quantity").attr("value", Max);
		$("#Quantity").focus();
		return;
	}

	var Parms = {
		"ProductsID"			: ProductID,
		"ProductsShippingMethodsID" : ProductsShippingMethodsID,

		"NormalOptionID"		: NormalID,
		"ImprintOptionID"		: 0,
		"NumColors"				: 0,

		"NormalOptionColors"	: JSON.stringify({}),
		"ImprintOptionColors"	: JSON.stringify({}),

		"Quantity"				: Quantity,

		"Artwork"				: "None"
	};

	MCarts.AddToCart(Parms, function(Code, Content) {
		if(Code == 1) {
			window.location.href = "/viewcart.php";
		}else{
			alert(Content);
		}
	})
}

//=============================================================================
$(TSaylor.OnInit);

//=============================================================================

