// JavaScript Document
function Triage(type) {
	this.Content = Div('listinghome');
	var content = this.Content;
	this.Construct = function(type){
	
	
		if (type) {
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listehome" ,true,"&type="+type );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
					}
				}
			}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.test = function( type ){
		construct( type );
	}
}

function TriageStock(type) {
	this.Content = Div('listinghome');
	var content = this.Content;
	this.Construct = function(type){
	
		if (type) {
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listestockhome" ,true,"&type="+type );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
					}
				}
			}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.stock = function( type ){
		construct( type );
	}
}

function TriageProduct(type) {
	this.Content = Div('listinghome');
	var content = this.Content;
	this.Construct = function(type){
	
		if (type) {
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listehomeproduct" ,true,"&type="+type );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
					}
				}
			}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.product = function( type ){
		construct( type );
	}
}

function TriageNews(type) {
	this.Content = Div('listinghome');
	var content = this.Content;
	this.Construct = function(type){
	
		if (type) {
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listehomenews" ,true,"&type="+type );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
					}
				}
			}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.news = function( type ){
		construct( type );
	}
}

function TriagerubStock(type, limit, pge){
	this.Content = Div();
	this.page = 0;
	this.nPages = 0;
	var content = this.Content;
	var objet = this;
	this.Construct = function(type, limit){
	
		if (!type){ 
			var type = LireCookie('type') ;
		}

		else { SetCookie('type', type); }
		
		if(!limit) {
			var limit = LireCookie('limit');
		}
		else { SetCookie('limit', limit); }
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerubstock" ,true,"&type="+type+"&limit="+limit+"&page="+this.page );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
						objet.nPages = retour.nPages;
						var numberPage = new ListeNumberPage(objet);
						var pagination = new Div("pagination");
						pagination.appendChild(numberPage.Content);
						content.appendChild(pagination);
					}
				}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.viewstock = function( type, limit, pge){
		SetCookie('type', type);
		SetCookie('limit', limit);
	if (pge=='ok') {this.page=0; objet.page = 0; construct( type, limit, 0);}
	else { construct( type, limit, pge);}
	}
}

function TriagerubNews(type, limit, pge){
	this.Content = Div();
	this.page = 0;
	var content = this.Content;
	var objet = this;
	this.Construct = function(type, limit){
	
		if (!type){ 
			var type = LireCookie('type') ;

		}

		else { SetCookie('type', type); }
		
		if(!limit) {
			var limit = LireCookie('limit');
		}
		else { SetCookie('limit', limit); }
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerubnews" ,true,"&type="+type+"&limit="+limit+"&page="+this.page );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
						objet.nPages = retour.nPages;
						var numberPage = new ListeNumberPage(objet);
						var pagination = new Div("pagination");
						pagination.appendChild(numberPage.Content);
						content.appendChild(pagination);
					}
				}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.viewnews = function( type, limit, pge){
		SetCookie('type', type);
		SetCookie('limit', limit);
	if (!pge) {this.page=0; objet.page = 0;}
		construct( type, limit);
		
	}
}

function TriagerubProduct(type, limit, pge){
	this.Content = Div();
	this.lettrage = Div("lettragecontent");
	this.page = 0;
	var content = this.Content;
	var lettrecontent = this.lettrage;
	


	var objet = this;
	
	this.Construct = function(typeobject){
		
		if (typeof(typeobject)=="undefined" ){ 
			var type = LireCookie('type1') ;

		}

		else { SetCookie('type1', typeobject.type); }
		
		if(typeof(typeobject)=="undefined") {
			var limit = LireCookie('limit');
		}
		else { SetCookie('limit', typeobject.limit); 
				}
		if(typeof(typeobject)!="undefined") {
			this.recherche = typeobject.recherche;
			limit = typeobject.limit;
			type = typeobject.type;
			this.page = 0;
			objet.page = 0;
		}
		

			content.innerHTML= "loading..."

		if (this.char=='List') {
				this.recherche ='';
				this.char = '';
				this.page = 0;
				}
		
			if (!this.char && this.recherche=='disabled') { this.recherche='';}
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerubproduct" ,true,"&type="+type+"&limit="+limit+"&page="+this.page+"&char="+this.char+"&recherche="+this.recherche );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
							lettrecontent.innerHTML = "";
						content.innerHTML= retour.txt;
						objet.nPages = retour.nPages;
						var numberPage = new ListeNumberPage(objet);
						var pagination = new Div("pagination");
						var navigation = new Navigation(objet);
						lettrecontent.appendChild(navigation.Content);
						pagination.appendChild(numberPage.Content);
						content.appendChild(pagination);
					}
				}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.viewproduct = function( type, limit, pge, recherche){
		SetCookie('type1', type);
			var objet = new Object;
		SetCookie('limit', limit);
		objet.page = 0;
		objet.type = type;
		objet.limit = limit;
		objet.recherche = recherche;
		construct( objet);
		
	}
}

