var domain = "http://"+window.location.hostname;
if(domain=='http://akitourne'){
	domain = window.location.toString().substr(0,17+window.location.toString().substr(17).indexOf('/'));
}


//MAJ = GLOBAL
$(document).ready(function(){//on attend que la page soit chargée
	$('.signalError').click(function(){
		loading();
		var type='oldValue';
		if($(this).attr('name')=="valid")type="newValue";
		$.ajax({
			type: "POST",
			url: domain+'/do/signalError.php',
			data: 'id='+$(this).attr('rel')+'&type='+$(this).attr('rev')+'&'+type+'='+$(this).attr('title')+'&lang='+$(this).attr('lang'),
			success: function(dialog){
				$('#modalForm').html(dialog);
				$('#modalFormPost').dialog({
					width: 600,
					resizable: false,
					disabled:true,
					draggable:false,
					buttons: {
						envoyer: function() {
							if(require($('#modalFormPost'))){
								backOpac(false);
								$.ajax({
									type: "POST",
									url: domain+'/do/signalError.php',
									data: $("#modalFormPost").serialize()
								});
								closeModal($(this));
								$('#signalSend').dialog({
									width: 400,
									resizable: false,
									disabled:true,
									draggable:false,
									buttons: {
										ok: function() {
											$(this).dialog('destroy');
											backOpac(false);
										}
									},
									open: function(event, ui) { 
										backOpac(true);
										$(this).css('height', '100%');
										$(this).dialog('option', 'position', 'center');
									},
									close: function(event, ui) { 
										backOpac(false);
										$( this ).dialog('destroy');
									}
								});
								$(".ui-dialog-titlebar").css('display','block');
							}
						}
					},
					open: function(event, ui) { 
						if($('.ui-widget-overlay').lenght>0){
							$('.ui-widget-overlay').show();
						}else{
							$('.ui-dialog').before('<div class="ui-widget-overlay" style="width:'+document.width+'px; height:'+document.height+'px; z-index: 1000;"></div>');
						}
					},
					close: function(event, ui) { 
						$('.ui-widget-overlay').hide();
						closeModal($(this));
					}
				});
				$(".ui-dialog-titlebar").css('display','block'); 
				$('.signalInfo').fadeIn();
			}
		});
		endLoading();
	});
});
