﻿var position = 0;
var i = 0;
var i2 = 0;
function next(){
	if(position < (($(".imageFrame").length-5)*104)){ 
		$(".imageFrame").animate({"marginLeft":"-=104px"},"slow");
		position += 104;
		i2++;
	}
}

function prev(){
	if(position>0){
	$(".imageFrame").animate({"marginLeft":"+=104px"},"slow");
	position -= 104;
	i2--;
	}
}

function nextBig(){
	if(position < (($(".imageFrameBig").length-1)*520)){ 
		$(".imageFrameBig").animate({"marginLeft":"-=520px"},"slow");
		position += 520;
		i++;
		$(".imageListBig").attr("style","height:"+$(".imageFrameBig").children('img')[i].height+"px");		
	}
}

function prevBig(){
	if(position>0){
	$(".imageFrameBig").animate({"marginLeft":"+=520px"},"slow");
	position -= 520;
	i--;
	$(".imageListBig").attr("style","height:"+$(".imageFrameBig").children('img')[i].height+"px;");	
	}
}

function hideList(index){
	$(".imageGallery").css("display","none");
	$(".imageGalleryBig").css("display","block");	
	$(".imageListBig").attr("style","height:"+$(".imageFrameBig").children('img')[index].height+"px;");
	$(".imageFrameBig").animate({"marginLeft":"-="+520*index+"px"},0.1);
	position = index * 520;
	i = index;
}

function close(){
	$(".imageGallery").css("display","block");
	$(".imageGalleryBig").css("display","none");	
	$(".imageListBig").attr("style","height:"+$(".imageFrameBig").children('img')[0].height+"px;");
	$(".imageFrameBig").animate({"marginLeft":"+="+520*i+"px"},0.1);
	$(".imageFrame").animate({"marginLeft":"+="+104*(i2)+"px"},0.1);
	position = 0;
	i2 = 0;
	i = 0;
}

window.onload = function() {
    if ($('.imageText .image img') != null) {
        var width = $('.imageText .image img').width();
        $('.imageText .image h2').css('width', width);
    }
    if ($(".contentLeft").height() != null) {
        var height = $(".contentLeft").height();
        var MaxCount = $(".newsList").children(".newsItem").length;
        var count = (MaxCount * 126) + 24;
        while (count > height) {
            MaxCount--;
            count = (MaxCount * 126) + 24;
            $(".newsList").children(".newsItem:last").remove();
        }
    }
}



