var is_ie = (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent));
function GID(id) { return (is_ie) ? document.all[id] : document.getElementById(id); }

$(document).ready(function() {
   $(".pngFix").pngFix();
   checkFlash();
   checkGallery();
   $.fn.alignCenter = function() {
      var marginLeft = - $(this).width()/2 + 'px';
      var marginTop = - $(this).height()/2 + 'px';
      return $(this).css({'margin-left': marginLeft, 'margin-top': marginTop});
   };
   $.fn.togglePopup = function(){
      if ($('#popup').hasClass('hidden')) {
         if ($.browser.msie) {
            $('#opaco').height($(document).height()).toggleClass('hidden').click(function() { $(this).togglePopup(); } );
            $('#popup').css({'position': 'absolute', 'left': ($(document).width() / 2), 'top': ($(document).height() / 2)});
         }
         else {
            $('#opaco').height($(document).height()).toggleClass('hidden').fadeTo('slow', 0.7).click(function() { $(this).togglePopup(); } );
            $('#popup').css({'position': 'fixed', 'left': '50%', 'top': '50%'});
         }
         $('#popup').alignCenter().toggleClass('hidden');
      }
      else {
         $('#opaco').toggleClass('hidden').removeAttr('style').unbind('click');
         $('#popup').toggleClass('hidden');
      }
   };
});

function initVideo() {
   var fv = { backcolor: 'black', frontcolor: 'white', lightcolor: 'white', screencolor: 'black', repeat: 'single', autostart: true };
   fv['file'] = '/data/file/P1010012.flv';
   htmlOptions = { src: "image/player.swf", width: '600', height: '480', flashvars: fv, replace: '<table class="noFlash"><tr><td align="center">Íå óñòàíîâëåí Adobe® Flash® Player<br /><a href="http://www.adobe.com/ru/products/flashplayer/" target="_blank">Óñòàíîâèòü</a></td></tr></table>' };
   $('#videoFlash').flash(htmlOptions, pluginOptions);
}

onload = init;
if ($.browser.msie) { onresize = bodySize; }

function init() {
   if ($.browser.msie) { bodySize(); }
}

function bodySize() {
   if ($.browser.msie && (document.documentElement.clientWidth || document.body.clientWidth)) {
      $("#tablemain").css('width', ((document.documentElement.clientWidth || document.body.clientWidth) > 1280) ? 1280 : "100%");
   }
}
