
var loadMenu = 0;
var loadSMenu = 0;
var loadSSMenu = -1;
var loadCurrent = 0;
var loadCurrent2 = 0;
var loadWidth = 0;
var loadFadeOut = false;

var menuCurrent = 0;
var menuServices = '1_2';
var menuCEM = '5_1';
var menuFtp = '1_8';
var menuFilm = '3_3';
var menuEvt = '3_1';
var menuEvt2 = '4_3';
var menu3D = '3_4';
var menuEvtId = 146;
var menu3dId = 374;
var smenuCurrent = -1;

var videoWidth = 480;
var videoHeight = 385;

var imgMargins = 50;
var imgNormalWidth = 828;
var imgShortWidth = 648;
var imgWidth = 828;
var imgHeight = 498;
var imgNb = 0;
var imgCurrent = 0;
var imgCurrentWidth = 0;
var textShortWidth = 230;
var textNormalWidth = 410;
var previousNormalLeft = 497;
var previousShortLeft = 407;
var nextNormalLeft = 565;
var nextShortLeft = 475;

var legendNext = '';
var legendPrev = '';

var logoMTdef = 40;
var logoMTmin = 35;
var logoMTmax = 55;
var logoMLdef = 175;
var logoMLmin = 150;
var logoMLmax = 350;

var mouseTimerid = null;
var mousePressed = false;
var smenuHeight = 32;

var userLang = 'fr';
var isIE = 0;


// MAIN FUNCTIONS

function completeDocument(l, did) {
  $('#content').append('<div id="back"> </div><div id="up"> </div><div id="down"> </div><div id="previous"> </div><div id="next"> </div><div id="cbg"><div> </div></div><div id="imgbg"> </div><div id="smenus"><div> </div></div>');
  preloadImages( '/images/pix.png', '/images/up-sel.png', '/images/down-sel.png', '/images/left-sel.png', 
	'/images/right-sel.png', '/images/menu-0-130.jpg', '/images/menu-1-130.jpg', '/images/menu-2-130.jpg', 
	'/images/menu-3-130.jpg', '/images/menu-4-130.jpg');
  // load menu
  if (l) userLang = l;
  var flashvars = {
    lang: userLang
  };
  var params = {
    quality: "high"
  };
  swfobject.embedSWF("main.swf", "menu", "860", "600", "8.0.0", "", flashvars, params);

  $('#images div, #texts div').css('marginLeft', '0px');
  $('#smenus div').css('marginTop', '0px');
  $('#previous, #next, #up, #back').hover(navOver, navOut);
//  $('#smenus p').hover(smenuOver, smenuOut);
  $('#previous').click(imgSlidePrev);
  $('#next').click(imgSlideNext);
  $('#logo a, #back').click(menuShow);
  $('#smenus a').click(changePage2);
  $('#smenus').bind("mousewheel", smenusMWheel);
  $('#up').mousedown(smenusSlideUp);
  $('#down').mousedown(smenusSlideDown);
  $('#up, #down').mouseup(mouseReleased);
  $('#menus h2').click(submenuShow);
  $('#menu div.submenus a').click(changePage3);

  // load default id
  if (did) {
    $(window).load(function(){
      menuLoad(did);
    });
  }

  // ie6
  if (navigator.appVersion.match("MSIE")) {
    arVersion = navigator.appVersion.split("MSIE");
    isIE = parseFloat(arVersion[1]);
  }
}

function navOver() {
  $(this).css('backgroundImage', $(this).css('backgroundImage').replace('.png', '-sel.png'));
}

function navOut() {
  $(this).css('backgroundImage', $(this).css('backgroundImage').replace('-sel', ''));
}
/*
function smenuOver() {
  if ($(this).hasClass('sel')) return;
  $(this).css('color', '#666666');
}

function smenuOut() {
  if ($(this).hasClass('sel')) return;
  $(this).css('color', 'black');
}*/

function preloadImages() {
  var d=document;
  if(d.images){
    if (!d.MM_p) d.MM_p = new Array();
    var i, j = d.MM_p.length, a = 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];
      }
  }
}

// PAGE FUNCTIONS

