﻿
$(document).ready(function () {

    $('.catalog-popup-link a').mouseover(function () {
        // how big is the window?
        var w = ($(window).width() - 900) / 2;

        var y = $(this).offset().top - 310;
        var x = $(this).offset().left;
        if (x > $(window).width() / 2) x -= (400 + w);
        else x += (190 - w);
        var id = this.href.substring(this.href.lastIndexOf('/'));
        //setTimeout(function() {
        $('#preview').css({ visibility: 'visible', display: 'block', top: y + 'px', left: x + 'px', zIndex: '20000' });
        $('#preview-content').load('http://www.shoptwigs.com/Preview' + id);
        //}, 500);
    });

    $('.catalog-popup-link a').mouseout(function () {
        $('#preview').css({ visibility: 'hidden' });
        $('#preview-content').html('');
    });


    /*
    // Create scrollbars
    $('.scroller').draggable({ containment: 'parent', axis: 'y', drag: function (event, ui) {
    var loc = parseInt($(this).css('top')) / ($(this).parent().height() - $(this).height());
    var target = $('#' + this.id.substring(0, this.id.lastIndexOf('-')) + '-content');
    target.css('top', '-' + Math.round(loc * (target.outerHeight() - target.parent().innerHeight())) + 'px');
    }
    });

    $('.scroll-area').click(function (event) {
    var y = event.pageY - $(this).offset().top;
    var slider = $(this).children();
    var space = $(this).height() - slider.height();
    var pos = Math.min(space, Math.max(0, y - (slider.height() / 2)));
    slider.css('top', pos + 'px');

    var loc = pos / space;
    var target = $('#' + this.id.substring(0, this.id.lastIndexOf('-')) + '-content');
    target.css('top', '-' + Math.round(loc * (target.outerHeight() - target.parent().innerHeight())) + 'px');
    });

    $('.scroll-up').mousedown(function (event) {
    var id = $(this).parent().attr('id');
    id = id.substring(0, id.lastIndexOf('-'));
    var scroller = $('#' + id + '-scroller');
    var content = $('#' + id + '-content');
    scroller.animate({ top: '0' }, 1000);
    });

    $('.scroll-dn').mousedown(function (event) {

    });
    */
});
/*
function resizeMenu()
{
    var high = $('#layout-stretch').height();
    if (high != null && high > 570)
    {
        $('#layout-left').height(high);
    }
}
*/
function addCartHide()
{
    document.getElementById('addtocart').style.display = 'none';
}
