$(document).ready(function() {
      
    $('#mainSlideShow').cycle({
        fx:     'fade', 
        requeueOnImageNotLoaded: true,
        delay: -1000,
        speed: 8000,
        continuous: 1      
    });
   
    $('.lnkHide').click(function(){
        $(this).parent().slideUp('slow');
        $(this).parent().parent().find('a.lnkShow').show('slow');
        return false;
    }) ;
   
    $('.lnkShow').click(function(){       
        $(this).parent().find('div.slideText').slideDown('slow');
        $(this).hide('slow');
        return false;
        
    }) ;
   
    var arrayOfUsedSlides = new Array();   
    $('#contentSlide').cycle({ 
        fx:     'scrollHorz', 
        prev:   '#slideArrowLeft', 
        next:   '#slideArrowRight',      
        timeout: 0,
        pager: '#slidePager',
        easing: 'easeOutExpo',       
        speed: 700,       
        requeueOnImageNotLoaded: true,
        after: function(){            
            var slided = false;
            id = this.id.split('_');
            var size =  $('#slideImage_'+id[1] + '> img').size();
            if (size > 1)
            {
                for (i=0;i<arrayOfUsedSlides.length;i++){
                    if (arrayOfUsedSlides[i] == id[1])
                        slided = true;
                }
                if (slided == false){       
          
                    $('#nav_'+id[1]).remove();
                    $('#slideImage_'+id[1])
      
                    .before('<div id="nav_'+id[1]+'" class="slideImagesNav"><a href="#" id="playPauseSlide_'+id[1]+'" style="display: none;" class="slidePause"></a></div>')            
       
                    .cycle({ 
                        fx:     'fade', 
                        speed:  2000, 
                        timeout: 5000,
                        requeueOnImageNotLoaded: true,
                        sync: true    
               
                    });
                    $('#playPauseSlide_'+id[1]).click(function(){
                        $('#slideImage_'+id[1]).cycle('toggle');
                        if ($(this).attr('class') == 'slidePause')
                            $(this).removeClass('slidePause').addClass('slidePlay');               
                        else if ($(this).attr('class') == 'slidePlay')
                            $(this).removeClass('slidePlay').addClass('slidePause');
                  
                        return false;
                    });
                    $('#playPauseSlide_'+id[1]).show('slow');                      
                    arrayOfUsedSlides.push(id[1]);            
        
                }
            }
            $(this).find('div.slideText').delay(1200).slideDown('slow'); 
        },
        before: function(){    
        }
    });


    $('.categoryButtons').hover(function(){
        $(this).css('background-position', '0 -194px');
    },function(){
        $(this).css('background-position', '0 0');
    });

    $('.goToContact').click(function(){
        $.scrollTo('#contact_form', 800, {
            margin: true,
            offset: -70,
            easing: 'easeOutCubic'           
        });
        return false
    });
    
     
   $('.journalDev').qtip({
      content: {
         text: false 
      },
      position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'rightMiddle'
        
      },
       adjust: { x: 5, y: 83 }
      },
     style: { 
      fontSize: 10,
      width: 100,
      height: 15,
      padding: 0,
      background: 'rgb(234, 234, 234)',
      color: '#000000',
      
      textAlign: 'center',
      border: {
         width: 1,
         radius: 10,
         color: 'rgb(234, 234, 234)'
      },
      tip: 'topRight',
      name: 'dark' 
   }
   });
   
});
