
function ScrollOffsetY()
 {
   if (browser.ie) return document.body.scrollTop;
   return document.body.scrollTop;
 } 
   
   
function getInnerHeight()   
 { return document.body.scrollHeight;
 }		

function getInnerWidth()   
 { return document.body.scrollWidth;
 }		
  

var CloseCallBack = null;  

function SetWindowsCloseCallBack(func_callBack)
 { CloseCallBack =func_callBack; }
 
 
function httpjump(url)
 { 
   if (window.parent)
     if (window.parent!=window)
       if (window.parent.httpjump) 
	     { window.parent.httpjump(url);
 		   return;
 	     }
    window.location=url;		

 } 
   

function closeWindow(bool_mustreload)
 { 
   if (CloseCallBack!=null)
    { CloseCallBack();
	  CloseCallBack =null 
	  return;
    }
	
  setVisible('ExtraDiv',false);
  SetSize('DisableDiv',0,0);
  setVisible('DisableDiv',false);
  if (bool_mustreload) silentReload();
 

  }
  
function DisableMainPage(bool_all)
 {var WinW = GetWindowWidth(); if (WinW<750) WinW=750;
  var WinH = GetWindowHeight(); if (WinH<550) WinH=550;
 
 // if (bool_all) document.getElementById('DisableDiv').style.zIndex = 10000;
 //         else document.getElementById('DisableDiv').style.zIndex = 9000;
  
  
  SetSize('DisableDiv',getInnerWidth(),getInnerHeight());
  setVisible('DisableDiv',true);
 
 } 
 
function EnableMainPage()
 {setVisible('DisableDiv',false);
  setVisible('ExtraDiv',false);
 }  
 
function kpress(e)
 { var key =0;
   if (window.event) key=window.event.keyCode;
   else if (e) key= e.which;
   if (key==13) 
    { //document.loginform.fct.value='';
	  document.loginform.submit();
    }
 } 
 

function  OpenErrorDiv(str_errorsmsg)
 {  var int_width  = 260;
    var int_height = 125;
    DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY());
	var HTMLdata =  '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:260px;height:125px;">'
                   +'<table height="120">'
				   +'<tr><td align=center valign=center>'+str_errorsmsg+'</td></tr>'
				   +'<tr><td align=center valign=bottom><a href="javascript:EnableMainPage();" id="okbtn" class="btn">OK</a></td></tr>'
				   +'</table>'
				   +'</div>'
				   +'</table>';
	document.getElementById('ExtraDiv').innerHTML = HTMLdata;
    setVisible('ExtraDiv',true);
	document.getElementById("okbtn").focus(); 				   							   
 }


function  ConfirmSubmit()
 { 
   document.calendarform.extra.value = document.confirmform.reason.value;
   document.calendarform.submit();
   return true;
 } 


function confirmpress(e)
 { var key =0;
  
   if (window.event) key=window.event.keyCode;
   else if (e) key= e.which;
  
   if (key==13) 
   { 
     return ConfirmSubmit();
   } 
   
   return false;
 } 

 
function  OpenConfirmDiv()
 {  var int_width  = 375;
    var int_height = 125;
    DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY());
	var HTMLdata = '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:375px;height:125px;">'
                   +'<form  name="confirmform">'
				   +'<table height="120">'
				   +'<tr><td colspan=2 valign=center>Veuillez entrer une raison pour la suppression de ces créneaux</td></tr>'
				   +'<tr><td colspan=2 valign=center><input onkeypress="confirmpress(event);" name="reason" size=55><input name="phantom" value="" style="visibility:hidden"></td></tr>'
				   +'<tr><td align=center valign=bottom><a href="javascript:ConfirmSubmit();" id="okbtn" class="btn">OK</a></td>'
				   +'<td align=center valign=bottom><a href="javascript:javascript:EnableMainPage();" class="btn">Annuler</a> </td></tr>'
				   +'</form>'
				   +'</table>'
				   +'</div>'
				   +'</table>';
	document.getElementById('ExtraDiv').innerHTML = HTMLdata;
    setVisible('ExtraDiv',true);
	document.confirmform.reason.focus();   
		   							   
 }


 
function GetCookieValue(str_key,str_cookies)
 {  var data ='';	
    var p = str_cookies.indexOf(str_key+'=');
	 if (p>=0)
	  { n = str_cookies.indexOf(';',p+str_key.length+1);
	    if (n<0) n= str_cookies.length;
		data = str_cookies.substring(p+str_key.length+1,n)
	  }
	return data;   
 } 
 
function GetCookieSession()
 {  
     var cookies = document.cookie;
	 
	 var session =  GetCookieValue('session',cookies)
	 if (session=='') return null;
	 this.session = session;
	 this.day     = GetCookieValue('day',cookies)
     return this;
 } 
 
function  ResetCookieSession()
 { var expiration = new Date( new Date().getTime() - 1000);
   document.cookie ='session=0;expires='+expiration.toGMTString();
   document.cookie ='day=0;expires='+expiration.toGMTString();	
 }
 
