

var jsObj ;


$.fn.getData=function(target){
	
	
		
	
		 $.getJSON('models/data.php?data='+target,
           
            
            function(data){
               
               
               
                $(data).each(function() {
                   
                    switch(target)
                    {
                    	case "index.php":
                    		
                    		var string = "<div class='list_item' id='"+this.id+"'><div  class='lDate'>"+this.date+"</div><div class='lTitle' > "+this.title+"</div></div>";
                    		
                    		$('#lContent').append(string);
                    		 $.fn.listenerFocus();
                    		
                    		
                    		break;
                    
                    	case "activites.php":
                    	
                    		break;
                    	
                    	case "references.php":
                    		var string = "<div class='list_item' id='"+this.id+"'><div  class='lDate'>"+this.date+"</div><div class='lTitle' > "+this.title+"</div></div>";
                    		
                    		$('#lContent').append(string);
                    		 $.fn.listenerFocus();
                    		break;
                    	
                    	case "publications.php":
                    	
                    		var string = "<div class='list_item' id='"+this.id+"'><div  class='lDate'>"+this.date+"</div><div class='lTitle' > "+this.title+"</div></div>";
                    		
                    		$('#lContent').append(string);
                    		 $.fn.listenerFocus();
                    		break;

                    	
                    
                    }
                 });
       	$.fn.autofocus();
		}

	);
	
	
}
$.fn.getFocus=function(item,page){


		    $.getJSON('models/focus.php?page='+page+'&item='+item,
           
            
            function(data){
               
               
               $(data).each(function() {
               
               			switch(page)
                    {	
                    	case "index.php":
                    		                    		
                    		
                    		
                    		var title = this.title;
                    		$('div.fHeader').html(title);
                    		
                    		var shText = this.shtext;
                    		$('div.fContent').html(shText);
                    		
                    		
                    		
                    		var images = this.images;
                    		var arrImg = new Array();
                    		arrImg = images.split(',');
                    		
                    		var path = "<img src='cms/thumb_"+arrImg[0]+"'>"  ;
                    		$('div.thumbs').html(path);                  		
                    		//alert(arrImg.length);
                    		//check if more...
                    		
                    		var loText = this.lotext;
                    		var moText = this.moretext;
                    		var lieu = this.lieu;
                    		var periode = this.periode;
                    		var clients = this.clients;
                    		var partenaires = this.partenaires;
                    		
                    		
                    		
                    		$('div.focus').height(198);
                    		
                    		
                    		if(arrImg.length>2 || moText!=''  ){
                    			
                    			var more = "<a href='#' id='more'>Détails</a>";
                    			$('div.more').html(more);
                    			
                    			
                    			$('#more').toggle(function() {
  										
  										
  										// voir plus
  										
  										$('div.focus').height(1000);
  										$('div.focus').width(640);
  										$('div.short_text').css("float","left");
  										
  										$("#more").html("Retour");
  										
  										$("div.list").hide();
  										$('div.side').hide();
  										
  											
  											
  											$('div.bot').append("<div class='lText'>"+loText+"</div>");
  											$('div.lText').css("width","640px");
  											
  											
  											if(lieu!=""){
  												$('div.bot').append("<div class='lieu'>Lieu : "+lieu+"</div>");}
  											if(periode!=""){
  												$('div.bot').append("<div class='periode'>Période : "+periode+"</div>");}
  											if(clients!=""){
  												$('div.bot').append("<div class='clients'>Clients : "+clients+"</div>");}
  											if(partenaires!=""){
  												$('div.bot').append("<div class='clients'>Partenaires : "+partenaires+"</div>");}	
  											
  											
  											var img ="<div class='moreImg'></div>";
  											$('div.focus').append(img);
  											
  											var string="";
  											
  											if(arrImg.length>=2){
  												for(inc=1;inc<arrImg.length;inc++)
  												{	
  													
  												 	string = string+"<img src='cms/"+arrImg[inc]+"' >";
  												 	
  												
  												}
  											 
  												$('div.moreImg').html(string);
  											}
  											
  										
										}, 
												   function() {
 										 $('div.focus').height(198);
 										 $('div.focus').width(462);
 										
 										 $('#more').html("Détails");
 										 
 										 $('div.bot').empty();
 										 $("div.list").show();
 										 $('div.side').show();
 										 $('div.moreImg').remove();
										}
										
										);                    			
                    			
                    		}
                    		
                    			

                    		break;
                    
                    	case "activites.php":
                    	
                    		break;
                    	
                    	case "references.php":
                    	
                    	
                    		var title = this.title;
                    		//alert(title);
                    		$('div.fHeader').html(title);
                    		
                    		var shText = this.shtext;
                    		$('div.fContent').html(shText);
                    		
                    		
                    		
                    		var images = this.images;
                    		var arrImg = new Array();
                    		arrImg = images.split(',');
                    		
                    		var path = "<img src='cms/thumb_"+arrImg[0]+"'>"  ;
                    		
                    		$('div.thumbs').html(path);                  		
                    		//alert(arrImg.length);
                    		//check if more...
                    		
                    		var loText = this.lotext;
                    		var moText = this.moretext;
                    		var lieu = this.lieu;
                    		var periode = this.periode;
                    		var clients = this.clients;
                    		var partenaires = this.partenaires;
                    		var organisme = this.organisme;
                    		var auteur = this.auteur;
                    		var coauteur = this.coauteur;
                    		
                    		
                    		$('div.focus').height(198);
                    		
                    		
                    		if(arrImg.length>2 || moText!=''  ){
                    			
                    			var more = "<a href='#' id='more'>Détails</a>";
                    			$('div.more').html(more);
                    			
                    			
                    			$('#more').toggle(function() {
  										
  										
  										// voir plus
  										
  										$('div.focus').height(1000);
  										$('div.focus').width(640);
  										$('div.short_text').css("float","left");
  										
  										$("#more").html("Retour");
  										$("div.list").hide();
  										$('div.side').hide();
  										
  											
  											
  											$('div.bot').append("<div class='lText'>"+loText+"</div>");
  											$('div.lText').css("width","640px");
  											
  											
  											if(lieu!=""){
  												$('div.bot').append("<div class='lieu'>Lieu : "+lieu+"</div>");}
  											if(periode!=""){
  												$('div.bot').append("<div class='periode'>Période : "+periode+"</div>");}
  											if(clients!=""){
  												$('div.bot').append("<div class='clients'>Clients : "+clients+"</div>");}
  											if(partenaires!=""){
  												$('div.bot').append("<div class='clients'>Partenaires : "+partenaires+"</div>");}	
  											
  											
  											var img ="<div class='moreImg'></div>";
  											$('div.focus').append(img);
  											
  											var string="";
  											if(arrImg.length>=2){
  												for(inc=1;inc<arrImg.length;inc++)
  												{	
  												
  												 	string = string+"<img src='cms/"+arrImg[inc]+"' >";
  												
  												}
  											 
  												$('div.moreImg').html(string);
  											}
  											
  										
										}, 
												   function() {
 										 $('div.focus').height(198);
 										 $('div.focus').width(462);
 										
 										 $('#more').html("Détails");
 										 
 										 $('div.bot').empty();
 										 $("div.list").show();
 										 $('div.side').show();
 										 $('div.moreImg').remove();
										}
										
										);                    			
                    			
                    		}
                    		
                    			

                    		break;

                    	
                    	case "publications.php":
                    		
                    		var title = this.title;
                    		//alert(title);
                    		$('div.fHeader').html(title);
                    		
                    		var shText = this.shtext;
                    		$('div.fContent').html(shText);
                    		
                    		
                    		
                    		var images = this.images;
                    		var arrImg = new Array();
                    		arrImg = images.split(',');
                    		
                    		var path = "<img src='cms/thumb_"+arrImg[0]+"'>"  ;
                    		$('div.thumbs').html(path);                  		
                    		//alert(arrImg.length);
                    		//check if more...
                    		
                    		var loText = this.lotext;
                    		var moText = this.moretext;
                    		var lieu = this.lieu;
                    		var periode = this.periode;
                    		var clients = this.clients;
                    		var partenaires = this.partenaires;
                    		
                    		
                    		
                    		$('div.focus').height(198);
                    		
                    		
                    		if(arrImg.length>2 || moText!=''  ){
                    			
                    			var more = "<a href='#' id='more'>Détails</a>";
                    			$('div.more').html(more);
                    			
                    			
                    			$('#more').toggle(function() {
  										
  										
  										// voir plus
  										
  										$('div.focus').height(1000);
  										$('div.focus').width(640);
  										$('div.short_text').css("float","left");
  										
  										$("#more").html("Retour");
  										$("div.list").hide();
  										$('div.side').hide();
  										
  											
  											
  											$('div.bot').append("<div class='lText '>"+loText+"</div>");
  											$('div.lText').css("width","640px");
  											
  											
  											if(lieu!=""){
  												$('div.bot').append("<div class='lieu'>Lieu : "+lieu+"</div>");}
  											if(periode!=""){
  												$('div.bot').append("<div class='periode'>Période : "+periode+"</div>");}
  											if(clients!=""){
  												$('div.bot').append("<div class='clients'>Clients : "+clients+"</div>");}
  											if(partenaires!=""){
  												$('div.bot').append("<div class='clients'>Partenaires : "+partenaires+"</div>");}	
  											
  											
  											var img ="<div class='moreImg'></div>";
  											$('div.focus').append(img);
  											
  											var string="";
  											if(arrImg.length>=2){
  											
  												
  											
  												for(inc=1;inc<arrImg.length;inc++)
  												{	
  												
  												 	string = string+"<img src='cms/"+arrImg[inc]+"' >";
  													
  												}
  											 
  												$('div.moreImg').html(string);
  											}
  											
  										
										}, 
												   function() {
 										 $('div.focus').height(198);
 										 $('div.focus').width(462);
 										
 										 $('#more').html("Détails");
 										 
 										 $('div.bot').empty();
 										 $("div.list").show();
 										 $('div.side').show();
 										 $('div.moreImg').remove();
										}
										
										);                    			
                    			
                    		}
                    		
                    			

                    		break;
	
                    	
                    
                    }

               		
               		
               		
               		})
                
                
                }
	

	)

}


$.fn.getContentAct = function(target){


		
		    $.getJSON('models/focus.php?page=activites.php&item='+target,
           
            
            function(data){
               
               
               $(data).each(function() {
               
               			var text = this.text;
               			var title = this.title;
               			$("div.cont_act").html(text)	;
               			
               			var arrImages = new Array;
               			
               			arrImages = this.images.split( ",");
               			
               			if(arrImages.length>1)
               			{
               				source = arrImages[0];
               				var string = "<img  class='thumbs' src='cms/"+source+"'>";
               				$("div.img_act").html(string)	;
               			
               			}
               			

               			
               			
               			
               			
               			
               			
               
               		})
               		
               });	
		
		
		
			
			
			
			

	}
	
	
	
	
	
	
	
	

