/* combo navigation plateformes */
function init_pf_nav(){
	if(document.getElementById("pf_nav")==null)
		return;
	o = document.getElementById("pf_nav");
	acol = o.getElementsByTagName("A");
	acol[0].chld = o.getElementsByTagName("DIV")[0];
	acol[0].onclick = function(){
		this.chld.style.display = (this.chld.style.display!='block')?'block':'none';
		return false;
	}
}

/* popup */
function _envoi(o){
	var w = window.open(o.href, 'popup', 'width=500, height=420, left=0, top=0, location=no, menubar=no, resizable=0, scrollbars=yes, status=no, toolbar=no, fullscreen=no');
	return false;
}

/* impression */
function _print(){
	if(window.print)
		window.print();
}

function countryRedirect() {
  var url=document.getElementById('countrySelect').selection.value
    document.location.href=url
 
}

/* ---------------------------------------------------- Random images home */
/*
// préchargement des images
var image1=new Image();
var image2=new Image();
var image3=new Image();
image1.src='img/visuel_home1.jpg';
image2.src='img/visuel_home2.jpg';
image3.src='img/visuel_home3.jpg';

// tableau des "identifiants" images
var liste_image=new Array(1,2,3);

// variable liée au premier affichage
var a=0;
var liste_image=new Array();

function random_home() {
	// détection du premier affichage
	if(a==0){
		liste_image[0]="1";
		liste_image[1]="2";
		liste_image[3]="3";
		r = Math.floor( Math.random()*liste_image.length );
		document.getElementById("image_fond").style.background='url(img/visuel_home'+liste_image[r]+'.jpg) no-repeat left top")';
		liste_image.splice(r,1);
		a=1;
	}
	// entrée en fondu
	$("#image_fond").fadeIn(800, function() {
		// génération d'un chiffre aléatoire
		r = Math.floor( Math.random()*liste_image.length );
		$(this).oneTime("2s",function() {
			// sortie en fondu
			$(this).fadeOut(800, function() {
				// application de la nouvelle image de fond
				$(this).css("background", "url(img/visuel_home"+liste_image[r]+".jpg) no-repeat left top");
				// vérification du nbre d'éléments ds le tableau
				if(liste_image.length > 1) {
					//$("#image_fond").unbind();
					random_home();
				} else {
					a=0;
					random_home();
					//$(this).fadeIn(800);
				}
				liste_image.splice(r,1);
			});
		});
	});
	
}
*/

var Img = new Array();
ImgNb = 8;
function random_img() {
	for(i=0;i<ImgNb;i++){
		m = new Image();
		m.src = 'fileadmin/templates/gecilog/img/visuel_home_0'+(i+1)+'.jpg';
		Img[i] = m.src;
	}
}
random_img();

function random_home(t) {
	r = Math.floor(Math.random()*Img.length);
	if(t == null) {
		$("#image_fond, #image_fond2").css("backgroundImage", "url("+Img[r]+")");
		$("#image_fond, #image_fond2").show();
		var sto = window.setTimeout('random_home("ok")', 2000);
		Img.splice(r, 1);
	} else {
		$("#image_fond2").css("backgroundImage", $("#image_fond").css("backgroundImage"));
		$("#image_fond").fadeOut(800, function() {
			$("#image_fond").css("backgroundImage", "url("+Img[r]+")");
			$("#image_fond").fadeIn(800, function() {
				Img.splice(r, 1);
				var sto = window.setTimeout('random_home("ok")', 2000);
			});
		});
	}	
	if(Img.length == 0) {
		random_img();
	}
}

/*
var images = new Array();
//var rotations = new Array(1, 2, 3, 4, 5, 6, 7, 8);
var rotations = new Array(1, 2);
var nb_rotations = rotations.length;

for(i=0;i<nb_rotations;i++){
	images[i] = new Image();
	images[i].src = 'img/visuel_home_0'+(i+1)+'.jpg';
}

function random_home() {
	if(arguments.length==0){
		r = Math.floor(Math.random()*images.length);
		$("#image_fond").css("backgroundImage", "url("+images[r].src+")");
		tmp = images[r].src;
		images.splice(r, 1);
		random_home(tmp);
		return;
	}
	// entrée en fondu
	arg = arguments[0];
	$("#image_fond").fadeIn(800, function() {
		// génération d'un chiffre aléatoire
		if(images.length==0){
			random_home_fin(arg);
			return;
		}
		r = Math.floor(Math.random()*images.length);
		$(this).oneTime("2s",function() {
		// sortie en fondu
			$(this).fadeOut(800, function() {
				// application de la nouvelle image de fond
				$(this).css("backgroundImage", "url("+images[r].src+")");
				images.splice(r, 1);
				random_home(arg);
			});
		});
	});
}

function random_home_fin(imgsrc){
	$("#image_fond").oneTime("2s",function() {
		$(this).fadeOut(800, function() {
			$(this).css("backgroundImage", "url("+imgsrc+")");
			$(this).fadeIn(800);
		});
	});
}
*/


