function setEqualHeight(columns, admin, offset, new_tallestcolumn) {
	var tallestcolumn = 0;
	columns.each(function() {
		currentHeight = $(this).height();
		if(currentHeight > tallestcolumn) {
			tallestcolumn  = currentHeight;
		}
	});
//console.log(' - 1 - ' +  tallestcolumn);

	if(window.innerHeight) {
		height = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	} else if(document.body && document.body.clientHeight) {
		height = document.body.clientHeight;
	}

//console.log(' - 2 - ' +  tallestcolumn);
	if(admin == 0) header = 125;
	else header = 125;

	if(offset != 0) {
		//tallestcolumn = header + offset;
		tallestcolumn = tallestcolumn;
	}

//console.log(' - 3 - ' +  tallestcolumn);
	if(tallestcolumn < height) {
		//height = height - header; //full height of header
		tallestcolumn = height;
	}

//console.log(' - 40 - ' +  new_tallestcolumn);
	if(new_tallestcolumn > tallestcolumn) {
		tallestcolumn = new_tallestcolumn;
	}
//console.log(' - 4 - ' +  tallestcolumn);

	//columns.height(tallestcolumn + 100);
	columns.height(tallestcolumn);
	tallestcolumn = 0;
	offset = 0;

}


function show_big_img(src, id) {
//console.log(src);
	//$('#show').append('<img src="' + src + '" alt="" />');
	var id = id.split("_");
	var about = $('#about_' + id[1]).html(); //.show();
	var descr = $('#descr_' + id[1]).html(); //.show();
	var url = $('#url_' + id[1]).html(); //.show();

//console.log(about);
//console.log(descr);
//console.log(url);

	if(url) {
		$('#show').append('<a href="' + url + '" title="' + descr + '" target="blank"><img src="' + src + '" alt="' + descr + '" /></a>');
	} else {
		$('#show').append('<img src="' + src + '" alt="' + descr + '" />');
	}
	$('#show').append('<div id="about">' + about + '</div>');
}


function go(arr, src, direction) {
	var next_id;
	for(aid in arr['src']) {
		if(!src) {
			src = arr['src'][aid];
			var first = 1;
		}
		if(src == arr['src'][aid]) {
			$('#show').empty();
			if(first) {
				next_id = aid;
			} else {
				if(direction == 1) {
					next_id = parseInt(aid) - 1;
					if(arr['src'][next_id - 1]) {
						$('#go_left').show();
					} else {
						//$('#go_left a').hide();
					}
				} else {
					next_id = parseInt(aid) + 1;
					if(arr['src'][next_id + 1]) {
						$('#go_right').show();
					} else {
						//$('#go_right a').hide();
					}
				}
			}

			if(next_id < 0) next_id = 0;
			if(next_id > (arr['src'].length-1)) next_id = arr['src'].length - 1;

			show_big_img(arr['src'][next_id], arr['about'][next_id]);
		}
	}
	src = arr['src'][next_id];
	return src;
}

$(document).ready(function() {
	$("#go_left").disableTextSelect();
	$("#go_right").disableTextSelect();


	//set top menu background yellow and font color black on hover
    $("#center_top_img_menu > p").bind("mouseenter", function(){
		$(this).find('a').css('color', '#000');
		$(this).css('background', '#fde31c');
    }).bind("mouseleave", function(){
		$(this).find('a').css('color', '#fff');
		$(this).css('background', '#151518');
    });


    $(".cm_catalog").bind("mouseenter", function(){
		$(this).find('p').css('color', '#fb4300');
    }).bind("mouseleave", function(){
		$(this).find('p').css('color', '#000');
    });


//show big img
	var src;
	var id;
	$("#select > img").click(function(){
		//var start_pos_top = $("#select").offset().top;

		src = $(this).attr('value');
		id = $(this).attr('id');
//console.log('value - ' + id);
		$('#show').empty();

		show_big_img(src, id);
		//$('#show').append('<img src="' + src + '" alt="" />');
		
		$("#go_left").show();
		$("#go_right").show();

		var new_tallestcolumn = $('#c_main').innerHeight();
		setEqualHeight($(".equal_height"), 0, 0, new_tallestcolumn);
	})

	$("#select_admin > img").click(function(){
		var id_adm = $(this).attr('src');
		$('#show').empty();
		$('#show').append('<img src="' + id_adm + '" alt="" />');
	})
//----


//preload all images in hidden div
	var arr = new Array();
	arr['src'] = new Array();
	arr['about'] = new Array();

	$('#select img').each(function() {
		///$('#content').append('<div style="margin-left:-9999px; background:url(' + $(this).attr('id') + ') no-repeat;"></div>');
		///arr.push($(this).attr('id'));
		$('#content').append('<div style="margin-left:-9999px; background:url(' + $(this).attr('value') + ') no-repeat;"></div>');
		arr['src'].push($(this).attr('value'));
		arr['about'].push($(this).attr('id'));

	})
//----


//select next img in array (after press ->) and show it
	$("#go_left").click(function(){
		src = go(arr, src, 1);
	})

	$("#go_right").click(function(){
		src = go(arr, src, 0);
	})
//----


})

$(document).ready(function() {
	var new_tallestcolumn = $('#c_main').innerHeight();
	setEqualHeight($(".equal_height"), 0, 0, new_tallestcolumn);

	if($.browser.msie) {
		//$('#content_div').css('height', '981px');
		//$('#left_menu').css('height', '981px');
	}


});

