// ie fix для лєйблов
if(window.iamIE)  {
    window.onload = function(){  
        var a = document.getElementsByTagName("label");
        for(var i=0,j=a.length;i<j;i++){
          if(a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG")          {
            a[i].childNodes.item(0).forid = a[i].htmlFor;
            a[i].childNodes.item(0).onclick = function(){
              var e = document.getElementById(this.forid);
              switch(e.type){
                case "radio": e.checked|=1;break;
                case "checkbox": e.checked=!e.checked;break;
                case "text": case "password": case "textarea": e.focus(); break;
              }
            }
          }
        }
  }
}

function handleFlashClick(banId) {
    //alert('You clicked on flash-banner with id=' + banId);
       
    var urlTo = $('.banner #' + banId + ' param[name="outerUrl"]').val();
    if ( urlTo && (urlTo != '' || urlTo != 'http://') )
        window.document.location = urlTo;
    
    return true;    
}

function open_popupWMP (url){
    open_popup( url, 40 ,10, 600, 500, 1);
}

function open_popup(url, posx, posy, size_w, size_h, scroll) {
    if (window.iamIE) {
        msg=window.open(url,'jmd','scrollbars=1,status=0,toolbar=0,directories=0,menubar=0,location=1,resizable=0,width='+size_w+',height='+size_h+', left='+posx+', top='+posy+'');
    } else {
        msg=window.open(url,'jmd','scrollbars='+scroll+',status=0,toolbar=yes,chrome=yes,directories=0,menubar=1,location=0,resizable=0,width='+size_w+',height='+size_h+', left='+posx+', top='+posy+'');
    }
}
    
$(function(){
    // обработчики после загрузки скриптов и страницы   
    if (window.DD_belatedPNG) {    
    }     
        
    // Фикс для IE6, потому что он не понимает селекторов такого вида ".first.active"
    if (window.iamIE6) {
        //$('#nav td.active:first-child').addClass('firstActive');
        //$('#nav td.active:last-child').addClass('last-child');    
    }
    if (window.iamIE7){
        //$('#nav td:last-child').addClass('last-child');
    }          
})

$("div.button:not(.bactive)").live("click", function(){
    $(this).addClass("bactive").parent("div").next("div").slideDown();
});
$("div.button.bactive").live("click", function(){
    $(this).removeClass("bactive").parent("div").next("div").slideUp();
});

$("div.drbutton:not(.opened)").live("click", function(){
    $(this).find(".button").addClass("bactive");
    $(this).addClass("opened").next("div").slideDown();        
    if(parseInt($(this).attr('session')) > 0) 
      loadFlash($(this).attr('auth'), "orderView", $(this).attr('billing'), $(this).attr('session'));
});

$("div.drbutton.opened").live("click", function(){
    $(this).find(".button").removeClass("bactive");
    $(this).removeClass("opened").next("div").slideUp();        
});


