﻿
//var LinkActive='';

//var LoaderDiv = '<script type="text/javascript" src="loader.js"></script><div id="header"></div>';

var LoaderDiv = '<div id="header" class="outer"><div class="next"><span>&nbsp;</span></div><i class="clear"><img src="images/dot.gif" alt="" /></i><div id="content"><div class="loader">Идет загрузка...</div><div class="loader-img"></div></div></div>';

var LoaderDivPressa = '<div><h1>Пресс-служба</h1><div class="loader">Идет загрузка...</div><i class="clear"><img src="images/dot.gif" alt=""></i></div>';

var ComPr = '';


function ChangePage(module, linkid)
{

 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: module}, function(data){

  $('#mainresult').html(data);
  ComPr = '';

  if (module == 'main')
  {
   OpenPressaMain();
  }
 // alert('все ОК');
  });
}

function ChangeProjectPage(Page)
{
  var PrStart=Page*4 - 4;
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'projects', prBegin: PrStart}, function(data){

  $('#mainresult').html(data);
  ComPr = '';
 // alert('все ОК');

  });
}

function ChangeProjectMain(PrBg)
{
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'main', prbg: PrBg}, function(data){

  $('#mainresult').html(data);
 // alert('все ОК');

  });
}

function OpenProject(PrId)
{
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'projects', prid: PrId}, function(data){

  $('#mainresult').html(data);
 // alert('все ОК');

  });
}

function ChangeGalleryPage(Page)
{
  var PrStart=Page*12 - 12;
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'gallery', prBegin: PrStart}, function(data){

  $('#mainresult').html(data);
  ComPr = '';
 // alert('все ОК');

  });
}

function OpenGallery(PrId)
{
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'gallery', prid: PrId}, function(data){

  $('#mainresult').html(data);
  ComPr = PrId;
 // alert('все ОК');

  });
}

function ChangePhoto(PrId, PhotoBegin)
{
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'gallery', prid: PrId, loop: 1, phBegin: PhotoBegin}, function(data){

  $('#mainresult').html(data);
  ComPr = PrId;
 // alert('все ОК');

  });
}

function OpenGalleryPhoto(PrId, PhotoBegin)
{
 $('#mainresult').html(LoaderDiv);
 //PhotoBg= PhotoBegin - 1;

 $.post('serv.php', {module: 'gallery', prid: PrId, loop: 1, phBegin: PhotoBegin}, function(data){

  $('#mainresult').html(data);
  ComPr = PrId;
 // alert('все ОК');

  });
}

function OpenPressaMain()
{
// $('#hf').html(LoaderDivPressa);

  $.post('serv.php', {module: 'pressa'}, function(data){

                    $('#hf').html(data);
     });
}

function OpenPressa(Show, Type)
{
 //$('#hf').html(LoaderDivPressa);

 if (ComPr == '')
 {
  $.post('serv.php', {module: 'pressa', show: Show}, function(data){

                    $('#hf').html(data);
                    if (Show == 'all' && Type == 1) window.scrollTo(0,700);
     });
 }
  else
  {
    ChangePressaPrPage('', ComPr);
  }
}

function ChangePressaPage(Page)
{
 RelBegin = Page*6 - 6;
 //$('#hf').html(LoaderDivPressa);

 $.post('serv.php', {module: 'pressa', show: 'all', relbegin: RelBegin}, function(data){

                    $('#hf').html(data);
                    window.scrollTo(0,700);
   });
}

function ChangePressaPrPage(Page, PrId)
{
 if (Page != '') RelBegin = Page*6 - 6;
  else RelBegin = 0;
 //$('#hf').html(LoaderDivPressa);

 $.post('serv.php', {module: 'pressa', show: 'pr', prid: PrId, relbegin: RelBegin}, function(data){

                    $('#hf').html(data);
                    window.scrollTo(0,700);
                    ComPr = PrId;
   });
}

function OpenRelize(RelId)
{
 //$('#hf').html(LoaderDivPressa);

 $.post('serv.php', {module: 'pressa', relid: RelId}, function(data){

  $('#hf').html(data);
  window.scrollTo(0,700);
 // alert('все ОК');

  });
}

function OpenComments(PrID, Action)
{
 $('#mainresult').html(LoaderDiv);
 //alert(ComPr + ' - ' + PrID);
 if (ComPr) Action = 'view';

 $.post('servComm.php', {module: 'comments', action: Action, prid: PrID}, function(data){

  $('#mainresult').html(data);
  ComPr = PrID;


  });
}

function OpenCommentPage(PrID, Begin)
{
 $('#mainresult').html(LoaderDiv);

 if (PrID) Action = 'view';
  else Action = '';

 $.post('servComm.php', {module: 'comments', action: Action, prid: PrID, begin: Begin}, function(data){

  $('#mainresult').html(data);
  if (PrID) ComPr = PrID;
    else  ComPr = '';

  });
}

function CommentAdd(PrID)
{
 $('#mainresult').html(LoaderDiv);

 $.post('servComm.php', {module: 'comments', action: 'add', prid: PrID}, function(data){

  $('#mainresult').html(data);
  ComPr = PrID;

  });
}

function CommentView(PrID)
{
 $('#mainresult').html(LoaderDiv);

 $.post('servComm.php', {module: 'comments', action: 'change', prid: PrID}, function(data){

  $('#mainresult').html(data);
  //ComPr = PrID;

  });
}

function OpenAbout()
{
 $('#mainresult').html(LoaderDiv);

 $.post('serv.php', {module: 'about', action: 'all'}, function(data){

  $('#mainresult').html(data);
  
  });
}
