    //=====================================================//
var LoadReadyLocal = {
    login: function(){
        $(function() {
            Dialog.setUpForm('loginForm');
            $('#btnLoginForm, #btnWishListLogin').livequery('click', function(e) {
                e.preventDefault();
                Util.openDialogForLink.call(this, Lang.data.login, 700, 400);
                //Member.loginForm.call(this, e);
            });

            Dialog.setUpForm('frmFgtPwd');
            $('#btnFgtPwd').livequery('click', function(e) {
                e.preventDefault();
                $(this).dialog('destroy');
                Util.openDialogForLink.call(this, Lang.data.forgotPassword, 500, 300);
            });

            /*var options = {
                success: function(json, statusText, jqFormObj) {
                    extraPar = {callbackOnError: function(json){
                        $('.loginErrorMessage').show();
                    }}
                    Validate.validateFormData(json, statusText, jqFormObj, extraPar);
                    Util.hideProgressInd();
                },
                beforeSubmit: function() {
                    Util.showProgressInd();
                },
                dataType: 'json'

            };
            $('#loginForm').ajaxForm(options);*/
        });
    },

    register: function(){
        $(function() {
            Util.setUpAjaxFormGeneral.call(this, 'newMemberForm');
        });
    },

    editProfile: function(){
        $(function() {
            Util.setUpAjaxFormGeneral.call(this, 'editProfileForm');
        });
    },

    changePassword: function(){
        $(function() {
            Util.setUpAjaxFormGeneral.call(this, 'changePasswordForm');
        });
    },

    downloadCatalog: function(){
        $(function() {
            Dialog.setUpForm('downloadCatalogForm');
            $('#btnDownloadCatalog').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'downloadCatalogForm', Lang.data.downloadCatalogTitle);
            });
        });
    },

    furnitureList: function(){
        $(function() {
            Dialog.setUpForm('furnitureForm');
            $('#btnFurniture').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'furnitureForm', Lang.data.furnitureListTitle);
            });
        });
    },

    newsLetter: function(){
        $(function() {
            Dialog.setUpForm('newsLetterForm');
            $('a.nltrSgnUp').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'newsLetterForm', Lang.data.newsLetterTitle);
            });
        });
    },

    emailToFriend: function(){
        $(function() {
            Dialog.setUpForm('emailToFriendForm');
            $('#btnEmailToFriend').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'emailToFriendForm', Lang.data.emailToAFriend, 485, 485);
            });
        });
    },

    submitEnquiry: function(){
        $(function() {
            $('#btnSubmitEnquiry').livequery('click', function(e) {
                Shopping.submitEnquiry.call(this, e);
            });
        });
    },

    /*submitEnquiry: function(){
        $(function() {
            $('#btnSubmitEnquiry').livequery('click', function(e) {
                e.preventDefault();
                Dialog.openDialog.call(this, 'enquiryForm', Lang.data.enquiryForm);
            });
        });
    },*/

    emailWishList: function(){
        $(function() {
            Dialog.setUpForm('emailWishListForm');
            $('#btnEmailWishList').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'emailWishListForm', Lang.data.emailWishList, 485, 510);
            });
            
            $('.proQuantity').change(function(e){
                e.preventDefault();
                var product_id = $(this).attr('id');
                var qty = $(this).val();

                var url = '/index.php?_room=member&_spAction=updateProductQuantity&showHTML=0';
                $.get(url, {product_id: product_id, qty: qty}, function (data) {

                })
                
            });
        });
    },

    askForQuote: function(){
        $(function() {
            Dialog.setUpForm('askForQuoteForm');
            $('#btnQuote').click(function(e){
                e.preventDefault();
                Dialog.openDialog.call(this, 'askForQuoteForm', Lang.data.askForQuote, 485, 525);
            });
        });
    }
};

LoadReady = $.extend(LoadReady, LoadReadyLocal);


