$(document).ready(function (){
	$(".fz").fancyZoom({directory:'/i/zoom',scaleImg: true,closeOnClick: true});
	
	$(".place-to-order").click(function(){
		var act;
		if ($(this).attr("checked") == true){
			act = 'add';
		}else{
			act = 'del';
		}
		$.post("/address/order/add/", { action: act, place_code: $(this).attr("name") } );		
	});
/**/	
	$(".period-start").keyup(function(){
		var name = $(this).attr("name").substr(6);
		$.post("/address/order/add/", { action: 'add', place_code: name, place_start: $(this).val() });		
	});		

	$(".period-end").keyup(function(){
		var name = $(this).attr("name").substr(6);
		$.post("/address/order/add/", { action: 'add', place_code: name, place_end: $(this).val() });		
	});	
	/*
	$(".form-item").keyup(function(){
		$.post("/address/order/add/", {action: 'save', name: $(this).attr("name"), value:$(this).val()});
	});
	*/
	$(".place-from-order").change(function(){
		if (confirm("Удалить текущую позицию из заказа?") == true){
			if ($(this).attr("checked") == false){
				$.post("/address/order/add/", { action: 'del', place_code: $(this).attr("name") } );
				$(this).parent().parent().remove();
			}		
		}else{
			$(this).attr("checked", true);
		}
	});
	$("area").jqBubble();
	$("#animarea").scrollTo("#floor_1", {duration:'10', axis:'y'});
	$(".menu-list #1").addClass("active");
	
	$(".floor_link").click(function(){
		$('.menu-list .active').removeClass("active");
		
		$(this).addClass("active");		
			$("#animarea").scrollTo($("#floor_"+$(this).attr('id')), {easing:'easeOutSine', duration:1000, axis:'y'});
			$("#floor-number").html($(this).attr('id'));
			return false;
	});
/**/	
	var photo_cnt = $('.photo-area .photo-container').length;
	var photo_current = 0;
	$(".photo-nav a").click(function(){
		var btn = $(this).attr('id');
		
		if (btn == 'scroll-right'){
			if (photo_current < photo_cnt-5){
				photo_current++;
			}
		}
		
		if (btn == 'scroll-left'){
			if (photo_current > 0){
				photo_current--;
			}
		}
		var cr = $('.photo-container').get(photo_current);
		$('.photo-area').scrollTo (cr, {duration:1000, axis:'x'});
		
		return false;
	});
});

function print_r( array, return_val ) {
    // Prints out or returns information about the specified variable  
    // 
    // version: 810.114
    // discuss at: http://phpjs.org/functions/print_r
    // +   original by: Michael White (http://getsprink.com)
    // +   improved by: Ben Bryan
    // *     example 1: print_r(1, true);
    // *     returns 1: 1
    
    var output = "", pad_char = " ", pad_val = 4;

    var formatArray = function (obj, cur_depth, pad_val, pad_char) {
        if (cur_depth > 0) {
            cur_depth++;
        }

        var base_pad = repeat_char(pad_val*cur_depth, pad_char);
        var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char);
        var str = "";

        if (obj instanceof Array || obj instanceof Object) {
            str += "Array\n" + base_pad + "(\n";
            for (var key in obj) {
                if (obj[key] instanceof Array) {
                    str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char);
                } else {
                    str += thick_pad + "["+key+"] => " + obj[key] + "\n";
                }
            }
            str += base_pad + ")\n";
        } else if(obj == null || obj == undefined) {
            str = '';
        } else {
            str = obj.toString();
        }

        return str;
    };

    var repeat_char = function (len, pad_char) {
        var str = "";
        for(var i=0; i < len; i++) { 
            str += pad_char; 
        };
        return str;
    };
    output = formatArray(array, 0, pad_val, pad_char);

    if (return_val !== true) {
        document.write("<pre>" + output + "</pre>");
        return true;
    } else {
        return output;
    }
}