//--------------------------------popup-----------------------------------------
var my_popup_cache = {};
function myPopupShow ($e, $id, $url, $btype) {
    var $cont = $($e.currentTarget || $e.target).find('.my_popup_cont');

    if (my_popup_cache[$id]) {
        $cont[0].style.display = '';
        return;
    }
    if ($btype == 1)
      {var $popup = makePopup_top();}
    else
      {var $popup = makePopup();}
    $popup.appendTo($cont);

    $popup.find('.my_popup_content').html('<div style="width:1px; height:123px;"><!-- --></div><div align="center">Загрузка...</div><div style="width:1px; height:123px;"><!-- --></div>');

    (function ($closure_popup, $closure_id) {
        $.get($url, {}, function ($data) {
            $closure_popup.find('.my_popup_content').html($data);
        });
        my_popup_cache[$closure_id] = 1;
    })($popup, $id);
}

function myPopupHide ($e) {
  var $cont = $($e.currentTarget || $e.target).find('.my_popup_cont');
  $cont[0].style.display = 'none';
}

function makePopup () {
  return $('  <div style="position:absolute; display: block; top: -260px; z-index: 11000" class="my_popup">    <table cellpadding="0" cellspacing="0" border="0">      <tr>        <td rowspan="3" valign="bottom"><div style="position:relative; left: 1px" class="strl png"></div></td>        <td><div class="my_popup_topleft png"><!-- --></div></td>        <td><div class="my_popup_topmid png"><!-- --></div></td>        <td><div class="my_popup_topright png"><!-- --></div></td>      </tr>      <tr>        <td colspan="3"><div class="my_popup_mid png">          <div style="width:200px; height:1px;"><!-- --></div>          <div class="my_popup_content"></div>        </div></td>      </tr>      <tr>        <td><div class="my_popup_botleft png"><!-- --></div></td>        <td><div class="my_popup_botmid png"><!-- --></div></td>        <td><div class="my_popup_botright png"><!-- --></div></td>      </tr>    </table>  </div>');
}
function makePopup_top () {
  return $('  <div style="position:absolute; display: block; top: -250px; z-index: 11000" class="my_popup">    <table cellpadding="0" cellspacing="0" border="0">      <tr>        <td rowspan="3" valign="bottom"><div style="position:relative; left: 1px; top: -200px" class="strl png"></div></td>        <td><div class="my_popup_topleft png"><!-- --></div></td>        <td><div class="my_popup_topmid png"><!-- --></div></td>        <td><div class="my_popup_topright png"><!-- --></div></td>      </tr>      <tr>        <td colspan="3"><div class="my_popup_mid png">          <div style="width:200px; height:1px;"><!-- --></div>          <div class="my_popup_content"></div>        </div></td>      </tr>      <tr>        <td><div class="my_popup_botleft png"><!-- --></div></td>        <td><div class="my_popup_botmid png"><!-- --></div></td>        <td><div class="my_popup_botright png"><!-- --></div></td>      </tr>    </table>  </div>');
}
//---------------------------------slide----------------------------------------
function animate(tagId,alfa,step){
 div = document.getElementById(tagId);
 var items = new Array();
 //получаем рисунки
 for(c=i=0;i<div.childNodes.length;i++){
  if (div.childNodes[i].tagName=="IMG"){
   items[c] = div.childNodes[i];
   c++;
  }
 }
 last = items[items.length-1];
 next = items[items.length-2];
 last.style.opacity= alfa/100;
 last.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity="+alfa+")";
 last.style.filter= "alpha(opacity="+alfa+")";

 if ((alfa-step)>0){
   setTimeout("animate('"+tagId+"',"+(alfa-step)+","+step+");",50);
 }else{
  next.style.opacity= 1;
  next.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
  next.style.filter= "alpha(opacity=100)";
  tmp = last;
  div.removeChild(last);
  div.insertBefore(tmp,items[0]);
  tmp.style.opacity= 1;
  tmp.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
  tmp.style.filter= "alpha(opacity=100)";
  setTimeout( "slideSwitch('"+tagId+"',1000)", 3000 );
 }
}
function slideSwitch(tagId,speed){
 div = document.getElementById(tagId);
 if (div.style.visibility!="visible"){
      div.style.visibility = "visible";
 }
 items = div.getElementsByTagName('img');
 if (items.length>0){
  animate(tagId,100,10);
 }
}
function slideSwitchStart(tagId, startTimeout){
  setTimeout("slideSwitch('"+tagId+"',1000)", startTimeout);
}



