﻿
    var txtSearch = document.getElementById('txtSearch');


    function SetMenuVisible(name, visible, dbg)
    {
        for(var i=0;i<menuCount;i++)
        {
            var id = 'mnu' + i;
            document.getElementById(id).style.display = (id == name && visible) ? 'block' : 'none';            
        }
    }
    

    function txtSearch_OnKeyDown(element, event)
    {
        var k = event.keyCode ? event.keyCode : event.charCode ? event.charCode : event.which;
        if (k == 13)
        {
            getProductSearchResult();
            return false;
        }
        return true;
    }


    function getProductSearchResult()
    {
        var txt = document.getElementById('txtSearch').value;
        var url = baseURL + '/album/gifts_selection.aspx?searchText=' + txt;

        location.href = url;
    }


    function EmpyCart()
    {
        msgBoxdisplay.Show(SR.EmptyCart, SR.AreYouSureEmptyCart,
		    [{ Button: 'Cancel' },
		      { Button: 'OK',
		          Callback: function()
		          {
		              if (typeof (shoppingCart) == 'undefined' || !shoppingCart)
		              {
		                  //used on non-cart pages
		                  var cartService = new ICartService();
		                  cartService.EmptyCart(ShowCartItemCount);
		              }
		              else
		              {
		                  //this is used on the actual cart page
		                  shoppingCart.emptyCart();
		              }
		          }
		      }
		    ]);
    }

   
    function ShowCartItemCount(val)
    {
        if (val)
        {
            //used on actual cart page.  otherwise get val from webservice
            ShowCartItemCountComplete(val);
            return;
        }

        var svc = new IAlbumService();
        svc.ItemsInTheCart(ShowCartItemCountComplete);
    }


    function ShowCartItemCountComplete(val)
    {
        var txt = (val == 1) ? SR.Item : SR.Items;
        
        elm = document.getElementById('itemCount');
        
        if (elm) elm.innerHTML = val + ' ' + txt;
    }



    //bug fix for MS ajax javascript
Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { 
    if (!this._upperAbbrMonths) { 
        this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
    }
    return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
 };