// При нажатии на ссылку с классом toggle в строке с классом toggle показывать/скрывать все строки до строки с классом stoptoggle
// В таблицах указать класс tarifs

$(document).ready(function(){
       
    
/*Вначале все строки после "тоглящейся" строки скрываем, исключение составляют строки с классом nohide*/
    jQuery("tr.toggle").nextUntil(".stoptoggle").hide();
    jQuery("tr.nohide").nextUntil(".stoptoggle").show();
    

/*Скрываем название тарифов в свернутых строках*/
    jQuery("tr.toggle h3.tarif").hide();
    jQuery("tr.nohide h3.tarif").show();
    
    jQuery("tr.toggle a.toggle").click(function() {
        jQuery(this).parent().parent().parent().nextUntil(".stoptoggle").toggle();
        jQuery(this).parent().parent().parent().find("h3.tarif").toggle();
        return false;
    });


/* Подсказка при наведении в таблице - через тултип, раньше было кастомно*/


$(".tarifs .hint").tooltip();

/*
    jQuery(".tarifs .hint-message").hide();

    jQuery(".tarifs .hint").mouseover(function() {
        jQuery(this).next().show();
    }); 
  
    jQuery(".tarifs .hint").mouseout(function() {
        jQuery(this).next().hide();
    });
*/

/* Подсветка строки таблицы при наведении */

    jQuery(".tarifs tr").mouseover(function() {
        jQuery(this).addClass("over");
    }); 
  
    jQuery(".tarifs tr").mouseout(function() {
        jQuery(this).removeClass("over");
    });




    jQuery(".hidden").hide();

/*

    jQuery("a.more").click(function() {        
        $(this).prev().toggle();           
    });

    $("a.more").toggle(function() {
        $(this).html('Скрыть');
    }, function() {
        $(this).html('Подробнее');
    });
    
    
    */


    jQuery("a.show-hint").click(function() {
        displayVal = $(this).next().css('display');
        $(".hint-wrap").hide();
        $("a.show-hint").html('Показать информацию');
        if (displayVal == 'none') {
            $(this).next().show();
            $(this).html('Скрыть информацию');
        }
        else {
            $(this).next().hide();
            $(this).html('Показать информацию');
        }
        return false;
    });
    
    jQuery("a.close-hint").click(function() {
        $(".hint-wrap").hide();
        $(this).parent().parent().prev().html('Показать информацию');
        return false;
    });
    


/*Можно будет попробовать тултипом*/

//jQuery("a.domain-hint").tooltip();

    jQuery("a.domain-hint").click(function() {
        displayVal = $(this).next().css('display');
        $(".hint-wrap").hide();
        if (displayVal == 'none') {
            $(this).next().show();
        }
        else {
            $(this).next().hide();
        }
        return false;
    });
    

    
    
    
    
    
    
    $("#other-apps").hide();
    jQuery("#toggle-other-apps a").toggle(function() {
        $(this).html('Скрыть остальные веб-приложения');
        $("#other-apps").show();
        return false;
    }, function() {
        $(this).html('Показать остальные веб-приложения');
        $("#other-apps").hide();
        return false;
    });
   
   
    jQuery("#faded").show();

    jQuery("a.tell-me").click(function() {
        $("#sendform").show();
        return false;
    });
    
    jQuery('#form_button_Cancel').click(function() {
        $("#sendform").hide();
        return false;
    });    




    jQuery(".h2-wrap h2 a").click(function() {
        displayVal = $(this).parent().parent().next().css('display');
        $(".block-more").hide();
        if (displayVal == 'none') {
            $(this).parent().parent().next().show();
        }
        else {
            $(this).parent().parent().next().hide();
        }
        return false;
    });



    jQuery(".hosting-tarif").hover(function() {
        $(this).find(".hosting-tarif-more").show();
        $(this).find(".recommend").hide();
        $(this).find(".recommend-back").show();
        return false;
         }, function() {
        $(this).find(".hosting-tarif-more").hide();
        $(this).find(".recommend").show();
        $(this).find(".recommend-back").hide();
        return false;
         });



    $("#certificate-more").hide();
    jQuery("a#show-cert").toggle(function() {
        $(this).html('Скрыть');
        $("#certificate-more").show();
        return false;
    }, function() {
        $(this).html('Еще');
        $("#certificate-more").hide();
        return false;
    });  
    
    
    
    
    jQuery("a.akcii-button").toggle(function() {
 $('#akcii').animate({
            right: '+=321',
          }, 500, function() {
            // Animation complete.
          });
    }, function() {
 $('#akcii').animate({
            right: '-=321',
          }, 500, function() {
            // Animation complete.
          });
    });  
    
    
    jQuery("a#login").toggle(function() {
        $("#clients-menu").show();
        return false;
    }, function() {
        $("#clients-menu").hide();
        return false;
    });


    $('#glossary').load('/Plone/lib/glossarii #glossary-page');
    
    $('#ru-abc-lng a').live('click', function(event) {
            $(this).replaceWith($(this).html());
            $("#en-abc-lng").html('<a href="#">Eng</>');
            $("#glossary-results").html('');
            $("#ru-abc").toggle();
            $("#en-abc").toggle();
            event.preventDefault();
            return false;
    });

    $('#en-abc-lng a').live('click', function() {
            $(this).replaceWith($(this).html());
            $("#ru-abc-lng").html('<a href="#">Рус</>');
            $("#glossary-results").html('');
            $("#ru-abc").toggle();
            $("#en-abc").toggle();
            event.preventDefault();
            return false;
    });




    jQuery('#glossary .abc a').live('click', function(event) {
        $('#abc-with-glossary').load('/Plone/lib/glossarii' + $(this).attr('href') + ' #abc-with-glossary>*');
        event.preventDefault();
        return false;
    });  


    jQuery('.portlet-glossary-wrap #glossary-results a').live('click', function(event) {
        $('#portal-column-one').load($(this).attr('href') + ' #portal-column-one>*');  
        $('#portal-column-content').load($(this).attr('href') + ' #portal-column-content>*');
        event.preventDefault();
        return false;
    });  

      $('#friends').twitterFriends({
         debug:1,
         users:12,
         username:'komtet_ru'
   });


});