function SetCookieSession(str_session,str_day,int_timeout)
 { var expiration = new Date( new Date().getTime()+int_timeout*1000);
   document.cookie =  'session='+str_session+';expires='+expiration.toGMTString();
   document.cookie =  'day='+str_day+';expires='+expiration.toGMTString();
   
 }  
 
 
function TryCookieLogin(str_target)
 { var cookie    = new GetCookieSession();
   if ( cookie == null) return;
   ResetCookieSession();
   var HTMLdata   = '<form action="'+str_target+'" name="loginform" method="POST" >'
	                  +'<input name="sessionid" value="'+cookie.session+'" type="hidden">'
					  +'<input name="jour" value="'+cookie.day+'" type="hidden">'
	  				  +'<form>';
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;	
   document.loginform.submit();
 } 
 
function OpenLoginDiv(int_today,str_target,str_msg,str_fct,bool_loginAllowed)
 {  var int_width  = 350;
    var int_height = 275;
    var session    = 0 ;//GetCookieSession();
	DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY() );
    SetSize('ExtraDiv', int_width , int_height);
    
  
  
    
    var HTMLdata =  '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:260px;height:125px;">'
                   +'<form action="'+str_target+'" name="loginform" method="POST" >'
				 
				   +'<table>'
                   +'<tr><td colspan=2 class="logindata">'+str_msg+'</td></tr>';
				 
	 if (bool_loginAllowed)
	  {
	   if (session<=0)  HTMLdata =  HTMLdata         			   
				   +'<tr><td class="logindata">Utilisateur:</td><td><input onkeypress="kpress(event);" name="user" size=16></td></tr>'
                   +'<tr><td class="logindata">Mot de passe:</td><td><input onkeypress="kpress(event);" name="password" type=password size=16></td></tr>'
                   +'<tr><td>&nbsp;</td><td><a href="javascript:document.loginform.submit();" class="btn">Entrer</a>'
				   +' <a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Annuler</a> </td></tr>';
       else      HTMLdata = HTMLdata +'<input name="sessionid" value="'+session+'" type="hidden">';
	 }
     else 
	 HTMLdata =  HTMLdata 
	               +'<tr><td width=100>&nbsp;</td><td>'
				   +' <br><br><a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Ok</a> </td></tr>';
         	
  
   
     HTMLdata =  HTMLdata            
				   +'</table>'
				   +'<input name="jour" value="'+int_today+'" type="hidden">'
				   +'<input name="fct" value="'+str_fct+'" type="hidden"></form>'
				   +'</div>'
                   +'</td></tr></table>';
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;
   
   if (session<=0)
    { document.loginform.user.focus();   
      setVisible('ExtraDiv',true);
	} else document.loginform.submit();
	   
 } 
 
 
 

function OpenRLoginDiv(int_today,str_target,str_msg,str_fct,int_session)
 {  var int_width  = 350;
    var int_height = 140;
    DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY());
    SetSize('ExtraDiv', int_width , int_height);
    
	var HTMLdata =  '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:260px;height:140px;">'
                   +'<form action="'+str_target+'" name="loginform" method="POST" >'
				 
				   +'<table>'
                   +'<tr><td colspan=2 class="logindata">'+str_msg+'</td></tr>';
				 
	
	    HTMLdata =  HTMLdata         			   
				   +'<tr><td class="logindata">Utilisateur:</td><td><input onkeypress="kpress(event);" name="ruser" size=16></td></tr>'
				   +'<tr><td class="logindata" colspan=2><input onkeypress="kpress(event);" style="border:0;" name="admininherit" type="checkbox">Conserver les droits <i>administrateur</i><br><br></td></tr>'
                   +'<tr><td>&nbsp;</td><td><a href="javascript:document.loginform.submit();" class="btn">Entrer</a>'
				   +' <a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Annuler</a> </td></tr>';
         	   
     HTMLdata =  HTMLdata            
				   +'</table>'
                   +'<input name="jour" value="'+int_today+'" type="hidden">'
				   +'<input name="sessionid" value="'+int_session+'" type="hidden">'
				   +'<input name="fct" value="'+str_fct+'" type="hidden"></form>'
				   +'</div>'
                   +'</td></tr></table>';
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;
   setVisible('ExtraDiv',true);			
   document.loginform.ruser.focus();    
 } 

