var base = '';//document.getElementsByTagName('base')[0].href;
function init(){
	new baniere();
	new polas();
	init_menu_d();
}

function baniere(){
	this.div_fond = document.getElementById('ims_ban');
	this.div_img = document.createElement('div');
	this.div_img.className = 'ban_img_int';
	this.div_fond.appendChild(this.div_img);
	this.tw_opa = new Tween(this.div_img,{'opacity':0});
	var zeclass = this;
	
	this.num_img = 1;
	this.arr_img = {};
	this.img_def = 0;
	
	this.preload = function(){
		this.num_img++;
		if(this.num_img >= photos_baniere.length){
			this.num_img = 0;
		}		
		var ima = base+'graph2/banieres/'+langue+'/'+photos_baniere[this.num_img];
		if(!this.arr_img[this.num_img]){
			this.arr_img[this.num_img] = new Image();
			this.arr_img[this.num_img].src = ima;
		}		
	}
	
	this.nextImage = function(){
		var laclass = this;
		this.div_img.style.backgroundImage = 'url('+this.arr_img[this.num_img].src+')';
		this.tw_opa.moveTo({'opacity':100},250);
		this.tw_opa.onComplete = function(){laclass.fintw()}
		this.preload();
	}
	
	this.fintw = function(){
		this.div_fond.style.backgroundImage = zeclass.div_img.style.backgroundImage;
		this.tw_opa.moveTo({'opacity':0},0);
		this.tw_opa.onComplete = function(){}
	}
	
	
	this.div_fond.style.cursor = 'pointer';
	this.div_fond.onclick = function(){
		zeclass.nextImage();
	}
	
	this.preload();	
}

function polas(){
	this.div_fond = document.getElementById('pola_dyn');
	this.div_img = document.createElement('div');
	this.div_img.className = 'ban_img_int';
	this.div_fond.appendChild(this.div_img);
	this.tw_opa = new Tween(this.div_img,{'opacity':0});
	var zeclass = this;
	
	this.imacur =this.num_img = 0;
	this.arr_img = {};
	this.img_def = 0;
	
	this.preload = function(){
		this.imacur =this.num_img;
		this.num_img++;
		if(this.num_img >= photos_polas.length){
			this.num_img = 0;
		}		
		var ima = base+'images/polas/'+photos_polas[this.num_img]+'.jpg';
		if(!this.arr_img[this.num_img]){
			this.arr_img[this.num_img] = new Image();
			this.arr_img[this.num_img].src = ima;
		}		
	}
	
	this.nextImage = function(){
		var laclass = this;
		this.div_img.style.backgroundImage = 'url('+this.arr_img[this.num_img].src+')';
		this.tw_opa.moveTo({'opacity':100},500);
		this.tw_opa.onComplete = function(){laclass.fintw()}
		this.preload();
	}
	
	this.fintw = function(){
		this.div_fond.style.backgroundImage = zeclass.div_img.style.backgroundImage;
		this.tw_opa.moveTo({'opacity':0},0);
		this.tw_opa.onComplete = function(){}
	}
	
	
//	lien_concours

	this.div_fond.style.cursor = 'pointer';
	this.div_fond.onclick = function(){
		window.location.href= base+lien_concours+'/'+photos_polas[zeclass.imacur]+'.htm';
	}
	
	this.preload();	
	
	setInterval(function(){zeclass.nextImage()},8000);
}

function init_menu_d(){
	var baniere =document.getElementById('grand_photo_ban');
	var divs = baniere.getElementsByTagName('div');
	
	for(var i=0; i<divs.length; i++){
		if(divs[i].className == 'sous_menu_top'){
			new ss_menu(divs[i]);
		}
	}
}

function ss_menu(div){
	this.div = div;
	this.baniere = document.getElementById('grand_photo_ban');
	this.banieref = document.getElementById('baniere');
	if(this.baniere.className == "menu_concours_ouv")return;
	
	this.par = div.parentNode;
	this.trans = 250;
	this.tw_opa = new Tween(this.div,{'opacity':0});
	this.interv;
	this.tw_h = new Tween(this.baniere,{'height':375});
	
	var laclass = this;	
	
	
	
	
	this.ouvrir = function(){
		clearTimeout(this.interv);
		this.tw_opa.moveTo({'opacity':100},this.trans);
		this.tw_h.moveTo({'height':395},this.trans);
	}
	this.fermer = function(){
		var laclass = this;
		this.interv = setTimeout(function(){laclass.fm()},100);
	}
	
	this.fm = function(){
		this.tw_opa.moveTo({'opacity':0},this.trans);
		this.tw_h.moveTo({'height':375},this.trans);
	}
	this.par.onmouseover = function(){
		laclass.ouvrir();
	}
	this.banieref.onmouseout = function(){
		laclass.fermer();
	}
	
	this.banieref.onmouseover = function(){
		clearTimeout(laclass.interv);	
	}
}

function popima(id){
	var ima = id.href;
	return !window.open(ima,'image','scrollbars=no, width=820, height=600, resizable=yes');
}