function changePage(id) {
  if ($('#content').css('top') == '35px') {
    if (menuCurrent == id)
      return false;
    loadFadeOut = true;
    $('#texts, #smenus, #cbg div').fadeOut(600);
    $('#images').fadeOut(600, function(){
      menuLoad(id);
    });
    return false;
  }

  if (menuCurrent && (menuCurrent != id)) {
    loadFadeOut = true;
    $('#texts, #smenus, #cbg div, #images').fadeOut(600);
  }

  $('#menu').animate({top: '-565px'}, 800, 'easeOutExpo');
  $('#content').animate({top: '35px'}, 1000, 'easeOutExpo', function(){
    if (menuCurrent != id)
      menuLoad(id);
  });
}

function changePage2() {
  id = $(this).attr('id').substr(2);
  if (smenuCurrent == id)
    return false;
  loadFadeOut = true;
  $('#texts, #cbg div').fadeOut(600);
  $('#images').fadeOut(600, function(){
    smenuLoad(id);
  });
  return false;
}

function changePage3() {
  id = $(this).attr('id').substr(2);
  $('#menu div.submenus a').removeClass('sel');
  $(this).addClass('sel');
  changePage(id);
  return false;
}

function menuShow() {
  $('#content').animate({top: '600px'}, 800, 'easeOutExpo');
  $('#menu').animate({top: '0'}, 1000, 'easeOutExpo');
  return false;
}

function submenuShow() {
  id = $(this).attr('id').substr(1);
  $('#menu div.submenus').css('display', 'none');
  $('#sm'+id).css('display', 'block');
  return false;
}

// MENU FUNCTIONS

function menuInit(id) {
  loadCurrent = 0;
  loadCurrent2 = 0;
  loadWidth = 0;
  imgNb = 0;
  imgCurrent = 0;
  imgCurrentWidth = 0;
  imgWidth = imgNormalWidth;

  menuCurrent = id;
  ids = id.split('_');
  loadMenu = ids[0]-1;
  loadSMenu = ids[1]-1;
  loadSSMenu = -1;
  smenuCurrent = -1;

  $('#up, #down, #next, #previous, #smenus, #cbg div').css('display', 'none');
  $('#images, #texts, #imgbg').css('width', imgNormalWidth+'px');
//  $('#texts p').css('marginLeft', textNormalWidth+'px');
//  $('#texts p.brands').css('marginLeft', (textNormalWidth-200)+'px');
  $('#previous').css('left', previousNormalLeft+'px');
  $('#next').css('left', nextNormalLeft+'px');
  $('#images div, #texts div').css('marginLeft', '0px');
  $('#smenus div').css('marginTop', '0px');
  $('#cbg div, #images div, #texts div, #smenus div, #legend').empty();
}

