$(function() {
	$("a.gall").lightBox({fixedNavigation:true});
	$("a[rel=gall]").lightBox({fixedNavigation:true});
});

function add_to_cart(id){
	$.post ("/forms/cart.php", {id: id}, function(msg){
		$("#change").html(msg);
		$('#add_to_cart_'+id).show("slow");
		$('#cart_items').html(msg);
		setTimeout(function () { $('#add_to_cart_'+id).hide("fast"); }, 3000);
	});
}

function add_to_cart_new(id){
	$.post ("/forms/cart.php", {id: id}, function(msg){
		$("#change").html(msg);
		$('#add_to_cart_new'+id).show("slow");
		setTimeout(function () { $('#add_to_cart_new'+id).hide("fast"); }, 3000);
	});
}

function order_cart(){
	$("#cart_loading").show();
	$('#cart_form').load('/forms/cart.php', function () {
		$("#cart_loading").hide();
	});
	show_cart();
	return false;
}

function show_cart(){
	formTop = $(document).scrollTop()+150;
	$('#cart_form_wrap').css('top', formTop+'px').show();
	$('#overlay').show();
}

jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++){
		jQuery("<img>").attr("src", arguments[i]);
	}
};
$.preloadImages("/bitrix/templates/fomedia_index/images/pop_up_top_bg.gif", "/bitrix/templates/fomedia_index/images/pop_up_bottom_bg.gif", "/bitrix/templates/fomedia_index/images/button_close.gif", "/bitrix/templates/fomedia_index/images/button.gif");

function hide_popup(){
	$('.pop_up').hide();
    $('#overlay').hide();
}

function show_faq_cur(obj){
	$(obj).parent().parent().parent().css('display', 'none');
	$(obj).parent().parent().parent().parent().find('.faq_cur').css('display', 'block');
}
function show_faq(obj){
	$(obj).parent().parent().css('display', 'none');
	$(obj).parent().parent().parent().find('.faq_first').addClass('faq_visited');
	$(obj).parent().parent().parent().find('.faq_first').css('display', 'block');
}
