$(document).ready(function() {
	$('.repair-header .ad').cycle({
		//blindX
		//blindY
		//blindZ
		//cover
		//curtainX
		//curtainY
		//fade
		//fadeZoom
		//growX
		//growY
		//scrollUp
		//scrollDown
		//scrollLeft
		//scrollRight
		//scrollHorz
		//scrollVert
		//shuffle
		//slideX
		//slideY
		//toss
		//turnUp
		//turnDown
		//turnLeft
		//turnRight
		//uncover
		//wipe
		//zoom
		fx: 'scrollLeft',
		pause:  1,
		speed:  500,
		timeout:  5000
	});
	
	$('.expandable-content-title').click(function() {
		$(this).next().toggle('slide', { direction: 'up' }, 500);
		$(".expandable-image-default", this).toggle();
		$(".expandable-image-active", this).toggle();
	}).next().hide();

	$("#dialog-warranty-content").dialog({
		autoOpen: false,
		resizable: false,
		draggable: false,
		bgiframe: true,
		show: 'scale',
		height:500,
		width:880,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: {
			'Close': function() {
				$(this).dialog('close');
			}
		}
	});

	$('.waranty-trigger').click(function() {
		$('#dialog-warranty-content').dialog('open');
	});
	$("#tabs-flat-rate-repair").tabs();
	$("#tabs-flat-rate-repair-triton").tabs();
	$("#tabs-flat-rate-repair-nautilus").tabs();

	
	$('#rma-create-customer').validate({
       rules: { 
            customer_name: 'required', 
            contact_first: 'required', 
            contact_last: 'required', 
            contact_phone: 'required', 
            contact_email: { 
                required: true, 
                email: true
            }
        }, 
        messages: { 
            customer_name: 'Please enter your customer name', 
            contact_first: 'Please Enter your first name', 
            contact_last: 'Please Enter your last name', 
            contact_phone: 'Please Enter your phone number', 
            contact_email: { 
                required: 'Please enter a valid email address', 
                minlength: 'Please enter a valid email address'
            }
        },
		errorContainer: $('#rma-create-customer-box .box-error'),
		errorLabelContainer: $('ul', $('#rma-create-customer-box .box-error')),
		wrapper: 'li',
		submitHandler: function() { 
			$("#rma-create-customer").ajaxSubmit({
				target: '#create-customer-confirm',
				success: function() {
					$('#rma-create-customer').css({'display' : 'none'});
				}
			});
		}
	});
	$('#warranty-rma-form').validate({
		rules: {
			problem_description: 'required'
		},
		messages: {
			problem_description: 'Please enter a description to the problem you are having with this part.'
		},
		errorLabelContainer: $('ul', '#warranty-rma-form'),
		wrapper: 'li',
		submitHandler: function(validateRMAForm) { 
			$('#default-title').css({'display' : 'none'});
			$('#proccessing-title').css({'display' : 'block'});
			$('#warranty-rma-form-content').css({'display' : 'none'});
			$('.button').css({'display' : 'none'});
			$('#proccessing-form').css({'display' : 'block'});
			validateRMAForm.submit();
		}
	});
	$('#create-customer-confirm-form').submit(function() {
		$('#create-customer-confirm-fields').css({'display' : 'none'});
		$('#proccessing-form').css({'display' : 'block'});
	});
	$("#shipto-list").tablesorter({
		debug: false,
		cssHeader: 'SortHeader',
		cssAsc: 'SortUp',
		cssDesc: 'SortDown',
		headers: { 
			0: { sorter: false }
		},
		sortList: [[1, 0]]
	}).tablesorterPager({
		container: $('#shipto-list-pager'),
		positionFixed: false,
		size: 5
	}).tablesorterFilter({
		filterContainer: $('#shipto-list-filter'),
		filterClearContainer: $('#shipto-list-filter-clear'),
		filterColumns: [1, 2, 3],
		filterCaseSensitive: false
	});
	$('#shipping-method-info-dialog').dialog({
		autoOpen: false,
		resizable: false,
		draggable: false,
		bgiframe: true,
		show: 'scale',
		height:520,
		width:520,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: {
			'Close': function() {
				$(this).dialog('close');
			}
		}
	});
	$('#flat-rate-repair-type-selections').tablesorter({
		debug: false,
		cssHeader: 'SortHeader',
		cssAsc: 'SortUp',
		cssDesc: 'SortDown',
		headers: { 
			0: { sorter: false }
		}
	}).tablesorterPager({
		container: $('#flat-rate-repair-type-pager'),
		positionFixed: false,
		size: 5
	}).tablesorterFilter({
		filterContainer: $('#flat-rate-repair-type-filter'),
		filterClearContainer: $('#flat-rate-repair-type-filter-clear'),
		filterColumns: [1, 2, 3],
		filterCaseSensitive: false
	});
	$('#time-and-material-type-selections').tablesorter({
		debug: false,
		cssHeader: 'SortHeader',
		cssAsc: 'SortUp',
		cssDesc: 'SortDown',
		headers: { 
			0: { sorter: false }
		}
	}).tablesorterPager({
		container: $("#time-and-material-type-pager"),
		positionFixed: false,
		size: 5
	}).tablesorterFilter({
		filterContainer: $("#time-and-material-type-filter"),
		filterClearContainer: $("#time-and-material-type-filter-clear"),
		filterColumns: [1, 2, 3],
		filterCaseSensitive: false
	});

});

