$(function(){
    bind_samsing();
    $(window).bind("resize", function() {
        bind_samsing();
    });
});

(function($) {
    $.fn.yurta = function(opts) {
        $this = this;
        defaults = {
            left    : false,
            right   : false,
            top     : false,
            bottom  : false,
            width   : '150px',
            height  : '150px',
            container   : 'txt-container',
            items   : []
        };
        opts = $.extend({}, defaults, opts);
        
        if(!opts.top && !opts.bottom) {
            opts.top = 0 + "px";
        } if(!opts.left && !opts.right) {
            opts.left = 0 + "px";
        }
        
        if(opts.left !== false) {
            $this.css('left', opts.left);
        } else {
            $this.css('right', opts.right);
        }
        
        if(opts.top !== false) {
            $this.css('top', opts.top);
        } else {
            $this.css('bottom', opts.bottom);
        }
        
        $this.css({
            'width'     : opts.width,
            'height'    : opts.height,
            'position'  : 'absolute'
        });
        
        txtleft = parseFloat(opts.left.split('%').shift()) < 80 ? opts.left : '75%';
        
        $(opts.container).css('left', txtleft);
        $this.hover(function() {
            $(opts.container).show('slow');
        }, function() {
            $(opts.container).hide('slow');
        });
    }
})(jQuery);

function bind_samsing() {
    var imgHeight = $(window).width() * 1500 / 3000;
    var y1Bottom = Math.round((imgHeight * 322 / 1500));
    var y1Height = Math.round((imgHeight * 242 / 1500));
    var y2Bottom = Math.round((imgHeight * 350 / 1500));
    var y2Height = Math.round((imgHeight * 200 / 1500));
    var y3Bottom = Math.round((imgHeight * 390 / 1500));
    var y3Height = Math.round((imgHeight * 150 / 1500));
    var y4Bottom = Math.round((imgHeight * 406 / 1500));
    var y4Height = Math.round((imgHeight * 130 / 1500));
    var y5Bottom = Math.round((imgHeight * 432 / 1500));
    var y5Height = Math.round((imgHeight * 110 / 1500));
    $('#yurta-1').yurta({
        left: '15.2%',
        bottom: y1Bottom + "px",
        width: '4%',
        height: y1Height + "px",
        container: '#yurta-1-container'
    });
    $('#yurta-2').yurta({
        left: '40.47%',
        bottom: y2Bottom + "px",
        width: '3.6%',
        height: y2Height + "px",
        container: '#yurta-2-container'
    });
    $('#yurta-3').yurta({
        left: '58.93%',
        bottom: y3Bottom + "px",
        width: '2.9%',
        height: y3Height + "px",
        container: '#yurta-3-container'
    });
    $('#yurta-4').yurta({
        left: '73.27%',
        bottom: y4Bottom + "px",
        width: '2.5%',
        height: y4Height + "px",
        container: '#yurta-4-container'
    });
    $('#yurta-5').yurta({
        left: '84.57%',
        bottom: y5Bottom + "px",
        width: '2.3%',
        height: y5Height + "px",
        container: '#yurta-5-container'
    });
}
