var isIE=false;

function $(id) {
  if      (document.layers)         return document.layers[id];         // NC 4
  else if (document.all)            return document.all[id];            // IE 4
  else if (document.getElementById) return document.getElementById(id); // DOM
  else                              return null;        
}

function detectIE(){
  var browserName=navigator.appName;
  return browserName.toLowerCase().indexOf('internet explorer')>-1;
}

function AfterLoad(){
  if (isIE) {
    var divW=$('cont').offsetWidth-1;
    var divH=$('cont').offsetHeight-1;
    var NeedAdd=0;

    $('corr').style.height=(5-(divH % 4))+"px";
    $('main1').style.paddingRight=(15-(divW % 4))+"px";
  }
}

function swAnsw(id) {
  var a=$('answ'+id);
  if (a.style.display!='block')
    a.style.display='block';
  else
    a.style.display='none';
}

function AttachPreviewImg() {
  var prvimg=$('previewimg');
  if (prvimg!=null) {prvimg.onload=spw2;}
}

function spw(a) {
  AttachPreviewImg();
  //Если display: none, то не загрузится
  $('preview').style.top='-1000px';
  $('preview').style.left='0px';
  $('preview').style.display='block';
  $('previewimg').src=a;
}

function spw2() {
  if ($('previewimg').src!='') {
    $('preview').style.width=$('previewimg').width+25;
    $('preview').style.height=$('previewimg').height+45;
    
    var winW=window.innerWidth?window.innerWidth:document.body.offsetWidth;
    var winH=window.innerHeight?window.innerHeight:document.body.offsetHeight;
    var scrollY=typeof(window.pageYOffset)=='number'?window.pageYOffset:(document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop-100);

    $('preview').style.left=winW>$('preview').offsetWidth?(winW/2-$('preview').offsetWidth/2)+'px':'0px';
    $('preview').style.top=winH>$('preview').offsetHeight?(winH/2-$('preview').offsetHeight/2+scrollY)+'px':'0px';
  }
}

isIE=detectIE();
document.write('<style type="text/css">.answ {display: none;}</style>');
