$(document).ready( function() { 

	$('#header_pane').dynamItDrop();
	
	$('#accordion').accordion({
		active: false,
		autoHeight: false,
		clearStyle: true,
		collapsible: true,
		header: 'div.toggle'
	});
	
	
	// calculate total price of optional coverages
	
	// variable to hold base price
	var basePrice = parseInt( $('#order-total span').html() );
	// variable to hold the total cost of the order
	var total = basePrice; // can be no less the base price
	
	$('.check').click( function() {
		// variable to hold sum of optional coverages 
		var ocTotal = 0;
		$('.check:checked').each( function() {
			ocTotal += parseInt( $(this).next().children('span').html() );
		});
		// set value of hidden input with total (for later form processing)
		$('#coverages_total').val(ocTotal);
		// set value of hidden input with total for front end
		if( ocTotal == '') {
			$('#coverages-total span').html('0');
			$('#order-total span').html(basePrice);
		}
		else {
			$('#coverages-total span').html(ocTotal);
			$('#order-total span').html(basePrice + ocTotal);
		}
	});
	
	// calculate order total


});

function agentAutocomplete () {
	var em = $('#email').val();
	var li = $('#license').val();
	if ($('#email').val() != "") {
		dynamItSend(dURL+'account.autocomplete&license='+li+'&email='+em);
	}
}

function warrantyPopup (strWhichRow, intScrWidth, intScrHeight) {
	var intScrWidth = (intScrWidth == null) ? 500 : intScrWidth;
	var intScrHeight = (intScrHeight == null) ? 300 : intScrHeight;
	dynamItOpenDialog($('#'+strWhichRow).parent().next().html(), intScrWidth, intScrHeight);
}

