var intLeftMargin = 0;
var intCurrentForm = 1;

$(document).ready(function(){
	$(".buttonnext").click(function(){
		formScroll(-600, 1);
	});
	$(".buttonprev").click(function(){
		formScroll(600, -1);
	});
	formButtons();
	for($i=2;$i<9;$i++) {
		$(".formpage"+$i).css("visibility","hidden");
	}
});

formScroll = function(intLeftMarginDiff, intCurrentFormDiff){
	if(intCurrentForm > 0) {
		$(".form"+intCurrentForm).ajaxSubmit({ 
			//target:			".form"+intCurrentForm,   // target element(s) to be updated with server response 
			//beforeSubmit:  showRequest,  // pre-submit callback 
			//success:       showResponse  // post-submit callback 
		
			// other available options: 
			url:				"./_scripts/formprocessor2.php"         // override for form's 'action' attribute 
			//type:      type        // 'get' or 'post', override for form's 'method' attribute 
			//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
			//clearForm: true        // clear all form fields after successful submit 
			//resetForm: true        // reset the form after successful submit 
		
			// $.ajax options can be used here too, for example: 
			//timeout:   3000 
		});
	}
	intCurrentForm = intCurrentForm + intCurrentFormDiff;
	for($i=1;$i<9;$i++) {
		$(".formpage"+$i).css("visibility","hidden");
	}
	$(".formpage"+intCurrentForm).css("visibility","visible");
	intLeftMargin = intLeftMargin + intLeftMarginDiff;
	$(".formapageholder").animate({
		left: intLeftMargin
	});
	var intFormHeight = $(".formpage"+intCurrentForm).height();
	if (intFormHeight > 680) {
		$(".formcontent").height(intFormHeight + 20);
	}
	if (intFormHeight < 730) {
		$(".formcontent").height(730);
	}
	formButtons();
	$("html, body").animate({scrollTop:0}, 'slow');
};

formButtons = function(){
	if(intCurrentForm == 1) {
		$(".buttonprev").hide();
	} else {
		$(".buttonprev").show();
	}
	
	if(intCurrentForm == 8) {
		$(".buttonnext").hide();
	} else {
		$(".buttonnext").show();
	}
};