var currentCat;

$(document).ready(function() {
	$("#nav a, #topNav a, #footerNav a, #subnav a, a.button").hover(
				// over
				function(){
					// store the original image src
					$(this).children(":first-child").attr( "originalsrc" , $(this).children(":first-child").attr("src") );
					
					// add -over to the image unless it is already -over
					if (!$(this).children(":first-child").attr("src").match(/-over/) ) {
						$(this).children(":first-child").attr( "src", $(this).children(":first-child").attr("src").replace(/\./, "-over.") );
					}
					
				},
				
				// out
				function(){
					// replace the original src
					$(this).children(":first-child").attr(
						"src", $(this).children(":first-child").attr("originalsrc")
					);
					
					$(this).children(":first-child").attr(
						"originalsrc", null
					);
				}
			);
	
/*	$('a[@rel*=lightbox]').lightBox({
		imageLoading: '/images/lightbox/lightbox-ico-loading.gif',
		imageBtnClose: '/images/store/buttons/icon_close.gif',
		imageBtnPrev: '/images/lightbox/lightbox-btn-prev.gif',
		imageBtnNext: '/images/lightbox/lightbox-btn-next.gif',
		imageBlank  : '/images/lightbox/lightbox-blank.gif'
	});
*/
	
	
	$("a.bookNav, #sectionLinks a").click(function() {
		var theDiv = $(this).attr("href").substring(1);
		theDiv = theDiv.replace('\/','');
		showSection(theDiv);
	});
			
	
	// accordian
		$("#storeSubNav li ul").hide();
		$("#storeSubNav .head").click(function(){
			$("#storeSubNav li ul:visible").slideUp("slow");
			$(this).next().slideDown("slow");
			return false;
		});
	
	if (currentCat) {
		if ((currentCat == 'candy') || (currentCat == 'disco') || (currentCat == 'orchid') || (currentCat == 'swirling')) {
			$("#spring").next().show();
		};
		
		$("#" + currentCat).children(":first-child").attr( "src", $("#" + currentCat).children(":first-child").attr("src").replace(/\./, "-over.") );
	}
	
});

window.onload = function() {
		// preload
		$("#nav a img, #topNav a img, #footerNav a img, #subnav a img, a.button img").each(
			function() {
				if (!$(this).attr("src").match(/-over/) ) {
					$("<img>").attr( "src", $(this).attr("src").replace(/\./, "-over.") );
				}
			}
		);
}



function showSection(theDiv) {
	$("#sections .section:visible").hide();
	// show the subpage
	$("#" + theDiv).fadeIn("slow");
}


// MLM FORM
function CheckMultiple1(frm, name) {
				for (var i=0; i < frm.length; i++)
				{
					fldObj = frm.elements[i];
					fldId = fldObj.id;
					if (fldId) {
						var fieldnamecheck=fldObj.id.indexOf(name);
						if (fieldnamecheck != -1) {
							if (fldObj.checked) {
								return true;
							}
						}
					}
				}
				return false;
			}
		function CheckForm1(f) {
			if (f.email.value == "") {
				alert("Please enter your email address.");
				f.email.focus();
				return false;
			}
		
				return true;
			};