var outroDestinations = new Array();
outroDestinations['idea-kit.php'] = '/';
outroDestinations['endless-pool-pricing.php'] = 'endless-pool.php'
outroDestinations['swim-spa-pricing.php'] = 'swim-spa.php'
outroDestinations['fastlane-pool-pricing.php'] = 'fastlane-pool.php'
outroDestinations['fastlane-pricing.php'] = 'fastlane.php'
outroDestinations['fiberglass-pool-pricing.php'] = 'fiberglass-pool.php'
outroDestinations['waterwell-pricing.php'] = 'waterwell.php'

$(document).ready(function(){	
	// Reset
	if ($('#followUp').length > 0) {
		setupOutro();
	}
});
function setupOutro() {
		var thisFile = getFileNameFromLocation();
		var thisPath = getPathFromLocation(thisFile);
		
		destination = thisPath + outroDestinations[thisFile];
		destination = destination.replace('//', '/');
		if (destination.toLowerCase().indexOf('undefined') != -1) {
			destination = 'N/A';
		}
		
		//alert ('destination: ' + destination);
		//alert ($('input[name="WhereToGo"]').val());
		//$('input[name="WhereToGo"]').val(destination);
		document.getElementById('WhereToGo').value = destination;
		//alert ('WhereToGo: ' + $('input[name="WhereToGo"]').val());
		//$('input[name="GotoN"]').val(destination);
		document.getElementById('GotoN').value = destination;
		//alert ('GotoN: ' + $('input[name="GotoN"]').val());
		
		$('#followUp')[0].reset();
	

	// Bind res and commercial dependants
	$("#usage").chained("#selectUsage");
	$("#interest").chained("#selectPrimaryInterest");
	
	// Select Usage
	$('#selectUsage').change(function(){
		if($('#selectUsage :selected').text() != 'Please select:'){
			$('#usage').fadeIn();
			$('.usageOther').fadeOut();	
		} else {
			$('#usage').fadeOut();
			$('.usageOther').fadeOut();	
		};
		
		if($('#selectUsage :selected').text() == 'Commercial / Public Use'){
			$('#primaryInterest').fadeOut();
			$('#alsoUseFor').fadeOut();	
		} else {
			$('#primaryInterest').fadeIn();
			$('#alsoUseFor').fadeIn();	
		}
		
	});
	

	// Primary Interest
	$('#selectPrimaryInterest').change(function(){
		if($('#selectPrimaryInterest :selected').text() != 'Please select:'){
			$('#interest').fadeIn();
			$('.interestOther').fadeOut();	
		} else {
			$('#interest').fadeOut();
			$('.interestOther').fadeOut();	
		};
	});	
	
	// Catch great interest
	$('#greatInterest').change(function(){
		
		
		
		//alert($('#greatInterest :selected').text());
		if($('#greatInterest :selected').text() == 'Original Endless Pool'){
			$('#alsoInterest option:eq(1)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(1)').attr('disabled','');
		}
		
		if($('#greatInterest :selected').text() == 'Endless Pool Swim Spa'){
			$('#alsoInterest option:eq(2)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(2)').attr('disabled','');
		}		
		
		if($('#greatInterest :selected').text() == 'Fastlane'){
			$('#alsoInterest option:eq(3)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(3)').attr('disabled','');
		}			
		
		if($('#greatInterest :selected').text() == 'Fastlane Pool'){
			$('#alsoInterest option:eq(4)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(4)').attr('disabled','');
		}

		if($('#greatInterest :selected').text() == 'Fiberglass Endless Pool'){
			$('#alsoInterest option:eq(5)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(5)').attr('disabled','');
		}	

		if($('#greatInterest :selected').text() == 'Endless Pool WaterWell'){
			$('#alsoInterest option:eq(6)').attr('disabled','disabled');
		} else {
			$('#alsoInterest option:eq(6)').attr('disabled','');
		}	
		
		$("#alsoInterest").val(""); 
		
		$('#also').fadeIn();	
		
	});
	
	function resetInterest(){
		
	}
	
	
	// Display other if applicable
	$('#usage').change(function(){
		// check if other
		if($('#usage :selected').val() == 'other_1004'){
			$('#usageOther_1004').val('Please specify...');
			$('#usageOther_1004').delay(200).fadeIn();
		}
		else if ($('#usage :selected').val() == 'other_1005'){
			$('#usageOther_1005').val('Please specify...');
			$('#usageOther_1005').delay(200).fadeIn();
		}
		else {
			$('.usageOther').fadeOut();
		}
	});
	
	$('#interest').change(function(){
		// check if other
		if($('#interest :selected').text() == 'Other'){
			var selectedSubUse = $('#interest :selected').val();
			$('#interestOther_' + selectedSubUse).val('Please specify...');
			$('#interestOther_' + selectedSubUse).delay(200).fadeIn();
		} else {
			$('.interestOther').fadeOut();
		}
	});	
	
	// Smartphone
	$('#smartPhone').change(function(){
		if($('#smartPhone :selected').text() == 'Yes'){
			$('#whichPhone').fadeIn();
		} else {
			$('#whichPhone').fadeIn();
		}
	});
	
	$('#whichPhone').change(function(){
		if($('#whichPhone :selected').text() == 'Other'){
			$('#otherPhone').fadeIn();
		} else {
			$('#otherPhone').fadeOut();	
		};	
	});
	
	// Get Digital
	$('#getDigital').change(function(){
		if($('#getDigital :selected').text() == 'Yes'){
			$('#downloadIdeaKit').fadeIn();
		} else {
			$('#downloadIdeaKit').fadeOut();
		}
		
	});
	
	// Clear other
	$('.usageOther').click(function(){
		$('.usageOther').val('');	
	});
	$('.interestOther').click(function(){
		$('.interestOther').val('');	
	});
	
	// Clear patterns
	$('.usageOther').val('Please specify...');
	$('.interestOther').val('Please specify...');
}

