$(function(){
    $('.pageNo').change(function (e) {
        e.preventDefault();
        var pageNo = $(this).val();
        url = $(this).attr('url');
        qstr = $(this).attr('qstr');
        newUrl = url + "Page-" + pageNo + '/?' + qstr;
        document.location = newUrl;
    })
});
//=====================================================//
var LoadReadyLocal = {

    newsLetterForm: function(){
        $(function() {
            Content.setupNewsletterForm();
        });
    },

    register: function(){
        $(function() {
            var options = {
                success: function(json, statusText, jqFormObj) {
                    Validate.validateFormData(json, statusText, jqFormObj);
                    Util.hideProgressInd();
                },
                beforeSubmit: function() {
                    Util.showProgressInd();
                },
                dataType: 'json'
            };
            $('#registerForm').ajaxForm(options);
        });
    },
    
    editProfile: function(){
        $(function() {
            var options = {
                success: function(json, statusText, jqFormObj) {
                    Validate.validateFormData(json, statusText, jqFormObj);
                    Util.hideProgressInd();
                },
                beforeSubmit: function() {
                    Util.showProgressInd();
                },
                dataType: 'json'
            };
            $('#editProfileForm').ajaxForm(options);
		});
    }
};

LoadReady = $.extend(LoadReady, LoadReadyLocal);


$(function() {
    $('#footer a.links').click(function(e){
        e.preventDefault();
        Util.openDialogForLink.call(this, '', 600, 400);
    });
    
    $(window).load(function(){
        $('.centered').cp_center();
    });

    $('.btnAddToAlbum').livequery('click', function (e) {
        e.preventDefault();

        var keyField = $(this).attr('keyField');
        var record_id = $(this).attr('record_id');
        var record_type = $(this).attr('record_type');

        url = '/index.php?_room=product&_spAction=addToWishList&showHTML=0';
        Util.showProgressInd();
        $.get(url, {keyField: keyField, record_id: record_id, record_type: record_type}, function (data){
            $('div#' + record_id).html(data);
            Util.hideProgressInd();
        });
    });

    $('.btnRemoveFromAlbum').livequery('click', function (e) {
        e.preventDefault();

        var keyField = $(this).attr('keyField');
        var record_id = $(this).attr('record_id');

        url = '/index.php?_room=product&_spAction=RemoveFromWishList&showHTML=0';
        Util.showProgressInd();
        $.get(url, {keyField: keyField, record_id: record_id}, function (data){
            $('div#' + record_id).html(data);
            Util.hideProgressInd();
        });
    });

    $('.btnEnquiry').livequery('click', function (e) {
        e.preventDefault();
        Dialog.setUpForm('enquiryForm');
        Dialog.openDialog.call(this, 'enquiryForm', 'Inquiry');
    })
    

});


