// JavaScript Document
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
	
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
	  }
    }
  }
}

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	
	for(i=0; i<a.length; i++)
	{
    	alert('');
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  	}
}


function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
}

function Change_ALAUNE (urlimage){
	if (urlimage!='')
	{
		document.getElementById("alaunenewsimg").src=urlimage;
	}
}

// Popup
var myfenetre;
function popup_fenetre(chemin,nom_fenetre,proprietes,largeur,hauteur)
{
	if (myfenetre!=null && !myfenetre.closed)
	{
		myfenetre.close();
	}
	
	if (largeur>0 && hauteur>0)
	{
		w = screen.width;
		h = screen.height;
		leftPos = (w-largeur)/2;
		topPos = (h-hauteur)/2;

		if (proprietes!="")
		{
			proprietes=proprietes+',';
		}
			
		proprietes=proprietes + 'width=' + largeur + ',height=' + hauteur + ',top=' + topPos + ',left='+leftPos;
	}
	
	myfenetre=window.open(chemin,nom_fenetre,proprietes);
	myfenetre.focus();
}

// Moteur de recherche
function lance_recherche(texte)
{
	document.formulaire.txtrecherche.value=texte;
	document.formulaire.submit();
}

// remet le champs de recherche a vide si on a le message de recherche
function supprime_recherche(leform,texte)
{
	if (leform.value==texte)
	{
		leform.value="";
	}
}
function lance_recherche_home()
{
	document.recherche_all.submit();
}

// Fonctions Ajax Popup sur overcontent
function fermer_popup(ladiv)
{
	clearTimeout;
	if (ladiv!="")
	{
		//Effect.SlideUp(ladiv);
		new Effect.Fade(ladiv)
	}
	else
	{
		new Effect.Fade('overcontent')
		//Effect.SlideUp();
	}
	
}


// Fonctions Ajax Concours
function Affiche_Concours()
{
	popup_fenetre('concours.php','JALOU','','800','750');
}

// Fonctions Ajax Rss
function Affiche_Rss(domaine)
{
	Element.show('overcontent');
	new Ajax.Updater('overcontent-update',
	domaine+'/ajax/rss.php',
	{method: 'get',
	parameters: ''
	,evalScripts:true
	});
}

// Fonctions Ajax Home

function Maj_Home_Tv(idtv)
{
	new Ajax.Updater('contenu-home-tv',
	'/ajax/tv_home.php',
	{method: 'get',
	parameters: 'idtv='+idtv
	,evalScripts:true
	});
	
	Maj_Sifr();
}

function Maj_Home_NewTalent(idnewtalent)
{
	new Ajax.Updater('contenu-home-nt',
	'/ajax/newtalent_home.php',
	{method: 'get',
	parameters: 'idnt='+idnewtalent
	,evalScripts:true
	});
	
	Maj_Sifr();
}


function Maj_Home_Patrimoine(idpatrimoine)
{
	new Ajax.Updater('contenu-home-patrimoine',
	'/ajax/magazine_home.php',
	{method: 'get',
	parameters: 'idp='+idpatrimoine
	,evalScripts:true
	});
	
	Maj_Sifr();
}

function Maj_Home_Emag(idmag)
{
	new Ajax.Updater('contenu-home-emag',
	'/ajax/emagazine_home.php',
	{method: 'get',
	parameters: 'idm='+idmag
	,evalScripts:true
	});
	
	Maj_Sifr();
}

function Maj_Home_Event(idevent)
{
	new Ajax.Updater('contenu-home-event',
	'/ajax/events_home.php',
	{method: 'get',
	parameters: 'idev='+idevent
	,evalScripts:true
	});
	
	Maj_Sifr();
}


function NavUnclick(idelem,classe,class_origine)
{
	Element.removeClassName(idelem,classe);
	Element.addClassName(idelem,class_origine);
}

function Navclick(idelem,classe)
{
	Element.addClassName(idelem,classe);
}
