var counter = 0;

function equalHeight() {
	counter++;
	
	console.log(counter);
	
	// Instead of min-height, make checkout summary boxes equal height
	//if ($(".inner") && counter == 5) {
	if (counter > 5) {
		
		//console.log('finally:' + counter);
		
		var maxBoxHeight = 0;

		$(".inner .box").each(function(index, value) {
		    var targetHeight = $(this).height();
		    if (maxBoxHeight < targetHeight) {
		    	maxBoxHeight = targetHeight;
		    }
		});

		$(".inner .box").height(parseInt(maxBoxHeight));
	}	
}

$(document).ready(function() {
	//$('#box_1').load('zeliwo/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
	$('#box_1').load('zeliwo/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
		var $ul = $(response).find("ul#leftMenuOffer li.l2 ul");
		$ul.find("a").each(function(index, value) {
		    $(this).attr("href", 'http://www.zeliwo.adjatech.pl/' + $(this).attr("href"));
		});
		$('#box_1').html($ul);
	});
	$('#box_2').load('aluminium/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
		var $ul = $(response).find("ul#leftMenuOffer li.l2 ul");
		$ul.find("a").each(function(index, value) {
		    $(this).attr("href", 'http://www.aluminium.adjatech.pl/' + $(this).attr("href"));
		});
		$('#box_2').html($ul);
	});
	$('#box_3').load('filtracja/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
		var $ul = $(response).find("ul#leftMenuOffer li.l2 ul");
		$ul.find("a").each(function(index, value) {
		    $(this).attr("href", 'http://www.filtracja.adjatech.pl/' + $(this).attr("href"));
		});
		$('#box_3').html($ul);
	});
	$('#box_4').load('energia/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
		var $ul = $(response).find("ul#leftMenuOffer li.l2 ul");
		$ul.find("a").each(function(index, value) {
		    $(this).attr("href", 'http://www.energia.adjatech.pl/' + $(this).attr("href"));
		});
		$('#box_4').html($ul);
	});
	$('#box_5').load('serwis/index.php ul#leftMenuOffer li.l2 ul', function(response, status, xhr){
		var $ul = $(response).find("ul#leftMenuOffer li.l2 ul");
		$ul.find("a").each(function(index, value) {
		    $(this).attr("href", 'http://www.serwis.adjatech.pl/' + $(this).attr("href"));
		});
		$('#box_5').html($ul);
	});

//	$(".inner .box ul li a").live("click", function(){
//		return false;
//	})
	
	$('#flashcontent a').mouseover(function() {
		var $anchor = $(this);
		$('img#mainSite').fadeOut('fast', function(){
			$(this).attr('src', 'index/img/site/' + $anchor.attr('rel') + '.jpg').fadeIn('fast');
		});
	});
	
	//equalHeight();
});

