// JavaScript Document

Event.observe(window,'load',function()
									 {
										 Question2 = new Question2();
									 });
Question2 = Class.create();

Question2.prototype = {
	
	initialize : function()
	{
		this.question_number = 1;
		this.question_path = 'templates/qa2-1.php';
	},
	start : function()
	{
		if(!$('question'))
		{
		win = new Window('question',
						 {className : 'alphacube',
						 width : 700,
						 height : 300,
						 showEffectOptions:{duration : 0,delay:0},
						 hideEffectOptions:{duration : 0,delay : 0},
						 onClose : function()
						 {
							 this.initialize;
						 },
						 onDestroy : function()
						 {
							 new Ajax.Request('templates/sess_destroy.php',{method : 'get'});
						 }
						 
						//risizable : false,
						//minimizable : false
						// maximizable :false
						 });
		win.setAjaxContent(this.question_path);
		win.setDestroyOnClose();
		win.showCenter();
		}
		else
		{
			alert('アンケートウインドウは既に開いています。');
		}
		this.question_number = 1;
	},
	submit : function()
	{
		form_number = 'qa2-'+this.question_number;
		this.question_number++;
		if(this.question_number == 6)
		{
			question_path = 'templates/finish.php';
		}
		else
		{
			question_path = 'templates/qa2-'+this.question_number+'.php';
		}
		new Ajax.Request('templates/submit.php',
						 {
							 method :'post',
							 parameters : Form.serialize(form_number),
							 onSuccess : function(httpobj)
							 {
								 if(httpobj.responseText == 1)
								 {
									 win.setAjaxContent(question_path);
								 }
								 else
								 {
									 win.getContent().update(httpobj.responseText);
								 }
							 },
							 onFailure : function()
							 {
								 win,getContent().update('<p>データ通信にエラーが発生しました。<br />お手数ですが現在のウインドウを閉じて始めからやり直してください。');
							 }
						 });
	},
	prev : function()
	{
		this.question_number = this.question_number-1;
		question_path = 'templates/qa2-'+this.question_number+'.php';
		win.setAjaxContent(question_path);
	},
	close : function()
	{
		//	ウインドウを削除するメソッドを記述
		win.destroy();
	},
	number_init : function()
	{
		this.question_number = 1;
	}
}
	
	