// Switch style by clicking lamp
var currentStyle = 'white';
function switchStyle()
{
  $('body').fadeToggle('fast', function(){
    var nextStyle = currentStyle == 'white' ? 'black' : 'white';
    
    // Switch stylesheet
    $('#lStyle').attr('href', 'style/' + nextStyle + '.css');

    // Switch lamp
    $('#iLamp').attr('src', 'img/' + nextStyle + '_lamp.png');

    // Switch logo
    $('#iLogo').attr('src', 'img/logo_' + nextStyle + '.png');
    
    currentStyle = nextStyle;
  }).fadeToggle('fast');

  return false;
}

var translations = {
  'ru': {
    'slogan1': 'Ваш',
    'slogan2': 'профессиональный',
    'slogan3': 'спутник',
    'about1': 'PROFSATEL - IT компания, предоставляющая полный спектр услуг по разработке и поддержке web приложений и сайтов любой сложности. Мы используем современные эффективные технологии, инструменты и методики для быстрого и качественного решения поставленных задач.',
    'about2': 'Наша цель заключается в повышении производительности, результативности и прибыли Вашей компании. Мы поможем Вам в реализации и поддержке Ваших IT проектов, что позволит Вам сфокусироваться на росте и расширении Вашего бизнеса.'
  },
  'en': {
    'slogan1': 'Your',
    'slogan2': 'professional',
    'slogan3': 'satellite',
    'about1': 'PROFSATEL - IT company offering a full range of services to develop and support web applications and web sites of any complexity. We use modern technologies, tools and techniques for fast and high quality solutions of tasks.',
    'about2': 'Our target is to improve productivity, efficiency and profits of your company. We will help you implement and support your IT projects that let you focus on growing and expanding your business.'
  }
};
var currentLanguage = 'en';

function switchLanguage(nextLanguage)
{
  if (nextLanguage != currentLanguage) {
    // Active language link
    $('.' + nextLanguage).addClass('active');
    $('.' + currentLanguage).removeClass('active');

    // Translate content
    for (id in translations[nextLanguage]) {
      $('#' + id).html(translations[nextLanguage][id]);
    }

    currentLanguage = nextLanguage;
  }

  return false;
}

// Move background
var currentBgPosition = 0;
function moveBackground()
{
  currentBgPosition++;
  $('body').css("backgroundPosition", currentBgPosition + 'px 0px');
}

$(function(){
  // Set translation
  if (-1 != navigator.userAgent.search(' ru')) {
    switchLanguage('ru');
  }

  // Start to move background
  setInterval("moveBackground()", 70);
});

