﻿var panelI=0;
var panelCnt=0;
function nextPanel() {
 $('.panel').slice(panelI,panelI+1).fadeOut('slow', function(){
  panelI+=1
  if (panelI>panelCnt)
   panelI=0
  $('.panel').slice(panelI,panelI+1).fadeIn('slow',function(){
   var duration=(0+parseInt($(this).find('.duration').html()))*1000;
   var embed=$(this).find('object,embed')
   if ( embed.length )
   {
    embed[0].SetVariable("method:setVolume", 0);
    embed[0].SetVariable("method:play","0");
    var pos=parseInt(0+$(this).find('.position').html())
    embed[0].SetVariable("method:setPosition", ""+pos*1000);
    embed.slice(0,1).animate(  {
     opacity:1
    }, duration+500, function(){
     $(this)[0].SetVariable("method:stop","0");
    })
   }
   window.setTimeout('nextPanel()',duration);
  })
 });
}

var myListener = new Object();
myListener.onInit =
 myListener.onUpdate =
 myListener.onClick =
 myListener.onFinish=
 myListener.onFinished=
 myListener.onKeyUp=function(){}
$(function(){
 panelCnt=panelI=$('.panel').length-1;
 window.setTimeout('nextPanel()',2000);
})

      function really()
      {
        return confirm('Вы уверены?');
      }

      var isDOM=((document.getElementById)?true:false);
      var isIE4=((document.all&&!isDOM)?true:false);
      var isNS4=(document.layers?true:false);

      agent=navigator.userAgent.toLowerCase();
      is_IE=true;
      is_IE=((agent.indexOf("msie")!=-1) && (agent.indexOf("opera")==-1));
      function object(id)
      {
        if(isDOM) return document.getElementById(id);
        if(isIE4) return document.all[id];
        if(isNS4) return document.layers[id];
      }

      function ns(element,text)
      {
        if (element==null) return;
        if (element.href==null) return;
        //starting img preload

        ni=new Image;
        ni.src=element.href;

        nw=parent.window.open('','','menubar=0,location=0,resizable=1,scrollbars=0,status=0,titlebar=0,toolbar=0');
        nw.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>',
        '<title>BALTIC COAL TERMINAL, '+text+'</title>',
        '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">',
        '<meta http-equiv="Pragma" CONTENT="No-Cache">',
        '<meta http-equiv="Cache-control" CONTENT="private"></head>',
        '<body style="margin:0;padding:0;text-align:center"><a href="#" title="'+text+' \n[кликните, чтобы закрыть окно]"><img  width="1200" id="ni" alt="'+text+' \n[кликните, чтобы закрыть окно]" src="'+element.href+'" style="cursor:hand" onclick="self.close()" /></a>',
        '<script src="full.js"></sc','ript></body></html>');
        nw.document.close();
      }

      function pv(element)
      {
        img=object('preview');
        if (img==null) return;
        if (element==null) return;
        if (element.value==''||element.value=='undefined') return;
        img.src=element.value;
        img.width=200;
        img.height=160;
      }

      function pv_other(element)
      {
        img=object('preview_other');
        if (img==null) return;
        if (element==null) return;
        if (element.value==''||element.value=='undefined') return;
        img.src=element.value;
        img.width=200;
        img.height=160;
      }

      function byid(id)
      {
        if (document.getElementById)
          return (document.getElementById(id));
        if (document.all)
          return document.all[id];
        if (document.layers)
          return document.layers[id];
        return false;
      }
