//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+		©Copyright I-Digitale 2009												+
//+		Tout droits de reproduction interdits									+
//+		http://www.idigitale.fr													+
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
var AJAX={};
var tab_Tmout={};

j(function(){
	loadCmt();

	var el_cnt_actu=document.getElementById('contenu_article');
	j('#nav .level1').hover(function(){
		clearTimeout(tab_Tmout['CMP_bdf_toggle_10']);
		CMP_bdf_toggle(true, [10], el_cnt_actu);
		
	}, function(){
		clearTimeout(tab_Tmout['CMP_bdf_toggle_10']);	
		tab_Tmout['CMP_bdf_toggle_10']=setTimeout(function(){
			CMP_bdf_toggle(false, [10], el_cnt_actu);
		},500);
			
	});
	
	/*j('td.pdf_view iframe').mouseout(function(){
		//j('html').focus();
		console.log(arguments);
		this.blur();
	});*/
	
	
	if(j('iframe',el_cnt_actu).size()){
		j(document).click(function(ev){
			var el=document.createElement("a");
			el.href="javascript:;";
			el.style.position="absolute";
			el.style.top=ev.pageY+"px";
			el.style.left=ev.pageX+"px";
			el.style.width="1px";
			el.style.height="1px";
			document.body.appendChild(el);
			el.focus();
			setTimeout(function(){
				document.body.removeChild(el);
			},10);
		});
	}
	
	
});

function loadCmt(){
	var el_cnt=document.getElementById('reac_cnt');
	if(el_cnt){
		
		j('#bt_order_desc, #bt_order_asc').hide();
		
		el_cnt.style.height=j(el_cnt).height()+'px';

		
		if(AJAX['loadCmt']){AJAX['loadCmt'].abort();}
		
		var obj=j('#f_reac').serializeArray();
		obj.push({'name':'act','value':'loadCmt'});
		obj.push({'name':'ROOT_PATH','value':ROOT_PATH});
		
		el_cnt.innerHTML="Chargement ...";
		AJAX['loadCmt']=j.post("bin/html_cmt.php",
				   obj,
				   function(html){
						el_cnt.innerHTML=html;
						el_cnt.style.height='';
						if(j('#nb_reac').val()>1){
							if(j('#order_reac').val()=="ASC"){
								j('#bt_order_desc').hide();
								j('#bt_order_asc').show();
							}else{
								j('#bt_order_desc').show();
								j('#bt_order_asc').hide();
							}
						}
				   }
		);
	}
}

function changerFlw(id_article){
	j.post("bin/bin_actu.php",
			"act=changerFlw&id_article="+id_article,
			function(json){
				if(json){
					json=j.secureEvalJSON(json);

					if(json.reponse == "1"){
						 j('#abt_art').hide();
						 j('#abtout_art').show();
					}else if(json.reponse == "0"){
						 j('#abt_art').show();
						 j('#abtout_art').hide();
					}		  
				}
			}
	);
	
}

function toggleAbt(etat){
	 if(etat=='true') {
		 j('#abt_art').hide();
		 j('#abtout_art').show();
	 } else {
		 j('#abt_art').show();
		 j('#abtout_art').hide();
	 }	
}

function changerEtat(id_article){
	j.post(ROOT_PATH+"adm/actus/bin/bin_actu.php",
			"act=changerEtat&id_article="+id_article,
			function(json){
				if(json){
					json=j.secureEvalJSON(json);
					if(json.statut_article == "1"){
						j("#etat_"+ json.id_article).attr('title','Désactiver l\'article')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Désactiver l\'article');
					}else if(json.statut_article == "0"){
						j("#etat_"+ json.id_article).attr('title','Activer l\'article')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Activer l\'article');						
					}	
				}
			}
	);
	
}
function changerCorrect(id_article){
	j.post(ROOT_PATH+"adm/actus/bin/bin_actu.php",
			"act=changerCorrect&id_article="+id_article,
			function(json){
				if(json){
					json=j.secureEvalJSON(json);
					if(json.statut_article == "1"){
						j("#correct_"+ json.id_article).attr('title','Signalé comme corrigé. Demander correction.')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Demander correction');
					}else if(json.statut_article == "0"){
						j("#correct_"+ json.id_article).attr('title','Actuellement en demande de correction. Clôturer la demande.')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Clôturer correction');						
					}					
				}
			}
	);
	
}

function changerComm(id_article){
	j.post(ROOT_PATH+"adm/actus/bin/bin_actu.php",
			"act=changerComm&id_article="+id_article,
			function(json){
				if(json){
					json=j.secureEvalJSON(json);
					if(json.statut_article == "1"){
						j("#comm_"+ json.id_article).attr('title','Fermer les commentaires')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Fermer commentaires');
					}else if(json.statut_article == "0"){
						j("#comm_"+ json.id_article).attr('title','Ouvrir les commentaires')
													.children('img').attr('src',ROOT_PATH+json.image_statut)
													.next('span').html('Ouvrir commentaires');						
					}								  
				}
			}
	);
	
}
