function jajax(Page,Div){document.getElementById(Div).innerHTML="Chargement en cours";var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest()}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP")}xhr.open("GET",Page,false);xhr.send(null);document.getElementById(Div).innerHTML=xhr.responseText}

var timeCookie = 200; // temps en secondes


var url = "http://www.mayottehebdo.com/images/mayotte_hebdo/pubcorner_mh_site.jpg";
var urlPetitFormat = "http://pub.mayottehebdo.com/images/groupamamhweb.gif"; // only for type=3 and 4

var linkPub = "http://www.mayottehebdo.com/statspub.php?u=http%3A%2F%2Fwww.groupama.fr";

//var tb_pathToImageLoading = "images/loading.gif";

/***
type = 1 affiche la pub au centre avec arriere plan effet fondu transparent
type = 2 affiche une miniature � droite en haut
type = 3 idem type = 2 sauf on mouse over on affiche la taille grand format de l'image
***/
var typePub = 10;

// DOM2
if ( typeof window.addEventListener != "undefined" )
	window.addEventListener( "load", gestion_image_swf_site, false );

// IE
else if ( typeof window.attachEvent != "undefined" ) {
	window.attachEvent( "onload", gestion_image_swf_site );
	window.attachEvent( "onunload", disposeAllTabs );
}

else {
	if ( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function ( e ) {
			oldOnload( e );
			gestion_image_swf_site();
		};
	}
	else
		window.onload = gestion_image_swf_site;
}

function gestion_image_swf_site()
{
	afficheImageAjax();
	change_bg_image();
}

/***
$(window).load(function(){
var timeCookie = 200; // temps en secondes
        $.fn.image = function(src,width,height, f){
        return this.each(function(){
                var i = new Image();
                        i.src = src;
                        i.onload = f;
                        //$(this).hide();
                        $(this).fadeOut("slow");
                        i.width = width;
                        i.height = height;
                        $(this).removeClass("ajax_loader");
                        this.appendChild(i);
                        $(this).fadeIn("slow");
                });
        }
		afficheImageAjax();


		if( getCookie('mayottehedbo') ){

		}
		else{
			//$.cookie('mayottehedbo', 'pub',{ expires: timeCookie });
			//$.cookie('mayottehedbo', 'pub', { expires: timeCookie, path: '/', domain: 'mayottehebdo.com/', secure: true });
			//imgLoader = new Image();// preload image
			//imgLoader.src = tb_pathToImageLoading;

			setCookie('mayottehedbo', 'pub',timeCookie)
			if( typePub == 1 ){

				tb_showCenterImage('Test',url,linkPub);

			}else if( typePub == 2 ){

				tb_showRightImage('zaleo',urlPetitFormat,linkPub);


			}else if( typePub == 3 ){

				tb_showRightImageAndElargeImageOnMouseOver('Test',urlPetitFormat, url, linkPub);
			}
		}

		change_bg_image();
});

function setCookie(nom,valeur,secondes) {
	var expDate = new Date();

	expDate.setTime(expDate.getTime() + (secondes * 1000));
	document.cookie = nom + "=" + escape(valeur) + ";expires=" + expDate.toGMTString();
}
function getCookie(nom) {
	deb = document.cookie.indexOf(nom + "=")
	if (deb >= 0) {
		deb += nom.length + 1
		fin = document.cookie.indexOf(";",deb)
		if (fin < 0) fin = document.cookie.length
		return unescape(document.cookie.substring(deb,fin));
	}
	return "";
}
***/
function change_bg_image()
{
	i = Math.floor(Math.random()*4);
	window.document.body.className = "body_bd" + i;
}
function afficheImageAjax()
{
	if(typeof(tab_All_Img) == 'undefined') return ;
	for ( var i = 0; i < indice; i++ )
	{
		url = tab_All_Img[i][1];
		var baseURL;
		if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
		}else{
	   		baseURL = url;
		}
	   	var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   	var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
			//$(tab_All_Img[i][0]).image(tab_All_Img[i][1],tab_All_Img[i][2],tab_All_Img[i][3],function(){ });
			mONimage =new Image(tab_All_Img[i][2],tab_All_Img[i][3])
			mONimage.src = tab_All_Img[i][1];
			document.getElementById(tab_All_Img[i][0]).appendChild(mONimage);// = '<img src="'+mONimage.src+'" border="0" alt="pub" width="'+tab_All_Img[i][2]+'"height="'+tab_All_Img[i][3]+'">';

		}
		else
		{
			// code ajax car page php non image
//			alert(url);
			//$(tab_All_Img[i][0]).load(url, {}, function(){});
jajax(url,tab_All_Img[i][0]);



		}//else
	}

}



