$(document).ready(function(){
    
    
    //Home Page Animation
    if($.browser.msie){
        
        $('#home-info-block').delay(2000).fadeIn(3000);
    
    }else{
        
        $('#home-info-block').delay(2000).fadeTo(3000,1);
      
    }
    
    
    
    
    
    //Attempt to take iPhone out the equation    
    if( ! is_touch_device() ){
        
        
        //Team Page Hovering
        
        $('a.person').hover(
            function(){
            
                //Need to find the corresponding div ID
                
                var personId = $(this).attr('id');
                personId = personId.split('_');
                personId = personId[1];
                        
                 $('#team-title-block')
                .stop(true, true)
                .css('opacity',0 );
                
                
                $('#team_'+personId)
                .removeClass('hidden')
                .stop(true, true)
                .fadeIn(600);
               
               
                //un-grey the selection
                $(this).find('img')
                .stop(true, true)
                .animate({opacity: '1'},600);
                
                
             
    
            },
            function(){
            
                var personId = $(this).attr('id');
                personId = personId.split('_');
                personId = personId[1];
                        
                $('#team_'+personId)
                .stop(true, true)
                .fadeOut('slow');
                    
               
                $('#team-title-block')
                .stop(true, true)
                .animate({ opacity: 0.8 }, 600);
                
                
                //Grey selected person
                $(this).find('img')
                .stop(true, true)
                .animate({opacity: '0.6'},600);
                
            
        });
        
        
        
        
        //Biz Situ Page Hovering
        
        $('a.situ').hover(
            function(){
            
                //Need to find the corresponding div ID
                
                var situId = $(this).attr('id');
                situId = situId.split('_');
                situId = situId[1];
                        
                $('#situhidden_'+situId)
                .removeClass('hidden')
                .stop(true, true)
                .fadeIn(600);
               
                $('#situ-title-block')
                .stop(false, false)
                .css('opacity',0 );
                
                
                //GREY THE SIBLINBGS
                $(this).siblings()
                .stop(true, true)
                .animate({opacity: '0.7'},600);
                
                
                
    
            },
            function(){
            
                var situId = $(this).attr('id');
                situId = situId.split('_');
                situId = situId[1];
                        
                $('#situhidden_'+situId)
                .stop(false, false)
                .fadeOut(600)
                    
                    
                $('#situ-title-block')
                .stop(true, true)
                .animate({ opacity: 0.8 }, 600);
                
                
                //UN-GREY THE SIBLINBGS
                $(this).siblings()
                .stop(true, true)
                .animate({opacity: '1'},600);
            
        });
        
        
        
        
    
    }
    
    
    
    //Test for tocuh device
    function is_touch_device() { 

        try { 

            document.createEvent("TouchEvent"); 
            return true; 

        } catch (e) { 

            return false; 
  
        } 

    }
    
    
    
    
    $("#confidentiality").validate();
    $("#application").validate();
    
    $("#contactForm").validate();
    
    
    
    $(".tweet").tweet({
                username: "Peter_Charles",
                join_text: "auto",
                avatar_size: 32,
                count: 3,
                auto_join_text_default: "", 
                auto_join_text_ed: "we",
                auto_join_text_ing: "we were",
                auto_join_text_reply: "we replied to",
                auto_join_text_url: "we were checking out",
                loading_text: "loading tweets..."
            });
    
    });



