//$(document).ready(function() {
jQuery(document).ready(function($) { // noconflict

	// backtotop links
	$(".backtotop").click(function(e) {
		e.preventDefault();
		$('html, body').stop().animate({
			scrollTop: 0
		}, 200, 'swing');
	});
	
	
	
	//alert(document.location.hostname);
	$('#myModal').load('http://directfuels.co.uk/?page_id=25 #calc', function() {		// UPDATE TO LIVE URL
	
	//$('#myModal').load('http://83.170.73.32/~directf/best-fuel-card/ #calc', function() {	
		
		//alert('Load was performed.');
		$(this).append('<a class="close-reveal-modal">&#215;</a>');

	});
	
	
	var usageThreshold = 500;
	$("#calculator-popup form #go").live("click", function(event) {
		console.log("GO");
		event.preventDefault();
		var usage = $("#usage").val();
		if (usage == "" || isNaN(usage)) {
			alert("Please enter your average fuel usage in litres per week.");
			return false;
		}
		var typeoffuel = $("input[name='fueltype']:checked").val();
		if (typeoffuel == undefined) {
			alert("Please choose your fuel type.");
			return false;
		}
		if (usage < usageThreshold) {
			// PLUS CARD
			//alert("PLUS CARD");
			if ($("#calcinfo-bunker").is(":visible")) {
				$("#calcinfo-bunker").fadeOut(500, function() {
					$("#calcinfo-plus").fadeIn(500);
				})
			} else {
				$("#calcinfo-plus").fadeIn(500);
			}
		} else if (usage >= usageThreshold) {
			// BUNKER CARD
			//alert("BUNKER CARD");			
			if ($("#calcinfo-plus").is(":visible")) {
				$("#calcinfo-plus").fadeOut(500, function() {
					$("#calcinfo-bunker").fadeIn(500);
				})
			} else {
				$("#calcinfo-bunker").fadeIn(500);
			}
		}
	});
	
	
	
	
	
	//SLIDESHOW - Home page
	
	$('.hero-banner').cycle({
		fx:      'scrollLeft', 
    	speed:    300, 
    	timeout:  12000,
		after: roundMyCornersCallback,
		before: roundMyCornersCallback,
		pause: 1
	});
	
	//SLIDESHOW - Sub pages
	
	$('.card-fader').cycle({
		fx:      'scrollUp', 
    	speed:    300, 
    	timeout:  12000
	});
	
	
	
	function roundMyCornersCallback() {
		if ( $.browser.msie && $.browser.version < 8) {
			DD_roundies.addRule('.apply a, .apply', '6px', false);
		}
	}
	

	
	
	
	
});
