﻿        function doButtonClick(buttonName, e)
        {
            //the purpose of this function is to allow the enter key to 
            //point to the correct button to click.
            var key;

            if (window.event)
                //IE
                key = window.event.keyCode;     
            else
                //firefox
                key = e.which;     

            if (key == 13)
            {
                //Get the button the user wants to have clicked
                var btn = document.getElementById(buttonName);
                if (btn != null)
                { 
                    // If we find the button click it
                    btn.click();
                    event.keyCode = 0
                }
            }
        }

        function clearText(controlID) { 
            var control = document.getElementById(controlID);

            control.value = ''; 
            control.style.color = 'black'; 
        } 

        function setDefaultText(controlID, defaultText) {
            var control = document.getElementById(controlID);
             
            if (control.value == '')
            { 
                control.value = defaultText;
                control.style.color = 'gray'; 
            } 
        }     
        
        function OpenStoreCoupon(storeAlias)
        {
            var viewerURL = '../storelocator/StoreCoupon.aspx?store=' + storeAlias;
            var winLeft = (screen.width - 400) / 2; 
            var winTop = (screen.height - 300) / 2; 

            var viewerArgs = 'menubar=no,toolbar=no,location=yes,personalbar=no,status=no,scrollbars=yes,resizable=yes,modal=no';
            viewerArgs = viewerArgs + ',width=' + 400; 
            viewerArgs = viewerArgs + ',height=' + 300;
            viewerArgs = viewerArgs + ',left=' + winLeft; 
            viewerArgs = viewerArgs + ',top=' + winTop; 

	        window.open(viewerURL, '', viewerArgs);
        }

        function openAFHS(url) {
            if (window.opener && !window.opener.closed) {
                if (opener.blur) opener.focus();
                self.close();
            }
            else {
                window.location.href = url;
            }
            return false;
        }