function menuLoad(id) {
  menuInit(id);
  imgNb = images[loadMenu][loadSMenu].length;

  // load musique
  if (menuCurrent == '3_6') {
    var flashvars = {
    };
    var params = {
      wmode: "transparent",
      quality: "high"
    };
    swfobject.embedSWF("sound_on_off.swf", "sound", "30", "13", "8.0.0", "", flashvars, params);
  }

  // load smenus
  hasSmenus = smenusLoad();

  // load ftp
  if (menuCurrent == menuFtp) {
    $.get('/ftp-login.php', {lang: userLang}, function(data){
      $('#texts div').append(data);
      var ext = ''; if (userLang != 'fr') ext = '-'+userLang;
      $('#cbg div').append('<img src="/images/menu-'+(loadMenu + 1)+'-130'+ext+'.jpg" />');
      ml = Math.floor(Math.random() * (logoMLmax - logoMLmin + 1) + logoMLmin);
      mt = Math.floor(Math.random() * (logoMTmax - logoMTmin + 1) + logoMTmin);
      $('#cbg img').css({marginTop: '-'+mt+'px', marginLeft: ml+'px'});
      $('#cbg div').css('display', 'block');
    });
  }
  // set menu text
  else if (smenus[loadMenu][loadSMenu].length) {
    if (isIE && (isIE < 7))
      $('#images div').append('<span id="i0" style="width: '+imgWidth+'px; height: '+imgHeight+'px; display:inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'http://www.estouest.ru/images/pix.png\', sizingMethod=\'image\');"></span>');
    else
      $('#images div').append('<img id="i0" src="/images/pix.png" style="width: '+imgWidth+'px; height: '+imgHeight+'px" />');
    $('#texts div').append(smenus[loadMenu][loadSMenu]);
//    if (hasSmenus) {
//      $('#texts p').css('marginLeft', textShortWidth+'px');
//      $('#texts p.brands').css('marginLeft', (textShortWidth-200)+'px');
//    }
    loadCurrent = 1; imgNb ++;

    // set menu text background
    var ext = ''; if (userLang != 'fr') ext = '-'+userLang;
    $('#cbg div').append('<img src="/images/menu-'+(loadMenu + 1)+'-130'+ext+'.jpg" />');
    if ((menuCurrent == '1_3') || (menuCurrent == '1_4') || (menuCurrent == '1_5') || (menuCurrent == '1_6') || (menuCurrent == '2_2') || (menuCurrent == '2_5') || (menuCurrent == '2_6') || (menuCurrent == '3_1') || (menuCurrent == '3_2') || (menuCurrent == '3_3') || (menuCurrent == '3_4') || (menuCurrent == '3_6') || (menuCurrent == '3_7') || (menuCurrent == '4_3') || (menuCurrent == '5_1') || (menuCurrent == '5_2')) {
      ml = logoMLdef;
      mt = logoMTdef;
    }
    else {
      ml = Math.floor(Math.random() * (logoMLmax - logoMLmin + 1) + logoMLmin);
      mt = Math.floor(Math.random() * (logoMTmax - logoMTmin + 1) + logoMTmin);
    }
    $('#cbg img').css({marginTop: '-'+mt+'px', marginLeft: ml+'px'});
    $('#cbg div').css('display', 'block');
  }

  // load images
  if (imgNb - loadCurrent > 0) {
    if (images[loadMenu][loadSMenu][loadCurrent2].match(/jpg$/))
      $('#images div').append('<img class="jpg" id="i' + loadCurrent + '" src="' + 
	images[loadMenu][loadSMenu][loadCurrent2] + '" />');
    else {
      $('#images div').append('<img id="i' + loadCurrent + '" src="' + images[loadMenu][loadSMenu][loadCurrent2] + '" />');
    }
    $('#images div #i' + loadCurrent).load(imgLoad);
  }
  if (imgNb > 1)
    $('#next').css('display', 'block');

  if (loadFadeOut) {
    loadFadeOut = false;
    $('#images, #texts, #smenus, #cbg div').fadeIn(600);
  }
  // preload submenu images
  for (i = 0; i < simages[loadMenu][loadSMenu].length; i ++)
    for (j = 0; j < simages[loadMenu][loadSMenu][i].length; j ++)
      preloadImages(simages[loadMenu][loadSMenu][i][j]);
  return false;
}

// SMENU FUNCTIONS

function smenusLoad() {
  if (!ssmenus[loadMenu][loadSMenu].length)
    return false;
  $('#smenus').css('display', 'block');
  imgWidth = imgShortWidth;

  $('#images, #texts, #imgbg').css('width', imgWidth+'px');
  $('#previous').css('left', previousShortLeft+'px');
  $('#next').css('left', nextShortLeft+'px');
  // rubrique production / photos
  if ((menuCurrent == '3_2') || (menuCurrent == '3_3')) {
    cat = '';
    for (i = 0; i < ssmenus[loadMenu][loadSMenu].length; i ++) {
      m = ssmenus[loadMenu][loadSMenu][i].substr(0, ssmenus[loadMenu][loadSMenu][i].lastIndexOf(' - '));
      c = ssmenus[loadMenu][loadSMenu][i].substr(ssmenus[loadMenu][loadSMenu][i].lastIndexOf('- ') + 2);
      if (c != cat) {
	$('#smenus div').append('<h3>'+c+'</h3>');
	cat = c;
      }
      $('#smenus div').append('<p class="photos"><a href="/" id="sm'+i+'">'+m+'</a></p>');
    }
  }
  else if (menuCurrent == '1_5')
    for (i = 0; i < ssmenus[loadMenu][loadSMenu].length; i ++)
      $('#smenus div').append('<p>'+ssmenus[loadMenu][loadSMenu][i]+'</p>');
  else for (i = 0; i < ssmenus[loadMenu][loadSMenu].length; i ++)
    $('#smenus div').append('<p><a href="/" id="sm'+i+'">'+ssmenus[loadMenu][loadSMenu][i]+'</a></p>');
  $('#smenus a').click(changePage2);
  if ($('#smenus div').height() > imgHeight)
    $('#down').css('display', 'block');
  return true;
}

function smenuInit(id) {
  loadSSMenu = 0;
  loadCurrent = 0;
  loadCurrent2 = 0;
  loadWidth = 0;
  imgNb = 0;
  imgCurrent = 0;
  imgCurrentWidth = 0;
  smenuCurrent = id;
  loadSSMenu = parseInt(id);
  legendNext = '';
  legendPrev = '';

  $('#next, #previous, #cbg div, #texts').css('display', 'none');
  $('#images div, #texts div').css({marginLeft: '0px'});
  $('#texts div, #images div, #legend, #legend2').empty();
}

function smenuLoad(id) {
  smenuInit(id);
  $('#smenus a').removeClass('sel');
  $('#sm'+id).addClass('sel');

  // set menu text
  if (scontents[loadMenu][loadSMenu][loadSSMenu].length) {
    var cont = scontents[parseInt(loadMenu)][parseInt(loadSMenu)][parseInt(loadSSMenu)];
    if (cont.indexOf('$$NEXTLEGEND') >= 0) {
      var arr = cont.split('<p align="left">$$NEXTLEGEND$$</p>');
      $('#legend').append(arr[0].replace('$$LEGEND$$', ''));
    }
    else if (cont.indexOf('$$LEGEND') >= 0)
      $('#legend').append(cont.replace('$$LEGEND$$', ''));
    else {
      if (isIE && (isIE < 7))
	$('#images div').append('<span id="i0" style="width: '+imgWidth+'px; height: '+imgHeight+'px; display:inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'http://www.estouest.ru/images/pix.png\', sizingMethod=\'image\');"></span>');
      else
	$('#images div').append('<img id="i0" src="/images/pix.png" style="width: '+imgWidth+'px; height: '+imgHeight+'px" />');
      $('#texts div').append(cont);
      loadCurrent = 1; imgNb ++;
      $('#texts, #cbg div').fadeIn(600);
    }
  }
  // load video
  if ((menuCurrent == menuFilm)) {
    if (videos[loadSSMenu]) {
      var m = ssmenus[loadMenu][loadSMenu][loadSSMenu].substr(0, ssmenus[loadMenu][loadSMenu][loadSSMenu].lastIndexOf(' - '));
      $('#legend').append('<p align="center" style="font-weight: bold;">'+m+'</p>');
      $('#images div').append('<div id="video"></div>');
      var flashvars = {
        id: videos[loadSSMenu]
      };
      var params = {
        quality: "high"
      };
      swfobject.embedSWF("flv-player.swf", "video", videoWidth, videoHeight, "8.0.0", "", flashvars, params);
    }
  }
  // load kenzo
  else if (((menuCurrent == menuEvt) && (smenuCurrent == 2)) || ((menuCurrent == menuEvt2) && (smenuCurrent == 2))) {
      $('#images div').append('<div id="video"></div>');
      var flashvars = {
        id: menuEvtId
      };
      var params = {
        quality: "high"
      };
      swfobject.embedSWF("flv-player.swf", "video", videoWidth, videoHeight, "8.0.0", "", flashvars, params);
  }
  // load est ouest films
  else if ((menuCurrent == menu3D) && (smenuCurrent == 12)) {
      $('#images div').append('<div id="video"></div>');
      var flashvars = {
        id: menu3dId
      };
      var params = {
        quality: "high"
      };
      swfobject.embedSWF("flv-player.swf", "video", videoWidth, videoHeight, "8.0.0", "", flashvars, params);
  }
  // load images
  else {
    imgNb = simages[loadMenu][loadSMenu][loadSSMenu].length;
    if (imgNb - loadCurrent > 0) {
      var c = '';
      if (simages[loadMenu][loadSMenu][loadSSMenu][loadCurrent2].match(/jpg$/)) {
	if (scontents[loadMenu][loadSMenu][loadSSMenu].indexOf('$$LEGEND') >= 0)
	  c = ' class="jpg2"';
	else
	  c = ' class="jpg"';
      }
      var url = simages[loadMenu][loadSMenu][loadSSMenu][loadCurrent2];
      if (((menuCurrent == menuServices) || (menuCurrent == menuCEM)) && (userLang != 'fr'))
	url = url.replace('.png', '-'+userLang+'.png');
      $('#images div').append('<img'+c+' id="i' + loadCurrent + '" src="' + url + '" />');
      $('#images div #i' + loadCurrent).load(imgLoad2);
    }
    if (imgNb > 1)
      $('#next').css('display', 'block');
  }
  loadFadeOut = false;
  $('#images').fadeIn(600);
  return false;
}

function mouseReleased() {
  if (mouseTimerid) clearTimeout(mouseTimerid);
  mousePressed = false;
}

function mouseWait(func) {
  if (mouseTimerid) clearTimeout(mouseTimerid);
  mouseTimerid = setTimeout(func+"()", 100);
}

function _smenusSlideUp(mwheel) {
  mousePressed = true;
  i = parseInt(($('#smenus div').css('marginTop')).replace("px", ""));   if (i == 0) return;

  if ($('#down').css('display') == 'none')
    $('#down').css('display', 'block');

  i += smenuHeight;
  if (i > 0) i = 0;
  if (i == 0) $('#up').css('display', 'none');
  $('#smenus div').css('marginTop', i+'px');
  if (!mwheel && mousePressed) mouseWait('smenusSlideUp');
}

function _smenusSlideDown(mwheel) {
  mousePressed = true;
  i = parseInt(($('#smenus div').css('marginTop')).replace("px", ""));
  l = 0 - $('#smenus div').height() + $('#smenus').height() - smenuHeight;

  if (i == l) return;

  if ($('#up').css('display') == 'none')
    $('#up').css('display', 'block');

  i -= smenuHeight;
  if (i < l) i = l;
  if (i == l) $('#down').css('display', 'none');
  $('#smenus div').css('marginTop', i+'px');
  if (!mwheel && mousePressed) mouseWait('smenusSlideDown');
}

function smenusSlideUp() {
  _smenusSlideUp(false);
}

function smenusSlideDown() {
  _smenusSlideDown(false);
}

function smenusMWheel(e, d) {
  if (d < 0) _smenusSlideDown(true);
  else _smenusSlideUp(true);
}

// IMAGE FUNCTIONS

function imgLoad() {
  loadCurrent ++;
  loadCurrent2 ++;
  if (loadCurrent == imgNb)
    return;

  if (images[loadMenu][loadSMenu][loadCurrent2].match(/jpg$/))
    $('#images div').append('<img class="jpg" id="i' + loadCurrent + '" src="' + 
	images[loadMenu][loadSMenu][loadCurrent2] + '" />');
  else
    $('#images div').append('<img id="i' + loadCurrent + '" src="' + images[loadMenu][loadSMenu][loadCurrent2] + '" />');
  $('#images div #i' + loadCurrent).load(imgLoad);
}

function imgLoad2() {
  loadCurrent ++;
  loadCurrent2 ++;
  if (loadCurrent == imgNb)
    return;

  var c = '';
  if (simages[loadMenu][loadSMenu][loadSSMenu][loadCurrent2].match(/jpg$/)) {
    if (scontents[loadMenu][loadSMenu][loadSSMenu].indexOf('$$LEGEND') >= 0)
      c = ' class="jpg2"';
    else
      c = ' class="jpg"';
  }
  var url = simages[loadMenu][loadSMenu][loadSSMenu][loadCurrent2];
  if (((menuCurrent == menuServices) || (menuCurrent == menuCEM)) && (userLang != 'fr'))
    url = url.replace('.png', '-'+userLang+'.png');
  $('#images div').append('<img'+c+' id="i' + loadCurrent + '" src="' + url + '" />');
  $('#images div #i' + loadCurrent).load(imgLoad2);
}

function imgSlideNext() {
  if (imgCurrent >= (imgNb - 1))
    return;
  imgCurrentWidth += $('#i'+imgCurrent).width() + imgMargins;

  if (!imgCurrent) {
    $('#previous').css('display', 'block');
    $('#cbg div').css('display', 'none');
  }
  imgCurrent ++;
  if (imgCurrent == (imgNb - 1)) $('#next').css('display', 'none');
  $('#images div').stop();
  $('#images div').animate({marginLeft: '-'+imgCurrentWidth+'px'}, 800, 'easeOutExpo');

  if ((imgCurrent == 1) && ($('#texts').css('display') == 'block')) {
    $('#texts div').stop();
    $('#texts div').animate({marginLeft: '-'+imgCurrentWidth+'px'}, 800, 'easeOutExpo');
  }
  // change legend
  if (scontents[loadMenu][loadSMenu][loadSSMenu].indexOf('$$NEXTLEGEND') < 0)
    return false;
  var arr = scontents[loadMenu][loadSMenu][loadSSMenu].split('<p align="left">$$NEXTLEGEND$$</p>');
  if (arr.length <= imgCurrent)
    return false;
  $('#legend').stop();
  $('#legend').animate({opacity: '0'}, 400, '', function(){
    $('#legend').html(arr[imgCurrent].replace('$$LEGEND$$', ''));
    $('#legend').animate({opacity: '1'}, 400);
  });
}

function imgSlidePrev() {
  if (imgCurrent <= 0)
    return;
  imgCurrentWidth -= $('#i'+(imgCurrent - 1)).width() + imgMargins;

  if (imgCurrent == (imgNb - 1)) $('#next').css('display', 'block');
  imgCurrent --;
  if (!imgCurrent) {
    $('#previous').css('display', 'none');
    if ($('#texts').css('display') == 'block')
      $('#cbg div').css('display', 'block');
  }
  $('#images div').stop();
  $('#images div').animate({marginLeft: '-'+imgCurrentWidth+'px'}, 800, 'easeOutExpo');

  if (!imgCurrent && ($('#texts').css('display') == 'block')) {
    $('#texts div').stop();
    $('#texts div').animate({marginLeft: '-'+imgCurrentWidth+'px'}, 800, 'easeOutExpo');
  }
  // change legend
  if (scontents[loadMenu][loadSMenu][loadSSMenu].indexOf('$$NEXTLEGEND') < 0)
    return false;
  var arr = scontents[loadMenu][loadSMenu][loadSSMenu].split('<p align="left">$$NEXTLEGEND$$</p>');
  if (arr.length <= imgCurrent)
    return false;
  $('#legend').stop();
  $('#legend').animate({opacity: '0'}, 400, '', function(){
    $('#legend').html(arr[imgCurrent].replace('$$LEGEND$$', ''));
    $('#legend').animate({opacity: '1'}, 400);
  });
}

// FTP FUNCTIONS

function ftpSendPassword() {
  if (!document.myform.user_email.value) {
    if (userLang == 'fr') alert('Merci de bien vouloir indiquer votre adresse email.');
    else if (userLang == 'en') alert('Please indicate your email address.');
    return false;
  }
  $.post( "/ftp-send-password.php", { email: document.myform.user_email.value }, function(data){
    if (parseInt(data) == 1) {
      if (userLang == 'fr') alert('Adresse email inconnue. Si vous ne possedez pas encore de compte, merci de bien vouloir faire une demande par mail.');
      else if (userLang == 'en') alert('Unknown email address. If you don\'t have any account, please ask for one by email.');
      return false;
    }
    if (userLang == 'fr') alert('Votre mot de passe vient de vous etre envoye par email.');
    else if (userLang == 'en') alert('Your password has just been sent to you by email.');
    return false;
  });
  return false;
}

function ftpLogin() {
  if (!document.myform.user_email.value) {
    if (userLang == 'fr') alert('Merci de bien vouloir indiquer votre adresse email.');
    else if (userLang == 'en') alert('Please indicate your email address.');
    return false;
  }
  if (!document.myform.user_passe.value) {
    if (userLang == 'fr') alert('Merci de bien vouloir indiquer votre mot de passe.');
    else if (userLang == 'en') alert('Please indicate your password.');
    return false;
  }
  mes = '<p class="help">Connexion en cours...</p>';
  if (userLang == 'en') mes = '<p class="help">Logging in...</p>';
  $('#texts div').html(mes);
  $.post( "/ftp-login.php", { user_email: document.myform.user_email.value, user_passe: document.myform.user_passe.value, lang: userLang }, function(data){
    $('#texts div').html(data);
  });
  return false;
}


