jQuery(document).ready(function(){

	// Nav - adding the arrows if they have javascript (removed from subnavs)
	$("#navigation ul li a").prepend('<span class="arrow"></span>');
		$("#navigation ul li ul li a span.arrow").remove();
		$("#navigation ul li.quoteLink span.arrow").remove();
		
	//       addomg extra padding to make room for the arrows
	$("#navigation ul li a span").css("padding-left", "35px");
		
	// Accordian Navigation
	
	$('div#navigation ul li ul, div.dropdowns div').hide();
	$('div#navigation>ul>li>a:not(.index-a, .contact-a, .drinksdispensers-a, .solutionFinder-a, .careers-a), div.dropdowns h2').click(
		function() {
			$(this).next().slideToggle('normal');
			return false;
		}
	);
	
	$('body.hotDrinks #navigation ul.hotDrinks').show();
	$('body.food #navigation ul.food').show();
	$('body.sweets #navigation ul.sweets').show();
	$('body.coldDrinks #navigation ul.coldDrinks').show();
	$('body.brands #navigation ul.brands').show();
	$('body.company #navigation ul.company').show();
	
	// click for more info hover
	
	$("div.productItem a img").hover(
      function () {
		$(this).attr({ 
          src: "images/layout/productList/moreInfoBgHover.jpg"
		});
      }, 
      function () {
		$(this).attr({ 
          src: "images/layout/productList/moreInfoBg.jpg"
		});  
      }
	 );


	
	// Solution Finder
	
	$("#solutionFinder").click(function() {
			$(this).css("cursor", "default");
			$("#solutionFinderBoxInner form").slideDown();
	});
	
	if (window.location.hostname == "web-server") {
		var siteRoot = "http://web-server/chris/expressvending/";
	} else if (window.location.hostname == "demo.adtrakdesign.co.uk") { 
		var siteRoot = "http://demo.adtrakdesign.co.uk/chris/expressvending/";
	} else {
		var siteRoot = "http://" + window.location.hostname + "/";
	}

	
	$("#step2, #step3a, #step3b, #step3c, p.submit").hide();

	$("#solutionFinder_step1").change(function() {
		$('#step2, #step3a, #step3b, #step3c').hide();		
		var step1value = $("#solutionFinder_step1").val();
		if (step1value == "reception_area") { $('#step2').slideDown(); }
		else if (step1value == "office_area") { $('#step2').slideDown(); }
		else if (step1value == "meeting_room") { $('#step2').slideDown(); }
		else if (step1value == "breakout_area") { $('#step2').slideDown(); }
		else if (step1value == "canteen") { $('#step2').slideDown(); }
		else if (step1value == "factory") { window.location.href = siteRoot + "solution-finder/factory-solutions.php"; }
	});
	
	$("#solutionFinder_step2").change(function() {
		$('#step3a, #step3b, #step3c').hide();	
		var step2value = $("#solutionFinder_step2").val();
		if (step2value == "hot_drinks") { $('#step3a, #step3b, #step3c').hide(); $('#step3a').slideDown(); }
		else if (step2value == "hot_cold_drinks") { $('#step3a, #step3b, #step3c').hide(); $('#step3b').slideDown(); }
		else if (step2value == "confectionery_snacks") { $('#step3a, #step3b, #step3c').hide(); $('#step3c').slideDown(); }
		else if (step2value == "food_sandwiches") { window.location.href = siteRoot + "solution-finder/food-solutions.php"; }
		else if (step2value == "chilled_drinks") { window.location.href = siteRoot + "solution-finder/chilled-solutions.php"; }
		else if (step2value == "combined_snacks") { window.location.href = siteRoot + "solution-finder/combined-solutions.php"; }
		else if (step2value == "chilled_water") { window.location.href = siteRoot + "solution-finder/water-solutions.php"; }
	});
	
	$("#solutionFinder_step3a").change(function() {
		var step3avalue = $("#solutionFinder_step3a").val();
		if (step3avalue == "0_50") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-0-50.php"; }
		else if (step3avalue == "50_100") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-50-100.php"; }
		else if (step3avalue == "100_200") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-100-200.php"; }
		else if (step3avalue == "200_plus") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-200-plus.php"; }
	});
	
	$("#solutionFinder_step3b").change(function() {
		var step3bvalue = $("#solutionFinder_step3b").val();
		if (step3bvalue == "0_50") { window.location.href = siteRoot + "solution-finder/hot-cold-solutions/hot-cold-solutions-0-50.php"; }
		else if (step3bvalue == "50_plus") { window.location.href = siteRoot + "solution-finder/hot-cold-solutions/hot-cold-solutions-50-plus.php"; }
	});
	
	$("#solutionFinder_step3c").change(function() {
		var step3cvalue = $("#solutionFinder_step3c").val();
		if (step3cvalue == "0_50") { window.location.href = siteRoot + "solution-finder/snack-solutions/snack-solutions-0-50.php"; }
		else if (step3cvalue == "50_plus") { window.location.href = siteRoot + "solution-finder/snack-solutions/snack-solutions-50-plus.php"; }
	});
	
	// Lightbox
	$(function() {
		$(".lightbox").lightbox();
	});
	
	// Hide/Show Specifications
	$("p.spec").addClass("switchOff").click(function() {
		if($(this).is(".switchOff")) {
			$(this).next().slideDown("slow", function() { 
				$(this).prev().removeClass("switchOff").addClass("switchOn");
			});
		} 
		if ($(this).is(".switchOn")) {
			$(this).next().slideUp("slow", function() { 
				$(this).prev().removeClass("switchOn").addClass("switchOff");
			});
		}
	}).next().hide();
	
	// Careers droppys
	$('#dropy1, #dropy2, #dropy3').hide();
	$('#drop1').click(function() {
	  $('#dropy1').slideDown('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
	$('#dropy1close').click(function() {
	  $('#dropy1').slideUp('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
	
	$('#drop2').click(function() {
	  $('#dropy2').slideDown('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
	$('#dropy2close').click(function() {
	  $('#dropy2').slideUp('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
	
	$('#drop3').click(function() {
	  $('#dropy3').slideDown('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
	$('#dropy3close').click(function() {
	  $('#dropy3').slideUp('slow', function() {
		// Animation complete.
	  });
	  return false;
	});
});