﻿var cur_present = 0;
var marLeft = 0;
var cur_present_text = document.getElementById('cur_present_text').value;

function showPresentText(id)
{
  if (id != cur_present_text) {
    var logo_width = document.getElementById('present3_company_item_' + id).clientWidth;
    var logo_left = document.getElementById('present3_company_item_' + id).offsetLeft;
    var arrow_left = logo_left + Math.round(logo_width/2) - 20;
    $('#present3_text_' + cur_present_text).hide();
    $('#present3_flash_' + cur_present_text).hide();
    cur_present_text = id;
    $('#present3_arrow').animate({backgroundPosition: arrow_left + 'px 0'}, 300);
    $('#present3_text_' + cur_present_text).show();
    $('#present3_flash_' + cur_present_text).show();
  }
}

function recountMarLeft()
{
  var present_div = document.getElementById('presentation').clientWidth;
  marLeft = Math.abs(Math.floor(present_div/2) - 640)*(-1);
}

function resizePresent()
{
  recountMarLeft();
  var present_marginLeft = marLeft - 1280*cur_present;
  document.getElementById('presentation_block').style.marginLeft = present_marginLeft +'px';
}

function movePresent(num_present)
{
  $('#present_slider_item_'+cur_present+' p').eq(0).animate({opacity: '0'}, 300);
  $('#present_slider_item_'+cur_present+' p').eq(1).animate({opacity: '1'}, 300);
  var present_marginLeft = marLeft - 1280*num_present;
  $('#present_slider_item_'+num_present+' p').eq(0).animate({opacity: '1'}, 300);
  $('#present_slider_item_'+num_present+' p').eq(1).animate({opacity: '0'}, 300);
  $('#presentation_block').animate({marginLeft: present_marginLeft + 'px'}, 300);
  $('#presentation_slider_select').animate({backgroundPosition: num_present*225 + 'px 0'}, 300);
  cur_present = num_present;
}

