$(document).ready(function(){
	var _pbar;
	$('#question_progress').progressbar({value:1});
	data = ["name","email","subject","message"];
	$('#question_button').button().click(function(){
		ajaxdata = ["type=ask"];
		$(data).each(function(){
			ajaxdata.push(this+"="+$('#question_'+this).val())
		})
		$('#question_forms').hide('blind');
		$('#question_progress').show();
		$('#dialog').animate({height:120});
		$('#question_progress').css('margin-top',40)
		_pbar = setInterval("ProgressBar('question_progress')",100);
		$.ajax({
			url:"PostMail.php",
			type:"post",
			data:ajaxdata.join("&"),
			success:function(){
				clearInterval(_pbar);
				$('#question_done').show().position();
				$('#question_progress').hide();
				$('#question_forms form')[0].reset();
			}
		})

	})
	$('#question').click(function(){
		$('#question_forms').show();
		$('#question_progress').hide();
		$('#question_done').hide();
		$("#dialog").dialog({ show: 'blind',modal:true,hide:"blind",width:354,height:370,resizable:false,close:function(){clearInterval(_pbar);p=1;}});
	})
})
p = 1;
function ProgressBar(f){
	if(p>100)p=1;
	p +=2;
	$('#'+f).progressbar("value",p);
}