function TriagerubSubscription(type, limit, pge){
	this.Content = Div();
	this.page = 0;
	var content = this.Content;
	var objet = this;
	this.Construct = function(type, limit){
	
		if (!type){ 
			var type = LireCookie('typesub') ;

		}

		else { SetCookie('typesub', type); }
		
		if(!limit) {
			var limit = LireCookie('limit');
		}
		else { SetCookie('limit', limit); }
		
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerubsubscription" ,true,"&type="+type+"&limit="+limit+"&page="+this.page );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
						objet.nPages = retour.nPages;
						var numberPage = new ListeNumberPage(objet);
						var pagination = new Div("pagination");
						pagination.appendChild(numberPage.Content);
						content.appendChild(pagination);
					}
				}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.viewsubscription = function( type, limit, pge){
		SetCookie('typesub', type);
		SetCookie('limit', limit);
	if (!pge) {this.page=0; objet.page = 0;}
		construct( type, limit, pge);
		
	}
}

function TriagerubPlanning(type, limit, pge){
	this.Content = Div();
	this.page = 0;
	var content = this.Content;
	var objet = this;
	this.Construct = function(type, limit){
	
		if (!type){ 
			var type = LireCookie('typeplanning') ;

		}

		else { SetCookie('typeplanning', type); }
					var limit1 = 4;

		
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerubplanning" ,true,"&type="+type+"&limit="+limit1+"&page="+this.page+"" );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
						objet.nPages = retour.nPages;
						var numberPage = new ListeNumberPage(objet);
						var pagination = new Div("pagination");
						var navigation = new Navigation(objet);
						pagination.appendChild(numberPage.Content);
						content.appendChild(pagination);
					}
				}
		}
	}
	this.Construct();
	var construct = this.Construct;
	window.viewplanning = function( type, limit, pge){
		SetCookie('typeplanning', type);
		SetCookie('limit', limit);
	if (!pge) {this.page=0; objet.page = 0;}
		construct( type, limit, pge);
		
	}
}

function TriageRelease(type){
	this.Content = Div('listinghome');
	var content = this.Content;
	this.Construct = function(type){
	
		if (type) {
			content.innerHTML= "loading...";
			var RequeteTri = ObjXMLHttpRequest();
			RequeteTri.SendRequest( "listerelease" ,true,"&type="+type+"&limit=6" );
			RequeteTri.onreadystatechange = function(){
				if( this.readyState == 4 ){
					if( this.status == 200 ){
						var retour = eval('('+RequeteTri.responseText+')');
						content.innerHTML= retour.txt;
					}
				}
			}

		}
	}
	this.Construct();
	var construct = this.Construct;
	window.release = function( type ){
		construct( type );
	}
}


 window.BandeauJSNews = function() {
 	var DivBandeauNews = document.getElementById('actuDeroulant');
	//console.log(DivBandeauNews);
	DivBandeauNews.style.overflow = "hidden";
	DivBandeauNews.style.height = "157px";
	var TranslationBandeauNews = document.getElementById('actuContent');
	TranslationBandeauNews.style.top = '0px';
	
	var tabMove = [0,20,40,60,80,100,120,150,160,180,200,220,240,260,280,300,320,340,360,380,400,420,450,460,480];
	if (DivBandeauNews) {
			var positioncalculer = 0;
				var varmove = 0;
				var elementcheck = 0;
			var TranslationH = function () {
		//	console.log('test varmove :'+varmove);
			positioncalculer = elementcheck*150;
		//	console.log('positioncalcul :'+positioncalculer);
			
					var MoveDiv = function() {
							//console.log('test elementcheck :'+elementcheck);
						
							TranslationBandeauNews.style.top = - tabMove[varmove]+'px';
							//console.log('top :'+TranslationBandeauNews.style.top);
							if (tabMove[varmove] == positioncalculer) {
								clearInterval(IntervalMove);
								if (elementcheck==3) { elementcheck = 0; } else { 	elementcheck++; }
						//		console.log('elementcheck : '+elementcheck);
							}
							else { 
									if(elementcheck<4 && elementcheck != 0) {
										varmove++;
								//		console.log('test varmoveblac :'+varmove);
										}
									else { varmove--; }
								}
									
						//	console.log(varmove);
					}
					var IntervalMove = setInterval(MoveDiv,10);
			/*		if( positioncalculer >=2250) {
							//clearInterval(IntervalNews);
							varmove = 0;
							BandeauJSNews;
					} */
								
			}	
			var IntervalNews = setInterval(TranslationH,5000);
			
	}
  
 
 }