$(function() {
    // set the border right of last item to 0 //
    $('#list li:nth-child(even)').css({'background-color': '#eff3ef'});
    $('table.generic tr:nth-child(even)').css({'background-color': '#f3f3f3'});
    $('#keyword').focus(function(){
        var value = $(this).val();
        if ($(this).val() == Lang.data.keywordSearch){
            $(this).val("");
        }
    });

    $('.c25l:nth-child(4n)').removeClass('c25l').addClass('c25r');

    $('#productImage a').click(function(e) {
         e.preventDefault();
         var media_id = $(this).attr('media_id');
         var url = '/index.php?_room=gallery&_spAction=largeImage&showHTML=0';
         $.get(url, {media_id: media_id}, function (data) {
             $('.largeImage').html(data).fadeIn('slow');
         })
    });

    $('#footer .links a').click(function(e){
        e.preventDefault();

        if ($(this).attr('id') == ''){
            Common.openFooterLinksDialog.call(this);
        } else if ($(this).attr('id') == 'disclaimer'){
            Common.openFooterLinksDialog.call(this, 600, 200);
        } else if ($(this).attr('id') == 'guarantees'){
            Common.openFooterLinksDialog.call(this, 600, 200);
        } else if ($(this).attr('id') == 'btnNewsletterSignup'){
            Dialog.openDialog.call(this, 'newsletterSignupForm', Lang.data.newsletterSignupTitle);
            Dialog.setUpForm('newsletterSignupForm');
        }
    });

    $('.btnSubmit').click(function(e){
        e.preventDefault();
        var frm = $(this).closest('form');
        $(frm).submit();
    });

    $('.btnCancel').click(function(e){
        e.preventDefault();
        window.history.back();
    });

    $('.btnBack').click(function(e){
        e.preventDefault();
        window.history.back();
    });

    $('.btnPrint').click(function(e){
        e.preventDefault();
        window.print();
    });

    $('ul.menu li, ul.menu li li').click(function(e){
        e.stopPropagation();

        var liObj   = $(this);
        var curId   = liObj.attr('id');
        var parent  = $(this).closest('ul');
        var subMenu = $('>ul', liObj);
        
        $('>li', parent).each(function(){
            var liID = $(this).attr('id');
            if (liID != curId){
                $('ul', $(this)).hide();
                $(this).addClass('closed').removeClass('opened');
            }
        });
                
        $(subMenu).slideToggle('slow', function(){
            if ($(subMenu).css('display') == 'block'){
                $(liObj).addClass('opened').removeClass('closed');
            } else {
                $(liObj).addClass('closed').removeClass('opened');
            }
        });
    });

    $('ul.menu li li a').click(function(e){
        e.stopPropagation();
    });
    
    $('.addToWishList').click(WishList.addToWishList);
    $('.btnRemoveWishList').click(WishList.removeWishList);

    $(window).load(function(){
        $('.centered').cp_center();
    });

    $(".jCarouselLite a").click(function(e){
        e.preventDefault();
        var pos = $(this).attr('href');
        $('.anythingSlider').anythingSlider(pos);
    });

    if ($('#galleryView').length > 0){
	    $('#galleryView').galleryView({
	    	panel_width: 778,
	    	panel_height: 356,
	    	frame_width: 96,
	    	frame_height: 96,
  	    	transition_speed: 350,
 	    	easing: 'easeInOutQuad',
	    	transition_interval: 0
	    });
	}

    /*$('#btnQuote').livequery('click', function(e) {
        e.preventDefault();
	    var url = $(this).attr('href');
        Util.showProgressInd();
        $.get(url, function (data) {
            Util.alert(Lang.data.quoteSuccessText);
            Util.hideProgressInd();
        })
    });*/

    $('.printBtn').livequery('click', function(e){
        e.preventDefault();
        var link = $(this).attr('href');
        var options = {
            url: link
        };

        $(this).cp_openWindow(options);
    });

    $('#frmProductSearch').submit(function(e){
        e.preventDefault();
        //alert(123);
        Util.clearPrepopulatedTextbox($(this));
        $(this).unbind('submit');
        $(this).trigger('submit');
    });

    $('div.global-wrapper a').attr('target', '_blank');

    //$('.hlist li:last a').css('padding-right', '0');

    $('.btnMap').livequery('click', function(e) {
		e.preventDefault();
        Util.openDialogForLink.call(this, '', 700, 550);
	});
});

