$(document).ready(function(){
		
		$('.abs').fadeOut(1); 
		$('.mac_main').fadeOut(1);
		$('.fadein').fadeOut(1);
		
		$('.offon').delay(4000).fadeIn(1);
		$('.fadein').fadeIn(4000);
		
		$('.mac_main').fadeIn(4000);
		$('.s1').delay(2000).fadeIn(1000);
		$('.s2').delay(3000).fadeIn(1000);
		$('.s3').delay(4000).fadeIn(1000);
		$('.s4').delay(5000).fadeIn(1000);
		
		function onoff(){
			if ( $('.offon').hasClass('none')==0  ){
				var s = Math.floor(Math.random() * (10000 - 0 + 1)) + 0;
				if (s > 2500) { $('.offon').fadeOut(1); }
				else { $('.offon').fadeIn(150).fadeOut(150).fadeIn(150).fadeOut(150); }
				}	
			}
		setInterval(onoff, 500);
		
		var incount=0;
		function abs(index){
			if (index==0 && incount>0) { $('.abs').fadeOut(1).delay(700).fadeIn(300);  $('.offon').removeClass('none')}
			else { $('.abs').stop(true,true).fadeOut(1); $('.offon').addClass('none')}
			incount++;
			}
		
		$('.clients_banners a img').animate({opacity: 0.5}, 1 );
		$('#toleft').fadeOut(1);
		
		var h='957px';
		$('.content').animate({height: h}, 1);
		$('#pl').animate({height: h}, 1);
		$('.content').scrollTo($(".page").eq(0), 1);
		
		links=$('.menu_link').size();
		index=0;
				
		$('.menu_link').click(function(){
			index=$(this).index('.menu_link');
			$('#pl').stop(true,true).scrollTo($(".page").eq(index), 700);
			
			var h=$('.page').eq(index).outerHeight()+'px';
			$('.content').animate({height: h}, {duration: 700, queue: false});  $('#pl').animate({height: h}, {duration: 700, queue: false});
						
			if (index <= 0) {$('#toleft').fadeOut(700)} else {$('#toleft').fadeIn(700)}
			if (index >= 2) {$('#toright').fadeOut(700)} else {$('#toright').fadeIn(700)}
			
			abs(index);
			
			$('.menu_link').removeClass('active');
			$(this).addClass('active');
			});
			
		
		$(".arrow").hover(
		  function () {
			$(this).children('img').animate({opacity: 0.6}, 50 );
		  },
		  function () {
			$(this).children('img').stop(true,true).animate({opacity: 1.0}, 50 );
		  }
		);
		
		$(".clients_banners a").hover(
		  function () {
			$(this).children('img').stop(true,true).animate({opacity: 1.0}, 100 );
		  },
		  function () {
			$(this).children('img').animate({opacity: 0.5}, 100 );
		  }
		);
		
		$('#toleft').click(function(){
				index--;
				if (index < 0) index=0;
				
				$('.menu_link').removeClass('active');
				$('.menu_link').eq(index).addClass('active');
				
				if (index <= 0) {$('#toleft').fadeOut(700)} else {$('#toleft').fadeIn(700)}
				if (index >= 2) {$('#toright').fadeOut(700)} else {$('#toright').fadeIn(700)}
				
				abs(index);
				
				$('#pl').stop(true,true).scrollTo($(".page").eq(index), 700);
				var h=$('.page').eq(index).outerHeight()+'px';
				$('.content').animate({height: h}, {duration: 700, queue: false});  $('#pl').animate({height: h}, {duration: 700, queue: false});
			});
			
		$('#toright').click(function(){
				index++;
				if (index > links-1) index=links-1;
				
				$('.menu_link').removeClass('active');
				$('.menu_link').eq(index).addClass('active');
				
				abs(index);
				
				if (index <= 0) {$('#toleft').fadeOut(700)} else {$('#toleft').fadeIn(700)}
				if (index >= 2) {$('#toright').fadeOut(700)} else {$('#toright').fadeIn(700)}
				
				$('#pl').stop(true,true).scrollTo($(".page").eq(index), 700);
				var h=$('.page').eq(index).outerHeight()+'px';
				$('.content').animate({height: h}, {duration: 700, queue: false});  $('#pl').animate({height: h}, {duration: 700, queue: false});
			});
			
		$('#tocont').click(function(){
			index=2;
			if (index <= 0) {$('#toleft').fadeOut(700)} else {$('#toleft').fadeIn(700)}
			if (index >= 2) {$('#toright').fadeOut(700)} else {$('#toright').fadeIn(700)}
			abs(index);
			$('.menu_link').removeClass('active');
			$('.menu_link').eq(index).addClass('active');
			$('#pl').stop(true,true).scrollTo($(".page").eq(index), 700);
			$(document).scrollTo($('html'), 700);
			$(document).delay(700).scrollTo($("#clientsid"), 500);

			var h=$('.page').eq(index).outerHeight()+'px';
			$('.content').animate({height: h}, {duration: 700, queue: false});  $('#pl').animate({height: h}, {duration: 700, queue: false});
		});
			
});						   

