$(document).ready(function() {
  
  /*
  $(".panel-1 .boxin").css('height', 0);
  $(".panel-2 .boxin").css('height', 0);
  $(".panel-3 .boxin").css('height', 0);
  $(".panel-1").css('margin-right', '-286px');
  $(".panel-2").css('margin-right', '-286px');
  $(".panel-3").css('margin-right', '-286px');  

  $(window).load(function () {

    $(".panel-1 .boxin").animate({
      height: "226px",
    },
    function(){
      $(".panel-1").animate({
        'margin-right': "10px"
      });
      $(".panel-2 .boxin").animate({
        height: "226px"
      },
      function(){
        $(".panel-2").animate({
          'margin-right': "10px"
        });
        $(".panel-3 .boxin").animate({
          height: "226px"
        }, function(){        
          $(".panel-3").animate({
            'margin-right': "10px"
          });
        })
        .animate({
          height: "226px"
        }, "fast");
      })
      .animate({
        'height': "226px"
      }, "fast");
    })
    
  });
  
  $(".panel a").mouseover(function(){
    $(this).animate({
      "margin-left":"20px",
    }, "fast").animate({
      "margin-left":"0"
    }, "fast");
  });
  */
  
  $('#top-team li:first-child').addClass('active');
  $('.person').hide();
  $('.person:first-child').show();
  
  $('#top-team a').mouseover(function()
  {  	
  	$('#top-team li').removeClass('active');
  	$(this).parent().addClass('active');
  	
		var id = $(this).attr('href');
		$('.person').hide();
		$(id).show();
  });
  
  $('#top-team a').click(function(){
		return false;
  });
  
	var b1 = $('#home .panel-1 .box a').css('background');
	var b2 = $('#home .panel-2 .box a').css('background');
	var b3 = $('#home .panel-3 .box a').css('background');
	$('#home .panel-1 .box a').css('background', 'none');
	$('#home .panel-2 .box a').css('background', 'none');
	$('#home .panel-3 .box a').css('background', 'none');
		
	$(window).load(function () {
		$('#home .panel-1 .box a').css('background', b1);
		$('#home .panel-2 .box a').css('background', b2);
		$('#home .panel-3 .box a').css('background', b3);
	});

	
  $('.client').hide();
  $('.client:first-child').show();
  
	$('#top-logos li a').click(function()
  {
		var id = $(this).attr('href');
		$('.client').hide();
		$(id).show();
		return false;
  });
  

	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	//var isiPad = navigator.userAgent.match(/Mozilla/i) != null;
	
	if (isiPad) {
		$('#top-plus div').click(function(){
			if ($(this).find('p').css('top') == '79px') {
				$(this).find('p').css('top', '-9999px');
			} else {				
				$('#top-plus div p').css('top', '-9999px');
				$(this).find('p').css('top', '79px');
			}
		});
	}
	
	
	
	// LOGOS
	$(window).load(function () {
		
		var scroll_speed = 50;
		var scroll_pixels = 2;
		var scroll_interval = 0;
		var scroll_pos = 0;	
		var scroll_width = 0;
		
		$('.scroll li').each( function(){ scroll_width += $(this).outerWidth(true); });

		scroll_width = -scroll_width + 900;
		//scroll_width = -1580 + 900;
		
		scroll_interval = setInterval(function() {
			scroll_move(-scroll_pixels);
		}, scroll_speed);
			
		function scroll_move(movement)
		{		
			scroll_pos = scroll_pos + movement;
			
			if (scroll_pos >= scroll_width && scroll_pos < 0) {
				$(".scroll ul").css('left', scroll_pos);
			}
			
			if (scroll_pos < scroll_width) {
				clearInterval(scroll_interval);
				scroll_interval = setInterval(function() {
					scroll_move(scroll_pixels);
				}, scroll_speed);
			}
			if (scroll_pos > 0) {
				clearInterval(scroll_interval);
				scroll_interval = setInterval(function() {
					scroll_move(-scroll_pixels);
				}, scroll_speed);
			}
		}
		
		$(".scroll-forward").click(function(){
			clearInterval(scroll_interval);
			scroll_interval = setInterval(function() {
				scroll_move(scroll_pixels);
			}, scroll_speed);
		});
		
		$(".scroll-back").click(function(){
			clearInterval(scroll_interval);
			scroll_interval = setInterval(function() {
				scroll_move(-scroll_pixels);
			}, scroll_speed);
		});
		
	});  
	
	
	
	
	
		
		
	/* ta ACCORDION 1.0 */
	(function($){
	  $.fn.ta_accordion = function(options) 
	  {    
	    var defaults = {
	      tab     : '.item',
	      trigger : 'h3',
	      hook    : 'h3'
	    };
	    var options =  $.extend(defaults, options);
	    
	    var id = this.selector;


	    $(id+' '+options.tab).hide();
	    //$(id+' '+options.trigger+':first').addClass('current').next().show();
	    
	    $(id+' '+options.hook).click(function() {
	      if($(this).next().is(':hidden')) {
	        $(this).addClass('current').next().slideDown();
	      } else {
	        $(this).removeClass('current').next().slideUp();				
	      }
	      return false;
	    });
	  };
	})(jQuery);

	$('.accordion').ta_accordion();
		
		
	

	// wait until document is fully scriptable
	$(function() {

		// select #flowplanes and make it scrollable. use circular and navigator plugins
		$("#flowpanes").scrollable({ circular: false, mousewheel: true });
	});
	
	if ($(window).height() < 720) {
		$('#popup').css('height', $(window).height());
	}
	
	$(window).resize(function() {	
		if ($(window).height() <= 730) {
			$('#popup').css('height', $(window).height());
		} else {
			$('#popup').css('height', 730);
		}
	});

	
});  
  
  
  
