$(window).load(function() {
    $('#slider').nivoSlider({
        effect:"boxRandom",
        slices:15,
        boxCols:8,
        boxRows:4,
        animSpeed:500,
        pauseTime:3000,
        startSlide:0,
        directionNav:true,
        directionNavHide:true,
        controlNav:true,
        controlNavThumbs:false,
        controlNavThumbsFromRel:true,
        keyboardNav:true,
        pauseOnHover:true,
        manualAdvance:false,
        prevText: 'Далее', // Prev directionNav text
        nextText: 'Назад', // Next directionNav text
    });
});


$(document).ready(function() {

    var cache = new Array();
    var isOpera = window.opera ? true : false;
    

    /* кнопка наверх */

    $('#bottom-menu-bar ul li a.top-button').click(function(e) {
        e.preventDefault();
        if ( isOpera === true ) {
            $('html').animate({
                scrollTop: '0px'
            }, 500, 'easeInOutCubic');
        } else {
            $('html, body').animate({
                scrollTop: '0px'
            }, 500, 'easeInOutCubic');
        }
    });

    /* иницилизация основного меню */

    $('#main-menu').topMenu({
        moreText: ' &darr;',
        animationSpeed: 500
    });
    
    /* скругление углов */
    
    $('.message-box .box-content').corner("bottom round 8px");
    $('.simple-message-box').corner('round 8px');
    $('blockquote').corner('round 8px');
    $('ul.page-navbar li a').corner('round 2px');

    /* текстовое сообщение */
    $('.message-box .title a').click(function(e) {
        e.preventDefault();
        $(this).parent().parent().find('.box-content').slideToggle(500);
    });


    /* сторока поиска */

    $('#search').focusin(function() {
        if ( $(this).val() == 'Enter search term here...' ) {
            $(this).val('');
        }
    });
    $('#search').focusout(function() {
        if ( $(this).val().trim() == '' ) {
            $(this).val('Enter search term here...');
        }
    });

var stext = $('.fourth.last div:hidden').text();
//$('#ui-tooltip-modal').css('max-width','700px');
$('.fourth.last h1').qtip(
   {
      id: 'modal', // Since we're only creating one modal, give it an ID so we can style it
      content: {
         text: stext,
         title: {
            text: 'Промышленное швейное оборудование, промышленные швейные машины, высокотехнологичные вышивальные машины, раскройное оборудование, а также оверлок промышленный и оборудование вто.',
            button: true
         }
      },
      position: {
         my: 'center', // ...at the center of the viewport
         at: 'center',
         target: $(window)
      },
      show: {
         event: 'click', // Show it on click...
         solo: true, // ...and hide all other tooltips...
         modal: true // ...and make it modal
      },
      hide: false,
      style: {
      	width: 800,
      	classes: 'ui-tooltip-light ui-tooltip-rounded'
      	
      }
   });

var authform = $('.f-auth').html();
//$('#ui-tooltip-modal').css('max-width','700px');
$('.auth').qtip(
   {
      id: 'modal', // Since we're only creating one modal, give it an ID so we can style it
      content: {
         text: authform,
         title: {
            text: 'Авторизация',
            button: true
         }
      },
      position: {
         my: 'center', // ...at the center of the viewport
         at: 'center',
         target: $(window)
      },
      show: {
         event: 'click', // Show it on click...
         solo: true, // ...and hide all other tooltips...
         modal: true // ...and make it modal
      },
      hide: false,
      style: {
      	width: 300,
      	classes: 'ui-tooltip-light ui-tooltip-rounded'
      	
      }
   });

var regform = $('.f-reg').html();
//$('#ui-tooltip-modal').css('max-width','700px');
$('.reg').qtip(
   {
      id: 'modal', // Since we're only creating one modal, give it an ID so we can style it
      content: {
         text: regform,
         title: {
            text: 'Регистрация',
            button: true
         }
      },
      position: {
         my: 'center', // ...at the center of the viewport
         at: 'center',
         target: $(window)
      },
      show: {
         event: 'click', // Show it on click...
         solo: true, // ...and hide all other tooltips...
         modal: true // ...and make it modal
      },
      hide: false,
      style: {
      	width: 800,
      	classes: 'ui-tooltip-light ui-tooltip-rounded'
      	
      }
   });

});//document.ready конец


String.prototype.trim = function() {
    a = this.replace(/^\s+/, '');
    return a.replace(/\s+$/, '');
};
