﻿
    $(document).ready(function(){
        function findPos(obj) {
            var curtop = 0;
            if (obj.offsetParent) {
                do {
                    curtop += obj.offsetTop;
                } while (obj = obj.offsetParent);
                return curtop;
            }
        };
        
        $('a.see-more').click (function() {
            var show = $(this).find("span.show");
            var hide = $(this).find("span.hide");
            var TglCnt = $(this).parent().parent().find("div.more-content");
            var rounded = $(this);
            var oftop = findPos(this);
            
            if (rounded.hasClass('rounded')){
                TglCnt.slideUp(900,function(){
                    hide.removeClass('hide').addClass('show');
                    rounded.removeClass('rounded');
                    rounded.children('b').replaceWith('<b>see sample shipment<\/b>');
                    //$('html, body').animate({scrollTop:oftop - 0}, 1000);
                });
            } else {
                TglCnt.slideDown(1400);
                show.removeClass('show').addClass('hide');
                rounded.addClass('rounded');
                rounded.children('b').replaceWith('<b>hide sample shipment<\/b>');
                //$('html, body').animate({scrollTop:oftop}, 800);
            };
        });
        
        $('a.see-holiday').click (function() {
            var show = $(this).find("span.show");
            var hide = $(this).find("span.hide");
            var TglCnt = $(this).parent().parent().find("div.more-holiday");
            var rounded = $(this);
            var oftop = findPos(this);
            
            if (rounded.hasClass('rounded-wider-tab')){
                TglCnt.slideUp(900,function(){
                    hide.removeClass('hide').addClass('show');
                    rounded.removeClass('rounded-wider-tab');
                    if ($('#ctl00_ucHeader_divHOG').hasClass('hog-home')){
                        rounded.children('b').replaceWith('<b>see our holiday ordering guidelines<\/b>');
                    } else {
                        rounded.children('b').replaceWith('<b>see holiday ordering guidelines<\/b>');
                    }
                    //$('html, body').animate({scrollTop:oftop - 0}, 1000);
                });
            } else {
                TglCnt.slideDown(1400);
                show.removeClass('show').addClass('hide');
                rounded.addClass('rounded-wider-tab');
                if ($('#ctl00_ucHeader_divHOG').hasClass('hog-home')){
                    rounded.children('b').replaceWith('<b>hide our holiday ordering guidelines<\/b>');
                } else {
                    rounded.children('b').replaceWith('<b>hide holiday ordering guidelines<\/b>');
                }
                //$('html, body').animate({scrollTop:oftop}, 800);
            };
        });
        
        $('div.what a').click (function() {
            var show = $(this).find("span.show");
            var hide = $(this).find("span.hide");
            var rounded = $(this);
            var TglCnt = $("div.more-content")
            
            if (rounded.hasClass('rounded')){
                TglCnt.slideUp(600,function(){
                    rounded.removeClass('rounded');
                    hide.removeClass('hide').addClass('show');
                });
            } else {
                rounded.addClass('rounded');
                show.removeClass('show').addClass('hide');
                TglCnt.slideDown(600);
            };
        });
    });