var myWindow;

function openCenteredWindow(url) {
    var width = 800;
    var height = 600;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "subWind", windowFeatures);
}


$(document).ready(function(){

    $('.e-photo').click(function(){
        file = $(this).attr('href');
        $('#e-canvas').html('<img src="'+file+'"/>');
        return false;

    });
    if(typeof(main)!='undefined'){
        $('.mm').mouseover(function(){
            image = Math.floor(Math.random() * 10) + 1;
            $('#image1').attr('src' , '/im/pixel.gif');
            $('#image2').attr('src' , '/im/pixel.gif');
            if (image<=5){
                $('#image1').attr('src' , '/im/startpage_'+image+'.png');
            }else{
                $('#image2').attr('src' , '/im/startpage_'+image+'.png');
            }
        });
        $('.mm').mouseout(function(){
            $('#image1').attr('src' , '/im/pixel.gif');
            $('#image2').attr('src' , '/im/pixel.gif');
        });
    }else{
        var curphotobottom = Math.floor(Math.random()*3);;
        photosbottom = new Array();
        photosbottom.push("/im/bottom_im2.jpg");
        photosbottom.push("/im/bottom_im3.jpg");
        photosbottom.push("/im/bottom_im4.jpg");

        function changeBottomImage()
        {
            curphotobottom=Math.floor(Math.random()*3);
            $('.bottom_change_image').attr('src', photosbottom[curphotobottom]);
        }
        changeBottomImage();
    }

    $('.e-area-button').mouseover(function(){
        $('#image1').attr('src' , '/im/pixel.gif');
        $('#image2').attr('src' , '/im/pixel.gif');
        parentname = $(this).parent().attr('id');
        if (parentname=='Map'){
            $('#image1').attr('src' , '/im/'+$(this).attr('id')+'.png');
        }else{
            $('#image2').attr('src' , '/im/'+$(this).attr('id')+'.png');
        }
    });
    $('.e-area-button').mouseout(function(){
        $('#image1').attr('src' , '/im/pixel.gif');
        $('#image2').attr('src' , '/im/pixel.gif');
    });
    $('.e-area-button').click(function(){
        return false;
    });

});
function sendPass() {
    email = document.getElementById('emailsend').value;
    if (email == '') {
      alert('Введите E-mail');
      return;
    }
    url = '/services/index/sendpass/?email='+email;
    $.ajaxSetup({
        beforeSend: function(req){
            req.setRequestHeader("X-Requested-With", 0);
        }
    });
    $.post(url, function(data) {
      
      $('error',data).each(function(i, _item){
          document.getElementById('tsend').style.display = 'none';
          _result = $(_item).text();
          if (_result == 1) {
            document.getElementById('sendok').innerHTML = 'E-mail was not found. Указанный E-mail не найден.';
          } else if (_result == 2) {
            document.getElementById('sendok').innerHTML = 'Error sending E-mail. Ошибка отправки уведомления.';
          } else {
            document.getElementById('sendok').innerHTML = 'E-mail successfully sent. E-mail успешно отправлен.';
          }
          return;
      });


    })
  
}
