function equalHeight(group) {
       tallest = 0;
       group.each(function() {
          thisHeight = $(this).height();
          if(thisHeight > tallest) {
             tallest = thisHeight;
          }
       });
       group.height(tallest);
    }
    
$(document).ready(function() {
   equalHeight($(".company"));
   equalHeight($(".news"));
   equalHeight($(".contact_details_item"));
});

//COMPANY LOGOS HOVER ANIMATION
$(document).ready(function() {  
  $('.company_logo').hover(
    function() {
      $(this).find('.company_logo_hover').fadeIn(300);
    },
    function() {
      $(this).find('.company_logo_hover').fadeOut(300);
    }
  );
});

//BUTTON CLASS ANIMATION
$(document).ready(function() {  
  $('.button').hover(
    function() {
      $(this).removeAttr('style');
      $(this).css("backgroundPosition","96% 7px");
      $(this).css("backgroundColor","#27276d"); 
      
      $(this).animate({ backgroundPosition: '92% 7px'}, 100);
      $(this).animate({ backgroundColor: '#4da5dc'}, 150);  
    },
    function() {
      $(this).animate({ backgroundPosition: '96% 7px'}, 100);
      $(this).animate({ backgroundColor: '#27276d'}, 150, function() {
	        $(this).css("backgroundPosition","96% 7px");
          $(this).css("backgroundColor","#27276d");
          $(this).removeAttr('style'); 
      });
       
    } 
  );
});

//OTHER SERVICES TAGS
$(document).ready(function(){
	$(".tab:not(:first)").hide();
	$(".tab:first").show();
	$("#services_tabs_triggers a:first").toggleClass('tab_trigger_active');
	$("#services_tabs_triggers a").click(function(){
    $('#services_tabs_triggers a').removeClass('tab_trigger_active');
		$(this).toggleClass('tab_trigger_active');
    stringref = $(this).attr("href").split('#')[1];
		$('.tab:not(#'+stringref+')').hide();
		if ($.browser.msie && $.browser.version.substr(0,3) == "6.0") {
			$('.tab#' + stringref).show();	
		} 
    if ($.browser.msie && $.browser.version.substr(0,3) == "7.0") {
			$('.tab#' + stringref).fadeIn(function(){
          this.style.removeAttribute("filter");
      });	
		} 
		if ($.browser.msie && $.browser.version.substr(0,3) == "8.0") {
			$('.tab#' + stringref).fadeIn(function(){
          this.style.removeAttribute("filter");
      });	
		} 
		else 
			$('.tab#' + stringref).fadeIn();
		return false;
		
	});
});

//SLIDING OTHER SERVICES COMPANY DESCRIPTION    
$(document).ready(function(){
  $('.tab_desc').hide(); 
  $('.tab-active').next().show();
  $('.tab_button').click(function(){ 
  	if( $(this).next().is(':hidden') ) {
  		$('.tab_button').removeClass('tab-active').next().slideUp();
  		$(this).toggleClass('tab-active').next().slideToggle(); 
  	} else {
      $(this).removeClass('tab-active').next().slideUp(); 
    };
  });
});

// COMPANY FADE-IN CHAIN
$(document).ready(function(){
var i = 0
var n = $(".company").length;
        
function showbox() {
  if(i <= n){
    if ($.browser.msie) { 
    $(".company").eq(i).fadeIn(500, function(){ this.style.removeAttribute("filter");i++; showbox(); }); 
    }  
    else 
      $(".company").eq(i).fadeIn(500, function(){ i++; showbox(); });
    return false;
  }         
}
 showbox();  
});  

// PHOTOZOOM MAGNIFING
$(document).ready(function() {
  if ($.browser.msie) {
    $('.zoom').hover(
    function() {
      $(this).append('<span class="zoom_ico"><img src="img/zoom.png" alt="" /></span>');
    },
    function() {
      $(this).find('.zoom_ico').remove();
    });
	} else {
    $('.zoom').append('<span class="zoom_ico"><img src="img/zoom.png" alt="" /></span>').each(function () {
	  var $span = $('>.zoom_ico', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(300, 1);
	  }, function () {
	    $span.stop().fadeTo(300, 0);
	  });
	});
  }
});     

// ACCORDION MENU
function initMenu() {
  $('#side_nav_block ul').prev().css({
    'backgroundImage' : 'url(img/bullet5.gif)',
    'backgroundRepeat' : 'no-repeat',
    'backgroundPosition' : 'right center'
  });
  $('#side_nav_block ul').hide();
  $('.nav-active').show();
  $('#side_nav_block li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        //checkElement.removeClass('nav-active').slideUp();
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#side_nav_block ul').removeClass('nav-active').slideUp('normal');
        $('#side_nav_block ul').prev().css('fontWeight','normal');
        checkElement.toggleClass('nav-active').slideToggle();
        checkElement.prev().css('fontWeight','bold');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() {initMenu();});

//CLICABLE LI ELEMENT
$(document).ready(function(){
	$(".works_item").click(function(){
    	window.location=$(this).find(".button").attr("href");
      return false;
	});	
}); 
