/*colored or not in clients page*/
window.onload = function(){
	jQuery.each($('.pop_up .inner'), function(){
									$(this).show();
									  if($(this).height()<28) {
										  $(this).height(28)
										  }
										  $(this).hide();
									  });
$('.customer a').hover(
	function() {
		$(this).children().css('display','none');
		$(this).find('.colored').css('display', 'block');
		},
	function() {
		var el = $(this);
		$(this).children().css('display','block');
		$(this).find('.colored').css('display', 'none');
	}
);}

/*popup in clients page*/
$(document).ready(function() {
 var timeoutID;
 $('.customer a').hover(function(){
 $(this).closest('li').find('.pop_up .inner').fadeIn('fast');
 },
 function (){
 var el = $(this);
 timeoutID = setTimeout(function(){el.closest('li').find('.pop_up .inner').fadeOut('fast');}, 1500);
 })

 $('.pop_up .inner').hover(function(){
 clearTimeout(timeoutID);
 $(this).show();
 },
 function(){
 $(this).closest('li').find('.pop_up .inner').fadeOut('fast');
 })
}); 

var lc;
$(function() {
	
	is_ie  = (jQuery.browser.msie);
	is_ie6 = (jQuery.browser.msie && jQuery.browser.version == '6.0');
	is_ie7 = (jQuery.browser.msie && jQuery.browser.version >= '7.0');
	
	// add top/bottom arrow
	$('.pi-ba').append('<img class="ba" src="/templates/prototype/i/icons/ba.gif" width="6" height="6" />');
	$('.pi-ta').prepend('<img class="ta" src="/templates/prototype/i/icons/ta.gif" width="6" height="6" />');
	
	if(is_ie6){
		$('div.layout-box').each(function(){
			//$(this).replaceWith('<span id="' + $(this).attr('id') + '" class="' + $(this).attr('class') + '">' + $(this).html() + '</span>');
			
		});
		
		// hover emulation
		$('.list-colored a, .footer-box .styled li').hover(function(){
			$(this).addClass('hover');
			//$(this).css('background','#000');
		}, function(){
			$(this).removeClass('hover');
			//$(this).css('background','#fff');
		});
	}
	
	if(is_ie) {
		$('.page-portfolio-item > p').filter('*:first').addClass('pi-screen-description-first').wrapInner('<span></span>');
		lc = $('.layout-container');
/*		$(window).resize(function(){
			lc.width(document.body.clientWidth < 950? "950px" : document.body.clientWidth > 1225? "1225px" : "auto");
		});
		lc.width(document.body.clientWidth < 950? "950px" : document.body.clientWidth > 1225? "1225px" : "auto");*/
	}
	
	// add percentage bar to news year list
	$('.box-news-years li').each(function(){
		var percentage = $(this).attr('class');
		percentage = percentage.slice(2);
		$(this).prepend('<span class="count-bar"><i class="count" style="width: ' + percentage + '%;"></i></span>');
	});
	
	// 2-cols height allign
	var colHeight = 0;
	if ($('.lb-8 .page-content').height() <= $('.lb-4.page-content').height()) {
		colHeight = $('.lb-4.page-content').height();
		(is_ie6) ? cssHeight = 'height' : cssHeight = 'min-height' ;
		$('.lb-8 .page-content').css(cssHeight, colHeight - 30);
	} else {
		colHeight = $('.lb-4.page-content').height();
		(is_ie6) ? cssHeight = 'height' : cssHeight = 'min-height' ;
		$('.lb-8 .page-content').css(cssHeight, colHeight - 30);
	}
	
	// .pi image hover
	$('.pi-image').hover(function(){
		$(this).next('h2').find('a').addClass('hovered');
	}, function(){
		$(this).next('h2').find('a').removeClass('hovered');
	});
	
	$('.lb-4.pi:nth-child(3n)').after('<div class="cc"></div>');
	$('.lb-2.pi:nth-child(6n)').after('<div class="cc"></div>');
	
	// :last-child emulation
	$('li:last-child, p:last-child').addClass('last');
	
	// :last-child emulation
	$('th:first-child, td:first-child').addClass('first');
	
	// add top border element to box items
	$('.footer-box, .pt').prepend('<em class="box-t"></em>');
	
	// add aiken arrow element to portfolio items
	$('p.pi-image').before('<div class="a-arrow"><!-- --></div>');
	
	if(is_ie6) {
		DD_belatedPNG.fix('.png, div, img');		
	}
	

});