var quoteCurrent = 0;
var logoCurrent = 0;
var row = 0;
var rowMod = 0;
var logoTotal = 0;
var rowTotal = 0;
baseArray = new Array();

$(document).ready(function() {
	// TYPOGRAPHY
	Cufon.replace('.menus ul', {fontSize:'16px', hover: true});
	Cufon.replace('.menus strong', {fontSize:'14px', hover: true});
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('.quotes p', {fontSize: '20px'});	
	Cufon.replace('#left-column h2', {fontSize: '22px'});
	Cufon.replace('h3');
	Cufon.replace('.rowShade p', {fontSize: '16px'});
	Cufon.replace('#right-column ul.values li', {fontSize: '28px'});
	
	// TECHNOLOGIES SECTION
	var firstTech = $('ul.techList li ul li').eq(0).html();
	var techWidth = 191;
	var arrowOffset = 77;
	var currentPosition = 1;
	// restyle
	$('ul.techList').css({'padding-bottom':'11px','background-image':'url(/wp-content/themes/consol/img/tick.png)', 'background-repeat':'no-repeat', 'background-position':arrowOffset+'px 100%'});
	$('ul.techList li').css({'clear':'none', 'width':techWidth+'px', 'margin':'0 !important'});
	$('ul.techList li ul').css({'display':'none'});
	$('ul.techList li.noMarg').css({'width':'175px'});
	// load content
	$('ul.techList').after('<div id="inform"><span>'+firstTech+'</span></div>');
	$('ul.techList img').css('cursor','pointer').click(function(){
		var currentPosition = $(this).position();
		var currentPosition = currentPosition.left + arrowOffset;
		$('#inform span').html($(this).next().children().html());
		$('ul.techList').animate({'background-position':currentPosition+'px 100%'});
	});
	
	// WHAT WE DO
	var firstWedo = $('ul.wedoList li ul li').eq(0).html();
	var wedoWidth = 191;
	var wedoArrowOffset = 77;
	var wedoCurrentPosition = 1;
	// restyle
	$('ul.wedoList').css({'padding-bottom':'11px','background-image':'url(/wp-content/themes/consol/img/tick.png)', 'background-repeat':'no-repeat', 'background-position':wedoArrowOffset+'px 100%'});
	$('ul.wedoList li').css({'clear':'none', 'width':wedoWidth+'px', 'margin':'0'});
	$('ul.wedoList li ul').css({'display':'none'});
	$('ul.wedoList li:last').css({'width':'220px'});
	// load content
	$('ul.wedoList').after('<div id="inform"><span>'+firstWedo+'</span></div>');
	$('ul.wedoList img').css('cursor','pointer').click(function(){
		var wedoCurrentPosition = $(this).position();
		var wedoCurrentPosition = wedoCurrentPosition.left + wedoArrowOffset;
		$('#inform span').html($(this).next().children().html());
		$('ul.wedoList').animate({'background-position':wedoCurrentPosition+'px 100%'});
	});
	
	// QUOTES
	if($('#quotes_sidebar').length > 0) {
		var timer = setInterval("swapQuote()",3000);
	}
	
	// WHO WORK WITH
	if($('#clientBlock').length > 0) {
		logoTotal = $('#clientBlock li:last').attr('class').substr(1,1);
		for(i=1;i<=logoTotal;i++){
			baseArray.push(i);
		}
		rowTotal = $('#clientBlock .c1').length;
		baseArray.sort( randOrd );
		var logoTimer = setInterval("swapLogo()",1000);
	}	
});
	
	function randOrd(){
		return (Math.round(Math.random())-0.5); 
	}
	
	function swapQuote(){
		var quoteTotal = $('.quotes p').size() - 1;
		quoteCurrent++;
		if(quoteCurrent > quoteTotal){quoteCurrent = 0;}
		$('.quotes p').slideUp("slow");
		$('.quotes p').eq(quoteCurrent).slideDown("slow");
	}
	
	function swapLogo(){
		$('#clientBlock .c'+baseArray[logoCurrent]).eq(row).fadeOut(function(){
			if (row + 1 > rowTotal-1) { rowMod = 0 } else { rowMod = row + 1;}
			$('#clientBlock .c'+baseArray[logoCurrent]).eq(rowMod).fadeIn();			
			logoCurrent++;
			if(logoCurrent > logoTotal-1) { 
				logoCurrent = 0; 
				row++;
				if (row > rowTotal-1) { row=0}
			}
		});
	}

