/* jQuery - document ready functions */
jQuery(document).ready(function() {
	/*
	FUNCTION: anonymous function for DT tag	
											
	PARAMETERS: none						
	*/
	jQuery('dt').click(function () {
		if (jQuery(this).attr('class') != 'selected') {
			// hides whichever definition data is visiable
			jQuery('dd:visible').slideUp('normal');
			
			// displays the selected definition data
			jQuery(this).next('dd').slideDown('normal');
		}
		
		// removes the 'selected' class
		jQuery('.selected').removeClass('selected');
		
		// adds the 'selected' class
		jQuery(this).addClass('selected');
	});
	/*
	FUNCTION: anonymous function for side navigation
													
	PARAMETERS: none								
	*/
	jQuery('.sectionNavi .odd, .sectionNavi .even').click(function() {
		
		// send use to the location of the hidden a href
		changeWindowLocation(jQuery(this).children('a').attr('href'));
		
		// following events are applied to the trigger
		}).hover(function() {
			jQuery(this).addClass('highlight').addClass('pointer');
		}, function() {
			jQuery(this).removeClass('highlight');
	});
	
	jQuery('.changeLang:not(".selected")').bind('click', function(e) {
		e.preventDefault();
		changeWindowLocation('/changeLanguage.cfm?code=' + (jQuery(this).attr('rel')));
	});
	
	jQuery(':input[name="dealerState"]').change(function() {

		jQuery.ajax({
			url: '/dealerlocator/includes/usList.cfm?state=' + jQuery(this).val(),
			type: 'post',
			cache: false,
			
			// if the post was successful
			success: function(result) {
				
				jQuery('#dealerList').html(result);
				
			},
			
			// the post was unsuccessful, report it to the user
			error: function(obj) { }
		});
		
	});
	
});
/* / jQuery - document ready functions */

/*
FUNCTION: downloadFileAlert	
							
PARAMETERS: none			
*/
function downloadFileAlert() {
	var msg	= 'The File you are trying to download requires you to be logged in.';
	msg		+= '\n\nTo log into your account or register for an account click the "OK" button below, otherwise click "Cancel".';
	
	if (confirm(msg)) {
		changeWindowLocation('/login');
	}
}
/*
FUNCTION: loadEventCalendar					
											
PARAMETERS:									
	month									
		- numeric: the month of the calendar
	year									
		- numeric: the year of the calendar	
*/
function loadEventCalendar(month, year) {
	jQuery.get('includes/eventCalendar.cfm?month=' + month + '&year=' + year, function(data) {
		jQuery('#CalenderContainer').html(data);
	});
}
/*
FUNCTION: showEventDetails						
												
PARAMETERS:										
	eventUUID									
		- string: the id of the event			
	eventTitle									
		- string: the name of the event			
	width										
		- numeric: the width of the modal window
*/
function showEventDetails(eventUUID, eventTitle, width) {
	Modalbox.show('windows/eventDetails.cfm?eventUUID=' + eventUUID, {title: eventTitle, overlayClose: true, width: width});
	return false;
}
/*
FUNCTION: showSupportWindow								
														
PARAMETERS:												
	page												
		- string: the url of the page					
	pageTitle											
		- string: the title of the page					
	width												
		- numeric: the width of the modal window		
	overlayClose										
		- true: close modal window when overlay clicked	
		- false: does nothing							
*/
function showSupportWindow(page, pageTitle, width, overlayClose) {
	Modalbox.show('windows/' + page, {title: pageTitle, overlayClose: overlayClose, width: width});
	return false;
}
