function product_change_qty(obj) {
    var id = jQuery(obj).attr('id');
    if (id.match("qqty")) {
	var sid = id.replace("qqty","qty");
    } else {
	var sid = "q" + id;
    }
    var val = jQuery(obj).val();
    jQuery("#" + sid).val(val);
}


function popups_fire(obj) {
        var time = 250;
        var hideDelay = 500;
	var showDelay = 1500;

        var hideDelayTimer = null;
        var showDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var distance = 10;
        var trigger = jQuery(obj);
        var id = jQuery(obj).attr('id');
        var popid = "p" + String(id);
        var info = jQuery('#'+popid);

        jQuery([trigger.get(0), info.get(0)]).mouseover(function () {
            if (showDelayTimer) clearTimeout(showDelayTimer);
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                return;
            } else {
                showDelayTimer = setTimeout(function () {
                    showDelayTimer = null;
                    beingShown = true;
                    var position = jQuery(trigger).offset();
                    info.css({
                        top: position.top,
                        left: position.left,
                        opacity:0
                    }).animate({
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }, showDelay);
            }
            return false;
        }).mouseout(function () {
            if (showDelayTimer) clearTimeout(showDelayTimer);
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    opacity:0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('left', '-10000px');
                });

            }, hideDelay);

            return false;
	});
        jQuery('.qty').change (function(){
	    product_change_qty(obj);
        });                                                            
}



jQuery(document).ready(function () {
    jQuery('.product-top1').each(function () {
        popups_fire(this);
    });

    jQuery('.qty').change (function(){
	product_change_qty(this);
    });

});

