﻿$(document).ready(function() {
    $('#magshoppod .closed').click(
		function() {
		    var openWidth = parseInt($('#magshoppod .opened').css('width').replace('px', ''));
		    var closeWidth = parseInt($(this).css('width').replace('px', ''));
		    ToggleFlyOut($('#magshoppod .opened'), (closeWidth - openWidth) + 'px', 500);
		}
	);

    $('#magshoppod .opened').click(
		function() {
		    var closeWidth = $('#magshoppod .closed').css('width');
		    ToggleFlyOut($(this), closeWidth, 500);
		}
	);

    function ToggleFlyOut(animatedElem, endLeft, duration) {
        animatedElem.stop(true, true).animate({
            left: endLeft
        }, duration, null);
    }

    /*if (navigator.cookieEnabled) {
        var cookieVal = readCookie("popoutShown");
        var popoutShown = (cookieVal != null && cookieVal.toLowerCase() == "true");

        if (!popoutShown) {
            createCookie("popoutShown", "true", null);
            $('#magshoppod .closed').trigger('click');
        }
    }*/
});
