var currentSlide = ["#slider-a","#slider-b","#slider-c","#slider-d",];
var slideArrayNumber = 0;
var slideArrayNumber2 = 1;
var currentSlide = ["#slider-a","#slider-b","#slider-c","#slider-d",];
var slideArrayNumber = 0;
var slideArrayNumber2 = 1;
var newArrayNumber = 1;
var sliderStatus = ("play");
var currentBox = ("#fob-box");
var currentTab = ("#fob-tab");
var currentImage = ("#image-a");
var currentThumb = ("#a img");
var pass = ("flash");
var currentDialog = ("nil");
var imgHeight;
var imgWidth;
var marginTop = (0);
var marginLeft = (0);
var productImgName;
var image1Width;
var image1Height;
var image2Width;
var image2Height;
var image3Width;
var image3Height;
var image4Width;
var image4Height;
var thumb1Width;
var thumb1Height;
var thumb2Width;
var thumb2Height;
var thumb3Width;
var thumb3Height;
var thumb4Width;
var thumb4Height;
var finfabHeight;
var finfabWidth;


$('document').ready(function() {
		$("#image-a, #image-b, #image-c, #image-d").css("display","block");
		$("#a, #b, #c, #d, #e").css("display","block");
		$("#dialog-box").css("display","block");
		$("#slider-box").css("display","block");
		$('#product-info-box').css("display","block");
		$('#popup-box-container').css("display","block");
		$("#modal-overlay").css("display","block");
		$("#product-image-enlarged").css("display", "block");
		$("#b img, #c img, #d img, #e img").css("opacity","0.4").css("filter","alpha(opacity=40)");
		$("#modal-overlay").hide();
		$("#dialog-box, #dialog-inner-box, #login, #header-help-fob, #header-help-zone1, #header-help-zone2, #x").hide();
		$("#product-image-enlarged").hide();
		$("image-enlarged").hide();
		$("#slider-b, #slider-c, #slider-d").hide();
		$("#image-b, #image-c, #image-d, #image-e").hide();
		$('#product-info-box').hide();
		$('#popup-box-container').hide();
		$("#slide-spacer").css("height","200px");
		
// Cookie Setup
		if($.cookie("password")== pass) {
			$(".pass").css("display","block");
			$(".no-pass").css("display","none");
			$("#enter-password").css("display","none");
			$(".price-hide, .yPsmNum").css("display","block");
			$(".hide-button").css("display","none");
			$(".show-button").css("display","block");
			$(".price").css("display","inline");
			$(".strikethrough").css("display","inline");
			$("#search-visibility").css("display","inline");
			$(".mainItName").css("width","190px");
			$(".multiName").css("width","200px");
			$(".csPr, .mainItQu, .multiQuantity, .mainItPr, .mainItSl, .multiDropdown, #embTableOfCh, #embTableChurchChairs, #collectionSamples, #custEmbButton, #customItemBox").show();
			$("#hideMeOnLogin").hide();
}
		else {
			$(".pass").css("display","none");
			$("#hideMeOnLogin").show();
			$(".no-pass").css("display","block");
			$("#enter-password").css("display","block");
			$(".price-hide, .yPsmNum").css("display","none");
			$(".hide-button").css("display","block");
			$(".show-button").css("display","none");
			$(".price").css("display","none");
			$(".strikethrough").css("display","none");
			$(".radfive").css("display","none");
			$(".radseven").css("display","none");
			$(".radeight").css("display","none");
			$(".mainItName").css("width","340px");
			$(".multiName").css("width","270px");
			$(".csPr, .mainItQu, .multiQuantity, .mainItPr, .mainItSl, .multiDropdown, #embTableOfCh, #embTableChurchChairs, #collectionSamples, #custEmbButton, #customItemBox").hide();

		}
		
// Slide Scroller
		$("#slideshow").click(function() {
		
			});
			$('#slideshow').after('<div id="nav">').cycle({
				fx: 'scrollLeft',
				next: '#slideshow',
				easing: 'backinout',
				timeout: '3500',
				pager: '#nav'
				});
			$('#pause').click(function() { 
			$('#slideshow').cycle('pause'); 
				});
			$('#play').click(function() { 
			$('#slideshow').cycle('resume'); 
			});
	
		
		
// Log-in
	$("form").submit(function() {
		if ($("input:first").val().toLowerCase() == pass) {
			$.cookie("password", pass);
			$("#dialog-box").fadeOut("fast");
			$("#dialog-inner-box").fadeOut("fast");
			$("#header-help-fob").fadeOut("fast");
			$("#login").fadeOut("fast");
			$("#modal-overlay").fadeOut("fast");
			$("#x").fadeOut("fast");
			$(".pass").css("display","block");
			$(".no-pass").css("display","none");
			$("#enter-password").hide();
			$("#pass-field").val("");
		}
		else {
			$("#pass-field").val("");
			$("#notify").text("Password incorrect. Please try again.").show();
		}
	});
	
	
	
	
	
// Zone Tabs
		$('#fob-tab').click(function() {
		if(("#fob-box") == currentBox) {
		}
		else {
			$(currentTab).css("border-bottom","1px solid #dfdad4");
			$(currentTab).css("height","24px");
			$(currentTab).css("background","#f9f8f6");
			$("#fob-tab").css("border-bottom","none");
			$("#fob-tab").css("height","28px");
			$("#fob-tab").css("background","#ffffff");
			$(currentBox).hide();
			$('#fob-box').show();
			currentBox = "#fob-box";
			currentTab = "#fob-tab";
		}
	});
	$('#zone1-tab').click(function() {
		if(("#zone1-box") == currentBox) {
		}
		else {
			$(currentTab).css("border-bottom","1px solid #dfdad4");
			$(currentTab).css("height","24px");
			$(currentTab).css("background","#f9f8f6");
			$("#zone1-tab").css("border-bottom","none");
			$("#zone1-tab").css("height","28px");
			$("#zone1-tab").css("background","#ffffff");
			$(currentBox).hide();
			$('#zone1-box').show();
			currentBox = "#zone1-box";
			currentTab = "#zone1-tab";
		}
	});
	$('#zone2-tab').click(function() {
		if(("#zone2-box") == currentBox) {
		}
		else {
			$(currentTab).css("border-bottom","1px solid #dfdad4");
			$(currentTab).css("height","24px");
			$(currentTab).css("background","#f9f8f6");
			$("#zone2-tab").css("border-bottom","none");
			$("#zone2-tab").css("height","28px");
			$("#zone2-tab").css("background","#ffffff");
			$(currentBox).hide();
			$('#zone2-box').show();
			currentBox = "#zone2-box";
			currentTab = "#zone2-tab";
		}
	});
	$('#product-info-tab').click(function() {
		if(("#product-info") == currentBox) {
		}
		else {
			$(currentTab).css("border-bottom","1px solid #dfdad4");
			$(currentTab).css("height","24px");
			$(currentTab).css("background","#f9f8f6");
			$(this).css("border-bottom","none");
			$(this).css("height","28px");
			$(this).css("background","#ffffff");
			$(currentBox).hide();
			$('#product-info-box').show();
			currentBox = "#product-info-box";
			currentTab = "#product-info-tab";
		}
	});


//Popup controls
	$(".open-popup").click(function() {
		$("#popup-box-container").fadeIn("fast");
	});
	
	$(".close-popup").click(function() {
		$("#popup-box-container").fadeOut("fast");
	});
	
	
// Image Gallery
	$("#a").click(function() {
		if(("#a img") == currentThumb) {
			
		}
		else {
			$(currentThumb).css("opacity","0.4").css("filter","alpha(opacity=40)");
			$(currentImage).fadeOut("normal");
			$("#a img").css("opacity","1").css("filter","alpha(opacity=100)");
			$("#image-a").fadeIn("normal", function() {		
				currentImage = ("#image-a");
				currentThumb = ("#a img");
			});
		}
	});
	
	$("#b").click(function() {
		if(("#b img") == currentThumb) {
			
		}
		else {
			$(currentThumb).css("opacity","0.4").css("filter","alpha(opacity=40)");
			$(currentImage).fadeOut("normal");
			$("#b img").css("opacity","1").css("filter","alpha(opacity=100)");
			$("#image-b").fadeIn("normal", function() {
				currentImage = ("#image-b");
				currentThumb = ("#b img");
			});
		}
	});
	
	$("#c").click(function() {
		if(("#c img") == currentThumb) {
			
		}
		else {
			$(currentThumb).css("opacity","0.4").css("filter","alpha(opacity=40)");
			$(currentImage).fadeOut("normal");
			$("#c img").css("opacity","1").css("filter","alpha(opacity=100)");
			$("#image-c").fadeIn("normal", function() {
				currentImage = ("#image-c");
				currentThumb = ("#c img");
			});
		}
	});
	
	$("#d").click(function() {
		if(("#d img") == currentThumb) {
			
		}
		else {
			$(currentThumb).css("opacity","0.4").css("filter","alpha(opacity=40)");
			$(currentImage).fadeOut("normal");
			$("#d img").css("opacity","1").css("filter","alpha(opacity=100)");
			$("#image-d").fadeIn("normal", function() {
				currentImage = ("#image-d");
				currentThumb = ("#d img");
			});
		}
	});
	
	$("#e").click(function() {
		if(("#e img") == currentThumb) {
			
		}
		else {
			$(currentThumb).css("opacity","0.4").css("filter","alpha(opacity=40)");
			$(currentImage).fadeOut("normal");
			$("#e img").css("opacity","1").css("filter","alpha(opacity=100)");
			$("#image-e").fadeIn("normal", function() {
				currentImage = ("#image-e");
				currentThumb = ("#e img");
			});
		}
	});

// Mouse-over Cursor Change
	$("#a, #b, #c, #d, #e, .goto-login, #logout, #x, #x2, #fob-tab, #zone1-tab, #zone2-tab, #product-info-tab").mouseover(function() {
		$(this).css("cursor","pointer");
	});
	$("#a, #b, #c, #d, #e, .goto-login, #x, #x2, #fob-tab, #zone1-tab, #zone2-tab, #product-info-tab").mouseout(function() {
		$(this).css("cursor","auto");
	});
	
	$("#help-fob, #help-zone1, #help-zone2").mouseover(function() {
		$(this).css("cursor","help");
	});
	$("#help-fob, #help-zone1, #help-zone2").mouseout(function() {
		$(this).css("cursor","auto");
	});

// Dialogue Boxes
	$("#help-fob").click(function() {
		$("#modal-overlay").fadeIn("fast");
		$("#dialog-box").fadeIn("fast");
		$("#dialog-inner-box").fadeIn("fast");
		$("#header-help-fob").fadeIn("fast", function() {
			currentDialog = ("#header-help-fob");
		});
		$("#x").fadeIn("fast");
	});
		
	$("#help-zone1").click(function() {
		$("#modal-overlay").fadeIn("fast");
		$("#dialog-box").fadeIn("fast");
		$("#dialog-inner-box").fadeIn("fast");
		$("#header-help-zone1").fadeIn("fast", function() {
			currentDialog = ("#header-help-zone1");
		});
		$("#x").fadeIn("fast");
	});
		
	$("#help-zone2").click(function() {
		$("#modal-overlay").fadeIn("fast");
		$("#dialog-box").fadeIn("fast");
		$("#dialog-inner-box").fadeIn("fast");
		$("#header-help-zone2").fadeIn("fast", function() {
			currentDialog =("#header-help-zone2");
		});
		$("#x").fadeIn("fast");
	});



// Log-in Box
	$(".goto-login").click(function() {
		$("#modal-overlay").fadeIn("fast");			
		$("#dialog-box").fadeIn("fast");
		$("#dialog-inner-box").fadeIn("fast");																	
		$("#login").fadeIn("fast");
		$("#x").fadeIn("fast");
		$("#notify").text("").hide();
		$("#pass-field").focus();
	});

	$("#x").click(function() {
		$("#modal-overlay").fadeOut("fast");
		$("#dialog-box").fadeOut("fast");
		$("#dialog-inner-box").fadeOut("fast");
		$(currentDialog).fadeOut("fast");
		$("#login").fadeOut("fast");
		$("#x").fadeOut("fast");
	});
		
	
	
//modal overlay click to fade out everything
	$("#modal-overlay").click(function() {
		$("#modal-overlay").fadeOut("fast");
		$("#dialog-box").fadeOut("fast");
		$("#dialog-inner-box").fadeOut("fast");
		$(currentDialog).fadeOut("fast");
		$("#login").fadeOut("fast");
		$("#x").fadeOut("fast");
		$("#product-image-enlarged").fadeOut("fast");
		$("#image-enlarged").fadeOut("normal");
	});



//  Mouse-Over Tabs
	$(".navbutton").mouseover(function() {
		$(this).css("background-position","0 50px");
	});
	$(".navbutton").mouseout(function() {
		$(this).css("background-position","0 0");
	});	

	$("#logout").click(function() {
		$.cookie("password", "fubar");
		location.reload();
	});

	
});


function resTablesLogin(){
		$("#modal-overlay").fadeIn("fast");			
		$("#dialog-box").fadeIn("fast");
		$("#dialog-inner-box").fadeIn("fast");																	
		$("#login").fadeIn("fast");
		$("#x").fadeIn("fast");
		$("#notify").text("").hide();
		$("#pass-field").focus();


}
