/*
Script Pub par Dlareg
Vous pouvez utiliser ce script pour votre site
http://www.dlareg.org
*/

var tableau = new Array
// la première pub attention à id = 0
tableau[id=0] = new unePub ("http://www.dlareg.org/pub/firefox.gif", "http://mozilla-europe.org/fr/firefox/", "Essayer Firefox c'est l'adopter", 419, 60)
// firefox
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/firefox.gif", "http://mozilla-europe.org/fr/firefox/", "Essayer Firefox c'est l'adopter", 419, 60)
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/firefox.gif", "http://www.mozilla-europe.org/fr/firefox/", "Essayer Firefox c'est l'adopter", 419, 60)
// wikipedia
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/wikipedia.png", "http://fr.wikipedia.org/wiki/", "Participez à la publication d'articles", 400, 60)
// bourguinux
tableau[id++] = new unePub ("http://www.dlareg.org/pub/bourguinux.gif", "http://www.bourguinux.org", "Bourguinux l'autre informatique", 468, 60)
// coagul
tableau[id++] = new unePub ("http://www.dlareg.org/pub/coagul.png", "http://www.coagul.org", "Echanges de savoir et entraide, GNU / Linux et BSD", 468, 60)
// ooo
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/ooo.png", "http://fr.openoffice.org/", "Gratuite et fiable", 468, 60)
// pldb
tableau[id++] = new unePub ("http://www.dlareg.org/pub/pldb.png", "http://www.pldb.free.fr", "Des photos sous licences Creatives Commons", 468, 60)
// april
tableau[id++] = new unePub ("http://www.april.org/association/documents/bannieres/banniere_horizontale_soutien_fulltext_486x60.png", "http://www.april.org/association/adhesion.texte", "Promouvoir et soutenir le logiciel libre", 468, 60)
// traduc
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/traduc.org.png", "http://www.traduc.org/", "Contribuez à la traduction de documentation de logiciels libres", 468, 60)
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/traduc.org.png", "http://www.traduc.org/", "Contribuez à la traduction de documentation de logiciels libres", 468, 60)

// campagne framasoft
//tableau[id++] = new unePub ("http://soutenir.framasoft.org/files/bannieres/Framabook/Framabook_468par60.png", "http://soutenir.framasoft.org/?pseudo=Dlareg&web=http%3A%2F%2Fwww.dlareg.org", "Je soutiens Framasoft, pourquoi pas vous ?", 468, 60, "01/02/2011")
//tableau[id++] = new unePub ("http://soutenir.framasoft.org/files/bannieres/Laroute/laroute_anim.gif", "http://soutenir.framasoft.org/?pseudo=Dlareg&web=http%3A%2F%2Fwww.dlareg.org", "Je soutiens Framasoft, pourquoi pas vous ?", 468, 60, "01/02/2011")

// rmll 2010
//tableau[id++] = new unePub ("http://2010.rmll.info/local/cache-vignettes/L450xH58/RMLL_2010_banniere_468x60-6d9c9.png", "http://2010.rmll.info/", "Rencontres Mondiales du Logiciel Libre", 468, 60, "11/07/2010")

// candidats
//tableau[id++] = new unePub ("http://www.dlareg.org/pub/candidats_fr.png", "http://www.candidats.fr", "Regardez les signataires du Pacte du Logiciel Libre", 468, 60)

// libre en fête
//tableau[id++] = new unePub ("http://www.libre-en-fete.net/images/banniere.png", "http://www.libre-en-fete.net", "Une fête nationale autour du logiciel libre", 486, 80, "30/03/2011")
//tableau[id++] = new unePub ("http://www.libre-en-fete.net/images/banniere.png", "http://www.libre-en-fete.net", "Une fête nationale autour du logiciel libre", 486, 80, "30/03/2011")
//tableau[id++] = new unePub ("http://www.libre-en-fete.net/images/banniere.png", "http://www.libre-en-fete.net", "Une fête nationale autour du logiciel libre", 486, 80, "30/03/2011")

// journée anti DRM
tableau[id++] = new unePub ("http://www.dlareg.org/pub/jmdrm.png", "http://www.april.org/fr/node/13818", "Journée Mondiale contre les DRM", 468, 60, "04/05/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/jmdrm.png", "http://www.april.org/fr/node/13818", "Journée Mondiale contre les DRM", 468, 60, "04/05/2011")

// ciné-débat
tableau[id++] = new unePub ("http://www.dlareg.org/pub/cine_debat.png", "http://coagul.org/drupal/%C3%A9v%C3%A8nement/cin%C3%A9-d%C3%A9bat-copier-nest-pas-voler", "partage, création, nouveaux modes de financement ...", 468, 60, "12/05/2011")

// JLL
tableau[id++] = new unePub ("http://www.dlareg.org/pub/banniere_jll.jpg", "http://coagul.org/drupal/%C3%A9v%C3%A8nement/deux-journ%C3%A9es-conf%C3%A9rences-et-dateliers-%C3%A0-liut-dijon", "Entrée libre et gratuite ...", 468, 60, "28/05/2011")

// LEF besac
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")
tableau[id++] = new unePub ("http://www.dlareg.org/pub/lef_besancon.jpg", "http://www.sequanux.org", "Samedi 18 juin 2011 ... Entrée libre et gratuite", 468, 60, "18/06/2011")

// retourne la date format US pour comparaison
function frToUs(date) {
	//str=str.replace(/\//g,'');
	var jour = date.substring(0,2)
	var mois = date.substring(3,5)
	var annee = date.substring(6,10)
	return (annee+mois+jour)
}

// retourne la date du jour format US
function dateJour() {
	var date_du_jour= new Date()
	var mois=date_du_jour.getMonth()+1
	if (mois<=9)
		mois=("0"+String(mois))
	var jour=date_du_jour.getDate()
	if (jour<=9)
		jour=("0"+String(jour))
	var annee=date_du_jour.getFullYear()
	var dateJour=parseInt(String(annee)+String(mois)+String(jour))
	return dateJour
}

// class unePub
function unePub(imagie, lien, slogan, l, h, d) {
	this.image = unePub.arguments[0]
	this.lien = unePub.arguments[1]
	this.slogan = unePub.arguments[2]
	this.l = unePub.arguments[3]
	this.h = unePub.arguments[4]
	if (unePub.arguments[5])
		this.d = unePub.arguments[5]
}

// tirage au hasard d'un numero (unePub)
function tirage(){
	maxi = tableau.length-1
	var numero = Math.round(Math.random()*maxi)
	if (tableau[numero].d) {
		date = frToUs(tableau[numero].d)
		if(parseInt(date)<parseInt(dateJour)) {
			// date depassée
			numero = tirage()
		}
	}
	return numero
}

function metlapub() {
	// calculer la date du jour
	dateJour=dateJour()
	// tirage de unePub
	numero = tirage()
	var texte="<center><a href=\""+ tableau[numero].lien + "\" target=\"_blank\">"
	texte = texte + "<img src=\"" + tableau[numero].image + "\" width=\"" + tableau[numero].l + "\" height=\"" + tableau[numero].h + "\" border=0 alt=\"" + tableau[numero].slogan + "\"></a><br /><a href=\""+ tableau[numero].lien+ "\" target=\"_blank\">" + tableau[numero].slogan + "</a></center>";
	//document.write(texte)
	return texte
}

