/*
 *
 */
$(document).ready(function(){
	$(".submit").click(function () {
		num = ( ie )?0:1;
		
		id_ssetape = this.parentNode.parentNode.parentNode.parentNode.childNodes[num].id;
		id_quest= this.parentNode.id;
		
		inputs = $(this.parentNode).find("input");
		rep_c = '';
		rep_t = '';
		for( i=0;i<inputs.length;i++ )
		{
			if( inputs[i].name == "rep_c"+id_quest+"[]" )
			{
				if( inputs[i].checked )
				{
					rep_c = inputs[i].value;
				}
			}
			if( inputs[i].name == "rep_t" )
				rep_t = inputs[i].value;
		}
		textareas = $(this.parentNode).find("textarea");
		for( i=0;i<textareas.length;i++ )
		{
			if( textareas[i].name == "rep_t" )
				rep_t = textareas[i].value;
		}
				
		obj = this.parentNode;
	
		if( rep_c == '' )
			alert('Veuillez choisir oui/non/autre.');
		else if( rep_c == 2 && rep_t == '' )
			alert('Veuillez entrer un commentaire.');
		else
		{	
			$(obj.getElementsByTagName('span')[1]).fadeIn(1);
			$(obj.getElementsByTagName('span')[1]).html(ajax_chargement);
			
			//$(obj.getElementsByTagName('span')[1]).fadeIn("fast");
			$.post(ajax_page, { az_op: 2, az_sid:id_ssetape, az_id: id_quest, az_rep_c: rep_c, az_rep_t: rep_t }, function(data){
				$(obj.getElementsByTagName('span')[1]).fadeOut("slow");
			});
		}
		return false;
	});
	
	$("div[id^='buttonpurge_']").click( function () {
		id = this.id.split('_');
		$.post(ajax_page, { az_op: 10, az_id:id[1] }, function(data){
			$('#files_'+id[1]).html('');
			$('#files_'+id[1]).each( function () {
				$(this.parentNode).find('p').html('');
			});
			$('#buttonpurge_'+id[1]).hide();
			
		});
	});
});