// # -*- coding: utf-8 -*-

// Affichage menus navigation générale
window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=230; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

window.onload=montre2;
function montre2(id) {
var d2 = document.getElementById(id);
	for (var i = 1; i<=230; i++) {
		if (document.getElementById('smenu_page'+i)) {document.getElementById('smenu_page'+i).style.display='none';}
	}
if (d2) {d2.style.display='block';}
}

function OpenWindow(strPage, hauteur, largeur, strName, strStatus, strMenu)
{
  if( !strName ) strName = "_blank";
  if( !strStatus ) strStatus = "no";
  if( !strMenu ) strMenu = "no";

  var hauteur_popup=400;
  var largeur_popup=520;
  if (typeof (hauteur) != 'undefined'){hauteur_popup=hauteur} 
  if (typeof (largeur) != 'undefined'){largeur_popup=largeur} 
  var H = (screen.height - hauteur_popup) / 2;
  var L = (screen.width - largeur_popup) / 2;
  popupWindow = window.open(strPage,strName,"status="+strStatus+",menubar="+strMenu+",scrollbars=yes,resizable=yes,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L);
  return popupWindow;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}    
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
//function montre(id) {
//  var d = document.getElementById(id);
//  if (d) {d.style.display='block';}
//}
function cache(id) {
  var d = document.getElementById(id);
  if (d) {d.style.display='none';}
}

function GetExtranetIdent()
{
  var oAjax = new AlkAjax('nameNlValide', 'fnLoadExtranetIdent', ALK_FORM_METHOD_GET, '/libconf/lib/lib_exectmpl.php?tmpl=alkexecextranetident&mode=1', null);
}

function fnLoadExtranetIdent(strHtml)
{
  // retourne le code html de la liste des blocs de la page
  var oDiv = document.getElementById("extranet");
  if ( !oDiv ) return;
  var oStyle = ( oDiv.style ? oDiv.style : oDiv );
  oStyle.display = 'block';
  oDiv.innerHTML = strHtml;
}

function SubmitExtranetIdent()
{
  var f = document.formLogin;
  f.strPwd.value = hex_md5(f.strPwd2.value);
  f.strPwd2.value = "";
  var oAjax = new AlkAjax('nameNlValide', 'fnSubmitExtranetIdent', ALK_FORM_METHOD_POST, '/libconf/lib/lib_exectmpl.php?tmpl=alkexecextranetident&mode=2', 'formLogin');
}

function fnSubmitExtranetIdent(strHtml)
{
  // retourne le code html de la liste des blocs de la page
  var oDiv = document.getElementById("extranet");
  if ( !oDiv ) return;
  var oStyle = ( oDiv.style ? oDiv.style : oDiv );
  oStyle.display = 'block';
  oDiv.innerHTML = strHtml;
}

function OpenCarte(doc_id, cont_id, cont_appli_id, lamb_x, lamb_y, echelle, rub_id, user_id) {
  var extentmin_x = parseInt(parseInt(lamb_x) - parseInt(echelle));
  var extentmax_x = parseInt(parseInt(lamb_x) + parseInt(echelle));
  var extentmin_y = parseInt(parseInt(lamb_y) - parseInt(echelle));
  var extentmax_y = parseInt(parseInt(lamb_y) + parseInt(echelle));
  var strExtent = '';if (lamb_x == '' && lamb_y == '' && echelle == '')	strExtent = ''; else  strExtent = '&EXTENT_MINX='+extentmin_x+'&EXTENT_MINY='+extentmin_y+'&EXTENT_MAXX='+extentmax_x+'&EXTENT_MAXY='+extentmax_y; strUrl = 'http://extranet.agglo-vannes.fr/scripts/sig/index_sig.phtml?template=site&cont_id='+cont_id+'&cont_appli_id='+cont_appli_id+'&rub_id='+rub_id+'&doc_id='+doc_id+strExtent;
  OpenWindow(strUrl,800,1020,'sigCarto');
}

function visible(thingId)
{
  var targetElement;
  targetElement = document.getElementById(thingId) ;
  if (targetElement.style.display == "none")
  {
    targetElement.style.display = "" ;
  } 
}

function invisible(thingId)
{
  var targetElement;
  targetElement = document.getElementById(thingId) ;
  targetElement.style.display = "none" ;
}

function NewsLetterValide(strToken, oForm)
{
  if (oForm.user_mail.value!=""){
    var strParam = strToken+"&"+convertFormValuesToUrlParam(oForm);
    var oAjax = new AlkAjax('nameNlValide', 'fnLoadNewsletterValide', ALK_FORM_METHOD_POST, '/scripts/alkanet/alkanet_site_sql.php?token='+strParam, "formNl");
  }else{
    window.alert("Vous devez saisir votre adresse mail");
  }
}

function fnLoadNewsletterValide(strHtmlContent)
{
  // retourne le code html de la liste des blocs de la page
  var oDiv = document.getElementById("nlreturn");
  if ( !oDiv ) return;
  var oStyle = ( oDiv.style ? oDiv.style : oDiv );
  oStyle.display = 'block';
  visible('nlreturn');
}