jQuery(window).load(function() {
	$('#mycustomscroll a').click(function() {
		var upAfterHeight = clearAll();
		var elementId = $(this).attr('id').substring(1);
		
		$('#a'+elementId).stop(true,true).fadeOut(0);
		$('#e'+elementId).stop(true,true).fadeOut(0);
		$('#a'+elementId).attr('show','false');
		$('#e'+elementId).attr('show','false');
		
		$('#ahpl'+elementId).fadeIn();
		var height = 80;
		var i =0;
		for (i=0;i<100;i=i+1){
			if (i>elementId && $('#a'+i).length){
				var curHeight = $('#a'+i).css('margin-top');
				var textLen = parseInt(curHeight.length-2);
				curHeight = parseInt(curHeight.substring(0,textLen));
				var changeValue
				$('#a'+i).css('margin-top',curHeight+height+'px');
				$('#e'+i).css('margin-top',curHeight+height+'px');
			}
		}
		$("#upAfterClick").css('height',(upAfterHeight+height)+'px');
		fleXenv.updateScrollBars();
	});
	
	$('.paginationClass a').click(function() {
		$('.paginationClass').find('a').removeClass("active");
		$(this).addClass("active");
	});
});

function runHeight(){
		var upAfterHeight = clearAll();
		var elementId = $(this).attr('id').substring(1);
		
		$('#a'+elementId).stop(true,true).fadeOut(0);
		$('#e'+elementId).stop(true,true).fadeOut(0);
		$('#a'+elementId).attr('show','false');
		$('#e'+elementId).attr('show','false');
		
		$('#ahpl'+elementId).fadeIn();
		var height = 80;
		var i =0;
		for (i=0;i<100;i=i+1){
			if (i>elementId && $('#a'+i).length){
				var curHeight = $('#a'+i).css('margin-top');
				var textLen = parseInt(curHeight.length-2);
				curHeight = parseInt(curHeight.substring(0,textLen));
				var changeValue
				$('#a'+i).css('margin-top',curHeight+height+'px');
				$('#e'+i).css('margin-top',curHeight+height+'px');
			}
		}
		$("#upAfterClick").css('height',(upAfterHeight+height)+'px');
		fleXenv.updateScrollBars();
}

function clearAll(){
	var iterator = 0;
	var maxValue = 0;
	$("#upAfterClick").find("a").each(function(){
		$(this).attr('show','true');
		$(this).attr('show','true');
		$('#ahpl'+(iterator+1)).fadeOut();
		$(this).css('margin-top',iterator*30);
		if ($(this).attr('hreflang')=='a'){
			$(this).fadeIn();
		}
		if ($(this).attr('hreflang')=='e'){
			iterator=iterator+1;
		}
		maxValue = iterator*30;
	});
	return maxValue;
} 
