jQuery(document).ready(function(){
								
	$('.itemTopPage a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
								
	// Toggle Solution Finder Box					
	$("#solutionFinderBox .button").click(function() {
		$(this).next().slideToggle("slow");
	}).next().hide();						
	
	// Toggle Call Back Box and clear callbackOutput on close
	$("#callbackBox .button").click(function() {
		$(this).next().slideToggle("slow", function() { $('#callbackOutput').empty(); });
	}).next().hide();	
	

	// Create Hover Area and Grey Box	
	$('.categoryBox').each( function() {				
		x = $(this).find('p.categoryName > a').attr('href');
		y = $(this).find('p.categoryName');
		$('<a href="' + x +'" class="hoverArea">&nbsp;</a>').appendTo(this);
		$('<div class="greyBg fade">&nbsp;</div>').insertBefore(y).css({"opacity": 0.70}).hide();
		$(this).find('p.categoryDescription').hide();	
	});
	// Highlight Category Box's on Mouse Over
	$(".hoverArea").mouseover(function() {
		var $fade = $(this).parent().find('.fade');
		var catName = $(this).parent().find('p.categoryName a');
		$fade.fadeIn(500);
		catName.css({color: '#fff'});
	});
	// Remove Highlight on Category Box's on Mouse Out	
	$(".hoverArea").mouseout(function() {
		var $fade = $(this).parent().find('.fade');
		var catName = $(this).parent().find('p.categoryName a');
		$fade.fadeOut(200);
		catName.css({color: '#064d84'});
	});	
	
//	// Call Back Form sender
//	$('#callbackBoxForm').bind('submit', function() {
//		$(this).ajaxSubmit({
//			beforeSubmit:	validate,
//			url:			'includes/cfm/ajax/callbackBoxFormSend.cfm',
//			target:			'#callbackOutput',
//			resetForm: 		true,
//			timeout:		800 
//		});
//		return false; // <-- important!
//	});
//	
//	// Contact Form sender
//	$('#contactus_form').bind('submit', function() {
//		$(this).ajaxSubmit({
//			beforeSubmit:	validateContactus,
//			url:			'includes/cfm/ajax/contactusFormSend.cfm',
//			target:			'#contactusOutput',
//			resetForm: 		true,
//			timeout:		800 
//		});
//		return false; // <-- important!
//	});
	
	
	// Accordion Scripting
	$("<p><strong>Please select a header from below for more information.</strong></p>").insertBefore("#contentRight h2.accordion-switch:first");
	
//	$("#contentRight").accordion({
//		active: false, 
//		autoHeight: false, 
//		header: 'h2.accordion-switch',
//		alwaysOpen: false
//	});
	
	$("#contentRight h2.accordion-switch").addClass("switchOff");
	
	$("#contentRight h2.accordion-switch").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();	
	


	$("div.infoBox p.infoButton").addClass("infoButtonOff");
	
	$("div.infoBox p.infoButton").click(function() {
		if($(this).is(".infoButtonOff")) {
			$(this).next().slideDown("slow", function() { 
				$(this).parent().find('p.infoButtonOff').removeClass("infoButtonOff").addClass("infoButtonOn");
			});
		} 
		if ($(this).is(".infoButtonOn")) {
			$(this).next().slideUp("slow", function() { 
				$(this).parent().find('p.infoButtonOn').removeClass("infoButtonOn").addClass("infoButtonOff");
			});
		}
	}).next().hide();	
	
	
	// Lightbox
	$('a.lightbox').lightBox({
		fixedNavigation:	false
	}); // Select all links with lightbox class
	
	// Solution Finder
	if (window.location.hostname == "web-server") {
		var siteRoot = "http://web-server/chris/londonvending/";
	} else {
		var siteRoot = "http://" + window.location.hostname + "/";
	}
	
	$('#step2, #step3a, #step3b, #step3c, #solutionFinderBox p.submit').hide();
	
	$("#solutionFinder_step1").change(function() {
		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.cfm"; }
	});
	
	$("#solutionFinder_step2").change(function() {
		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.cfm"; }
		else if (step2value == "chilled_drinks") { window.location.href = siteRoot + "solution-finder/chilled-solutions.cfm"; }
		else if (step2value == "combined_snacks") { window.location.href = siteRoot + "solution-finder/combined-solutions.cfm"; }
		else if (step2value == "chilled_water") { window.location.href = siteRoot + "solution-finder/water-solutions.cfm"; }
	});
	
	$("#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.cfm"; }
		else if (step3avalue == "50_100") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-50-100.cfm"; }
		else if (step3avalue == "100_200") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-100-200.cfm"; }
		else if (step3avalue == "200_plus") { window.location.href = siteRoot + "solution-finder/hot-solutions/hot-solutions-200-plus.cfm"; }
	});
	
	$("#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.cfm"; }
		else if (step3bvalue == "50_plus") { window.location.href = siteRoot + "solution-finder/hot-cold-solutions/hot-cold-solutions-50-plus.cfm"; }
	});
	
	$("#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.cfm"; }
		else if (step3cvalue == "50_plus") { window.location.href = siteRoot + "solution-finder/snack-solutions/snack-solutions-50-plus.cfm"; }
	});

	
});


//function validate(formData, jqForm, options) { 
//	
//	$('#callbackBoxForm input').each( function() {
//		var woo = $(this).fieldValue();
//		if (!woo || woo == '') {
//			$('#callbackOutput').empty();
//			$('<ul class="errors"><li>Please fill in ALL the input boxes below.</li></ul>').appendTo('#callbackOutput');
//	    	return false; 
//		}	
//	});
//	
//}
//	
//function validateContactus(formData, jqForm, options) { 
//	
//	$('#contactus_form input').each( function() {
//		var woo2 = $(this).fieldValue();
//		if (!woo2 || woo2 == '') {
//			$('#contactusOutput').empty();
//			$('<ul class="errors"><li>Please fill in ALL the input boxes below.</li></ul>').appendTo('#contactusOutput');
//	    	return false; 
//		}	
//	});
//	
//}
