var hauteur_page=1;
var hauteur_ligne=new Array();
var HAUTEUR_MAX_PAGE=26; //Hauteur page en cm
hauteur_ligne['Entete']=5;
hauteur_ligne['LLon']=1.5;
hauteur_ligne['LgSepSem']=1;
hauteur_ligne['LgSepSalle']=1;
hauteur_ligne['LgRenc']=0.9;
hauteur_ligne['LgDiv']=0.5;
hauteur_ligne['LgDiv2']=0.5;
hauteur_ligne['LgRencE']=1.5;

function new_Aff(){
   document.forms["Form_Param"].submit();
   return false;   
}
function new_Champ(){
   document.forms["Form_Param"].elements["typeAff"].selectedIndex=1;
   document.forms["Form_Param"].elements["Semaine"].selectedIndex=0;   
   document.forms["Form_Param"].submit();
   return false;   
}
function new_Sem(){
   document.forms["Form_Param"].elements["typeAff"].selectedIndex=0;
   document.forms["Form_Param"].elements["Champ"].selectedIndex=0;   
   document.forms["Form_Param"].submit();
   return false;   
}
function imprime(){
   window.print();
   return false;   
}

function affEntete(titre,ID){
texte="<DIV ID='SP"+ID+"' STYLE='page-break-after=always'></DIV><table ID='CH"+ID+"' class='Entete'><tr>";
texte+="<td class='logo' rowspan=3><img border:0 src='Logo_HBCBWL_nb.JPG' height='100%' width='130'></td>";
texte+="<td class='Entete1'>HAND BALL CLUB BOUSBECQUE WERVICQ-SUD VAL DE LYS</td></TR><tr>";
texte+="<tD class='Entete2'>97 Rue de Wervicq 59166 BOUSBECQUE<br><U>http:/";
texte+="/hbcbwl.com</U><br>webadmin@hbcbwl.com</td></tr><tr><td class='LigneTitre'>";
texte+=titre;
texte+="</TD></TR></table>";
document.write(texte);
}

function affEnteteTable(ID,IDligne){
texte="<tr ID='"+IDligne+"' class='LLon'><th class='ColDate'>DATE</th><th class='ColPoule'>EQUIPE</th>";
texte+="<th class='ColRencontre'>RENCONTRE</th><th class='ColSalle'>Lieu Rencontre</th>";
texte+="<th class='ColCouleur'>Couleur Recevant</th><th class='ColRdV'>Rendez-Vous</th></tr>";
document.write(texte);
}
function styleCalque(idCalque)
{
  if (document.all) calqueStyle = document.all[idCalque].style;
  if (document.layers) calqueStyle = document.layers[idCalque].style;
  if (document.getElementById) calqueStyle = document.getElementById(idCalque).style;
  return calqueStyle;
}

function noprint(ID){
  SP='SP'+ID;
  CalqueStyle=styleCalque(SP);
  CalqueStyle.display='none';
  CH='CH'+ID;
  CalqueStyle=styleCalque(CH);
  CalqueStyle.display='none';
  LL='LG'+ID+'_1';
  CalqueStyle=styleCalque(LL);
  CalqueStyle.display='none';
}
function AjouteLigne(typeligne){
//Ajoute une ligne au chapitre correspondant
   hauteur_page+=hauteur_ligne[typeligne];
}
function NouvellePage(ID){
//Change de page avant chapitre ID
   hauteur_page=hauteur_ligne['Entete'];
}
function MiseEnPage(ID){
  //supprime premier saut de page
  CalqueStyle=styleCalque('SP1');
  CalqueStyle.display='none';
  chapitre=1;  
  ligne=1;
  idligne='LG'+chapitre+'_'+ligne;
  NouvellePage(chapitre);
  memochapitre=1;
  saut_chap=false;
  while(document.getElementById(idligne)){
    while(document.getElementById(idligne)){
	   classe=document.getElementById(idligne).className;
       AjouteLigne(classe);
	   if ((chapitre==memochapitre) && (hauteur_page>HAUTEUR_MAX_PAGE)){
	     // coupure page dans chapitre
		 document.getElementById(idligne).className=classe+'_sp';
		 hauteur_page=0;
		 saut_chap=true;
	   }
	   ligne++;
	   idligne='LG'+ chapitre +'_'+ ligne;
	}
	ligne=1;
	// teste si saut de page
	if ((hauteur_page>HAUTEUR_MAX_PAGE)||(saut_chap)){
	   NouvellePage(chapitre);
	   saut_chap=false;
	   if (chapitre==memochapitre){chapitre++;}
	   memochapitre=chapitre;
	} else {
	   if (chapitre!=memochapitre){noprint(chapitre);}
	   chapitre++;
	}
    idligne='LG'+chapitre+'_'+ligne;
  }
}