function OpenPasswordDiv(int_today,str_target,str_msg,str_fct,bool_loginAllowed)
 {  var int_width  = 350;
    var int_height = 200;
    var session    = 0 ;//GetCookieSession();
	DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY() );
    SetSize('ExtraDiv', int_width , int_height);
    var HTMLdata =  '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:260px;height:90px;">'
                   +'<form action="'+str_target+'" name="loginform" method="POST" >'
				 
				   +'<table>'
                   +'<tr><td colspan=2 class="logindata">'+str_msg+'</td></tr>';
	 
	 if (bool_loginAllowed)
	  {
	   if (session<=0)  HTMLdata =  HTMLdata         			   
                   +'<tr><td class="logindata">Mot de passe:</td><td><input onkeypress="kpress(event);" name="password" type=password size=16></td></tr>'
                   +'<tr><td>&nbsp;</td><td><a href="javascript:document.loginform.submit();" class="btn">Entrer</a>'
				   +' <a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Annuler</a> </td></tr>';
       else      HTMLdata = HTMLdata +'<input name="sessionid" value="'+session+'" type="hidden">';
	 }
     else 
	 HTMLdata =  HTMLdata 
	               +'<tr><td width=100>&nbsp;</td><td>'
				   +' <br><br><a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Ok</a> </td></tr>';
         	
  
   
     HTMLdata =  HTMLdata            
				   +'</table>'
				   +'<input name="jour" value="'+int_today+'" type="hidden">'
				   +'<input name="fct" value="'+str_fct+'" type="hidden"></form>'
				   +'</div>'
                   +'</td></tr></table>';
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;
   
   if (session<=0)
    { document.loginform.password.focus();   
      setVisible('ExtraDiv',true);
	} else document.loginform.submit();
 } 
 
function OpenMailPasswordDiv(int_today,str_target,str_msg,str_fct,bool_loginAllowed)
 {  var int_width  = 400;
    var int_height = 125;
    var session    = 0 ;//GetCookieSession();
	DisableMainPage();
	SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY() );
    SetSize('ExtraDiv', int_width , int_height);
    var HTMLdata =  '<table width="100%" height="100%"><tr><td align="center" valign="center">'
                   +'<div class="login" style="position:relative;width:'+(int_width-10)+'px;height:'+(int_height-10)+'px;">'
                   +'<form action="'+str_target+'" name="loginform" method="POST" >'
				 
				   +'<table width="100%" >'
                   +'<tr><td colspan=2 class="logindata">'+str_msg+'</td></tr>';
	 
	 if (bool_loginAllowed)
	  {
	   if (session<=0)  HTMLdata =  HTMLdata         			 
                   +'<tr><td class="logindata" width="100">Email:</td><td><input onkeypress="kpress(event);" name="email" type="text" size=40></td></tr>'  
                   +'<tr><td class="logindata">Mot de passe:</td><td><input onkeypress="kpress(event);" name="password" type=password size=16></td></tr>'
                   +'<tr><td>&nbsp;</td><td><a href="javascript:document.loginform.submit();" class="btn">Entrer</a>'
				   +' <a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Annuler</a> </td></tr>';
       else      HTMLdata = HTMLdata +'<input name="sessionid" value="'+session+'" type="hidden">';
	 }
     else 
	 HTMLdata =  HTMLdata 
	               +'<tr><td width=100>&nbsp;</td><td>'
				   +' <br><br><a href="javascript:document.loginform.fct.value=\'\';document.loginform.submit();" class="btn">Ok</a> </td></tr>';
         	
  
   
     HTMLdata =  HTMLdata            
				   +'</table>'
				   +'<input name="jour" value="'+int_today+'" type="hidden">'
				   +'<input name="fct" value="'+str_fct+'" type="hidden"></form>'
				   +'</div>'
                   +'</td></tr></table>';
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;
   
   if (session<=0)
    { document.loginform.email.focus();   
      setVisible('ExtraDiv',true);
	} else document.loginform.submit();
 }  
 
 

  
function OpenPage(str_url,str_title,int_width,int_height,bool_mustreload)
 { if (isVisible('ExtraDiv')) closeWindow(false);
   DisableMainPage(); 
   var ydec = 0;
  
   
   SetPosition('ExtraDiv', parseInt((WinW -int_width) / 2) ,parseInt( (WinH-int_height) /2) +ScrollOffsetY());
   SetSize('ExtraDiv', int_width , int_height);
   var w1 = int_width-parseInt(int_width /3);
   var w2 = parseInt(int_width /3);
   var HTMLdata = '<table width="'+int_width+'" height="'+int_height+'" cellspacing="0" border="0" cellpadding="0">'
                 +'<tr><td  width="'+w1+'" class="WinA1">&nbsp;</td><td width="'+w2+'" class="WinA2">'+str_title+'</td></tr>'
                 +'<tr><td colspan="2" class="WinB">'
				 +'<IFRAME src="'+str_url+'" BORDER="0" FRAMEBORDER="0" SCROLLING="0" style="width:'+parseInt(int_width -16)+'px;height:'+parseInt(int_height -48)+'px;"  ></iframe>'
				 +'</td></tr>'
				 +'<tr><td colspan="2" class="WinC"><img src="/img/link.gif"><a href="javascript:closeWindow('+bool_mustreload+');">Fermer</a></td></tr>'
                 +'</table>';
   
   document.getElementById('ExtraDiv').innerHTML = HTMLdata;
   setVisible('ExtraDiv',true);
  }

   