var currLayer = '';

function openLayer(_layer){
  if(currLayer != ''){
    closeLayer(currLayer);
  }

  if(currLayer == ''){
    var win = window;
  	width_x = win.innerWidth ? win.innerWidth : win.document.body.clientWidth;
  	width_y = win.innerHeight ? win.innerHeight : win.document.body.clientHeight;
  	container_width = parseInt($(_layer).getStyle('width'));
  	container_height = parseInt($(_layer).getStyle('height'));
    currLayer = _layer;
    $(_layer).setStyle({display: 'block'});
  }
}

function closeLayer(_layer){
  $(_layer).setStyle({display: 'none'});
  currLayer = '';
}

function swapImage(_id,_image){
  $(_id).src = _image;
}

function requestPass(){
    var args = "user=" + document.requestPwForm.nickmail.value;
    new Ajax.Updater("responseText", "/?action=externalSendPsw", { method: 'post', asynchronous:true, parameters:args });
}

function chageVote(type){
  if(type == 'plus' && document.votingform.vote.value < 4){
    document.votingform.vote.value++;
  }else if(type == 'minus' && document.votingform.vote.value > 1){
    document.votingform.vote.value--;
  }
  $(responseText).innerHTML = '';
  $(voteImage).src = 'img/garden/level_' + document.votingform.vote.value + '.png';
}

function sendVoting(){
  var tVote = parseInt(document.votingform.vote.value);
  if(tVote > 0 && tVote < 5){
    var args = "vote=" + tVote + "&uid=" + document.votingform.uid.value;
    new Ajax.Updater("responseText", "/?action=externalGardenVote", { method: 'post', asynchronous:true, parameters:args });
  }
  return false;
}

var selectLang = false;
function showLanguageLayer(){
  if(!selectLang){
    $('selectLangBox').setStyle({visibility:'visible'});
    selectLang = true;
  }else{
    $('selectLangBox').setStyle({visibility:'hidden'});
    selectLang = false;
  }
}
function hideLanguageLayer(){
  $('selectLangBox').setStyle({visibility:'hidden'});
}
function setLanguageSelected(){
  $('selectLangBox').setStyle({visibility:'hidden'});
}

var gtcount = 5;
var gtcurrent = 1;
function prevGamesTourimage(_locale){
  if(gtcurrent > 1){
    gtcurrent--;
    $('gamestourimage').src = '/img/'+_locale+'/gamestour/spieltour_' +gtcurrent+ '.png';
  }
}

function nextGamesTourimage(_locale){
  if(gtcurrent < gtcount){
    gtcurrent++;
    $('gamestourimage').src = '/img/'+_locale+'/gamestour/spieltour_' +gtcurrent+ '.png';
  }
}