//----------------------------------------------------------------------------------------
//	Bienvenue dans Marmite framework
//  © Copyright 8eInteraction 2004-2005 - Tous droits réservés.
//	Modification interdite sans autorisation.
//	Conformez-vous au contrat de licence.
// 	Date de creation :  22/02/2005
//----------------------------------------------------------------------------------------


//Rotation d'image
function image_rotate(idtag, name, interval){

	
	this.images = new Array(); 
	this.offset = 1;
	this.idtag = idtag;
	this.name = name;
	this.interval = interval;
	
	this.get_image = function() {
		this.imagetag = document.getElementById(this.idtag);
	}
	
	this.add_image = function(path) {
		 this.images[this.images.length] = path;
	}
	
	this.cicle = function() {
	
		this.get_image();
		if(this.offset > this.images.length -1) this.offset = 0;
		//alert(this.images[this.offset]);
		this.imagetag.src = this.images[this.offset];
		this.offset++;
		
		idt = window.setTimeout(this.name + ".cicle()",this.interval);
	}
	window.setTimeout(this.name + ".cicle()",this.interval);
}




//Lien antirobot
function nobot(url){
	document.location=url;
}

//Poste la page avec argument
function post_page(id){
	if(document.forms[0]['hidden_postback']){
		document.forms[0]['hidden_postback'].value = id;
	}
	document.forms[0].submit();
}

//Poste la page vers une autre page
function post_gateway(id,url,target,message){
	
	//alert('ee');
	document.forms[0].action = url;
	document.forms[0].target = target;
	
	if(document.forms[0]['hidden_gateway']){
		document.forms[0]['hidden_gateway'].value = id;
	}
	
	if(message){ 
		var test = confirm(message);
		if(test)document.forms[0].submit();
	}else{
		document.forms[0].submit();
	}

}

//Poste la page par le viewstate vers une autre page
function post_viewstate(encodedline, url, target, message){
	
	document.forms[0].action = url;
	document.forms[0].target = target;

	//On decode la ligne pour faire un tableau
	viewarrayline = encodedline.split('&');
	tableline = new Array(); 
	
	//Liste des valeurs
	for (var k in viewarrayline){
			conc = viewarrayline[k];
			valuearrayline = conc.split('/');
			cle = valuearrayline[0];
			val = valuearrayline[1];
			tableline[cle]=val;
	}
	
	//On decode l'existant
	if(document.forms[0]['hidden_viewstate']){

		//la ligne des viewstate
		line = document.forms[0]['hidden_viewstate'].value;
		viewarray = line.split('&');
		table = new Array(); 
		//Liste des valeurs
		for (var k in viewarray){
			conc = viewarray[k];
			valuearray = conc.split('/');
			cle = valuearray[0];
			val = valuearray[1];
			table[cle]=val;
		}
		
		//La on fusionne
		for (var id in tableline){
			table[id]=tableline[id];
		}
		
		//On reconstruit le viewstate
		line = '';
		sep = '';
		for (var k in table){
			val = table[k];
			part = k + '/' + val;
			if(val){
			line = line + sep + part;
			sep = '&';
			}
		}
		document.forms[0]['hidden_viewstate'].value = line;
	}
	
	if(message){ 
		var test = confirm(message);
		if(test)document.forms[0].submit();
	}else{
		document.forms[0].submit();
	}

}