/*
*	Fichier commun.js : Fonctions clientes javascripts communes à toutes les pages du site
*/

// -- Variable de test pour détecter le navigateur web
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// ----- Fonctions pour le survol des sous-rubriques dans infoBulle (fond de cellule en négatif)
function negatifon1(obj){
	obj.parentElement.style.backgroundColor='#0066cc';
}
function negatifoff1(obj){
	obj.parentElement.style.backgroundColor='#0049AE';
}
function negatifon2(obj){
	obj.parentElement.style.backgroundColor='#0049AE';
}
function negatifoff2(obj){
	obj.parentElement.style.backgroundColor='#0066cc';
}
//------- Fonctions pour les pages de recherche
function genererPages(nbPages,pageCourante,libellePrecedent,libelleSuivant){
	reponse="";
	if (pageCourante>1){
		reponse+='<a class=image href="javascript:changePage('+(pageCourante-1)+')"><img src="images/commun/flech-left.gif" border="0"></a>&nbsp;&nbsp;<a class=lienAccueil href="javascript:changePage('+(pageCourante-1)+')">'+libellePrecedent+'</a>&nbsp;&nbsp;';
	}
	for (i=1;i<=nbPages && (i<=10 || i<=pageCourante+2);i++){
		if (i!=pageCourante){
			reponse+='<A class=lienAccueil HREF="javascript:changePage('+i+');" target=_self>'+i+'</A>';
		}else{
			if (nbPages>1){reponse+=i;}
		}
		if (i<nbPages){
			reponse+='</b><font color=#FFFFFF> | </font><b>';
		}
	}
	if (pageCourante<nbPages){
		reponse+=('&nbsp;<a class=lienAccueil href="javascript:changePage('+(pageCourante+1)+')">'+libelleSuivant+'</a>&nbsp;&nbsp;<a class=image href="javascript:changePage('+(pageCourante+1)+')"><img src="images/commun/flech-right.gif" border="0"></a>');
	}
	document.write(reponse);
}
//------ fonction permettant d'ouvrir une popup à l'adresse url de taille largeur par hauteur
function popup(url,largeur,hauteur){
	var f=window.open(url,"fenetre","height="+hauteur+",width="+largeur+",scrollbars=no");
	f.focus();
}
//------ fonction permettant d'afficher le haut de la page html
function haut(){
	tmp=location.href;
	if (tmp.indexOf('#top')>0)
		location.href=tmp.substring(0,tmp.indexOf('#'));
	else
		location.href+='#top';
}
//------ Fonction pour cibler la recherche sur best-oc
function rechercher(mots){
	location.href="http://bestoc.com/recherche.asp?logo=http://akiway.com/images/accueil/akilogo.gif&barre=9C9EFB&lien=330066&titre=330066&boite=ffffff&ref=http://www.akiway.com&script=http://www.akiway.com/js/chaines.js&mots="+mots;
}
// -- Fonctions Standard Macromedia Dreamweaver
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_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_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++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
/*
function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- Le champ '+nm+' doit contenir une adresse mail valide.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- Le champ '+nm+' doit contenir une valeur numérique.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- Le champ '+nm+' doit contenir une valeur numérique comprise entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Le champ '+nm+' est obligatoire.\n'; }
  } if (errors) alert('Le formulaire n\' a pas pu être validé pour les raisons suivantes :\n'+errors);
  document.MM_returnValue = (errors == '');
}
*/
function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name;obj=val; if ((val=val.value)!="") {
      if (obj.type=="checkbox")	if (!obj.checked) errors+='- La case '+nm+' doit être cochée.\n';
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- Le champ '+nm+' doit contenir une adresse mail valide.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- Le champ '+nm+' doit contenir une valeur numérique.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- Le champ '+nm+' doit contenir une valeur numérique comprise entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est obligatoire.\n'; }
  } if (errors) alert('Le formulaire n\' a pas pu être validé pour les raisons suivantes :\n'+errors);
  document.MM_returnValue = (errors == '');
}

// --- Fonction permettant de choisir le moteur de recherche avec bouton radio

function moteurRecherche(){
	var f=document.recherche;
	var texte=f.texte.value;
	var url='';
	for (i=0;i<f.moteur.length;i++)
		if (f.moteur[i].checked)
			url=f.moteur[i].value;
	window.open(url+texte,"recherche","");
	return false;
}

function changePage(numPage){
	d=document.forms[0];
	d.PageNo.value=numPage;
	d.changePage.value='ok';
	d.submit();
}

function cache(){
	//document.all.calqueDep.style.visibility="hidden";
}

function val(champ,valeur){
	eval('document.forms[0].'+champ+'.value="'+valeur+'";');
	document.forms[0].submit();
}

function meteo(){
	window.open("../meteo/meteo.asp","meteo","width=600,height=500,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
}

function meteo_num(num){
	window.open("http://search.meteoconsult.fr/cgii-bin/achat?MIval=/partenaire/reference/produit.html&langue=fr&fond=%23FFFFFF&texte=%230A1A58&nbr_jours=5&num_ville="+num,"","width=600,height=400,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no");
}

function chat(pseudo)
{
	window.open("http://chat.akiway.com/index.php?pseudo="+pseudo,"chat","width=700,height=570,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no");
}

function favoris(){
	self.external.addfavorite('http://akiway.com','Akiway');
}

function scores(jeu){
	window.open("http://akiway.com/site/jeux/scores.asp?jeu="+jeu,"score","width=400,height=450,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
}