
//	Post Comments With Ajax
	;(function($) {
		$.ajaxSetup({ 'beforeSend' : function(xhr) { xhr.setRequestHeader('Accept', 'application/json') } })

		$.fn.postWithAjax = function(settings) {
			var option = $.extend({}, $.fn.postWithAjax.defaultSettings, settings)

			return this.submit(function() {
				form = $(this)

				form.append('<input name="ajax" type="hidden" value="true" />')

				$.post(form.attr('action'), form.serialize(), handleResponse, option.type)

				return false;
			})
		}

		$.fn.postWithAjax.defaultSettings = { type : 'html' }
	})(jQuery);



//	Fieldify - Add support for PSEUDO pseudo classes on form elements in IE damn 6
	;(function($) {
		$fieldify = $.fieldify = function() {
			if ($.browser.msie && parseInt($.browser.version) == 6) {
				$.each([$('button'), $('input'), $('select'), $('textarea')], function() {
					el = $(this)
					el
						.hover(
							function() { $(this).addClass('hover') },
							function() { $(this).removeClass('hover') }
						)
						.focus(function() { $(this).addClass('focus') })
						.blur(function() { $(this).removeClass('focus') })
				})
			}

			return this;
		}
	})(jQuery);
	
	
//	Ajaxy Calculator
	


//	That's the anthem, get your damn hands up!
	$(function() {
		$('body').addClass('js')
		$.fieldify();
		
		
		$("#home_slide").cycle();
		
		$("form.calculator_form button").hide();
		$("form.calculator_form select").change( function() {
			
			var calc_id = $("#calc_id").val();
			
			var x = $("#xaxis").val();
			var y = $("#yaxis").val();
			
			$.get("/incs/actions/calculator_result.php", { pass_calc_id: calc_id, pass_x: x, pass_y: y},
				function(result){

					$("#calc_result strong").hide();
					$("#calc_result strong").html(result);
					
					if(jQuery.browser.msie) {
						$("#calc_result strong").show();
					}
					else {
						$("#calc_result strong").fadeIn("medium");
					}
					
				}
			);
			
		});
		
		/*
		$("form.calculator_form").submit( function() {

			var form = $(this);
			var calc_id = $("#calc_id").val();
			
			form.find('button').html('Please Wait');
			
			var x = $("#xaxis").val();
			var y = $("#yaxis").val();
			
			$.get("/incs/actions/calculator_result.php", { pass_calc_id: calc_id, pass_x: x, pass_y: y},
				function(result){

					$("#calc_result strong").hide();
					$("#calc_result strong").html(result);

					$("#calc_result strong").fadeIn("medium", function() {
						if(jQuery.browser.msie) this.style.removeAttribute('filter');
					});
					
					form.find('button').html('Calculate');
				}
			);
			
			return false;
			
		});
		*/
	})
