/* Dissonant Designs jQuery code 2010 */

$(function(){
		   
	// Tabs
	$('#tabs').tabs();
	
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	
	// Slider
	$('#html').slider({
		range: 'min',
		value: 5,
		step: 1,
		min: 0,
		max: 20,
		slide: function(event, ui) {
			$("#htmlAmount").replaceWith('<div id="htmlAmount">' + ui.value + ' page(s)</div>');
		},
		stop: function(event, ui) {
			calculateTotal();
		}
	});
	
	// Slider
	$('#images').slider({
		range: 'min',
		value: 3,
		step: 1,
		min: 0,
		max: 20,
		slide: function(event, ui) {
			$("#imgAmount").replaceWith('<div id="imgAmount">' + ui.value + ' image(s)</div>');
		},
		stop: function(event, ui) {
			calculateTotal();
		}
	});
	
	// Slider
	$('#flash').slider({
		range: 'min',
		value: 1,
		step: 1,
		min: 0,
		max: 20,
		slide: function(event, ui) {
			$("#flashAmount").replaceWith('<div id="flashAmount">' + ui.value + ' Flash object(s)</div>');
		},
		stop: function(event, ui) {
			calculateTotal();
		}
	});
	
	// Slider
	$('#javascript').slider({
		range: 'min',
		value: 2,
		step: 1,
		min: 0,
		max: 20,
		slide: function(event, ui) {
			$("#jsAmount").replaceWith('<div id="jsAmount">' + ui.value + ' Javascript script(s)</div>');
		},
		stop: function(event, ui) {
			calculateTotal();
		}
	});
	
	// Slider
	$('#php').slider({
		range: 'min',
		value: 0,
		step: 1,
		min: 0,
		max: 20,
		slide: function(event, ui) {
			$("#phpAmount").replaceWith('<div id="phpAmount">' + ui.value + ' PHP page(s)</div>');
		},
		stop: function(event, ui) {
			calculateTotal();
		}
	});
	
	// Dialog			
	$('#dialog').dialog({
		autoOpen: false,
			width: 600,
			buttons: {
				"Send": function() { 
					$('#emailForm').submit(); 
				}, 
				"Cancel": function() { 
					$(this).dialog("close"); 
				}
			},
			resizable: false
	});
	
	// Dialog Link
	$('#dialog_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	
	// Dialog Link
	$('#email_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	
	// Clear Messages
	$("#topMsg").click(function() {
		$("#topMsg").fadeOut(400);
	});
	
});

// Calculator
	
function calculateTotal() {
	$("#totalData").replaceWith('<div id="totalData">Total: $' + (
		  ($( "#html" ).slider( "option", "value" ) * 25) +
		  ($( "#images" ).slider( "option", "value" ) * 10) +
		  ($( "#flash" ).slider( "option", "value" ) * 35) +
		  ($( "#javascript" ).slider( "option", "value" ) * 30) +
		  ($( "#php" ).slider( "option", "value" ) * 75) + 150) + '.00 (GST inc.)');
}

