//=====================================================//
var LoadReadyLocal = {

    newsLetterForm: function(){
        $(function() {
            Content.setupNewsletterForm();
        });
    },
    enquiryForm: function(){
        $(function() {
            Content.setupEnquiryForm();
        });
    }
};


LoadReady = $.extend(LoadReady, LoadReadyLocal);


$(function() {


    // set the border right of last item to 0 //
    $('#list li:nth-child(even)').css({'background-color': '#eff3ef'});
    $('ul.list li:nth-child(odd)').css({'background-color': '#DCDEDE'});
    //$('ul.list li:nth-child(even)').css({'background-color': '#FFF4DB'});
    $('ul.authorList li:nth-child(even)').css({'background-color': '#FFF'});
    $('table.generic tr:nth-child(even)').css({'background-color': '#f3f3f3'});
    $('#keyword').focus(function(){
        var value = $(this).val();
        if ($(this).val() == 'keyword search'){
            $(this).val("");
        }
    });

    //section image hover
    $('.hlist ul li:not(.active)').hover(function () {
        var imgHover = $('img', $(this)).attr('imghov');
        activSrc = $('img', $(this)).attr('src');
        $('img', $(this)).attr('src', '/media/section/active/'+ imgHover)
        $(this).addClass('active');
    },function () {
        $('img', $(this)).attr('src', activSrc);
        $(this).removeClass('active');

    });

    $('.showComments').livequery('click', function(e){
        e.preventDefault();
        Util.showProgressInd();
        var rec_id = $(this).attr('id');
        var url    = '/index.php?_room=comment&_spAction=list&record_id=' + rec_id + '&showHTML=0';
        var link   = $(this);

        $.get(url, function(data){
            var parent = $(link).closest('.commentHltBox');
            var commentsBox = $('.commentsList', parent);
            $(commentsBox).html(data);
            $(commentsBox).slideToggle();
            Util.hideProgressInd();
        });
    });

    $('.addComment').livequery('click', function(e){
        e.preventDefault();
        link = $(this);

		Util.showProgressInd();
		var parent = $(link).closest('.commentHltBox');
		var commentsBox = $('.commentsList', parent);
		if($(commentsBox).css('display') == 'none'){
		    $('a.showComments', parent).click();
		}
		Comments.showCommentsForm.call(link);
    });

    $('#imageContainer img').each(function(i){
        var imgUrl = $(this).attr('src');
        imgUrl = imgUrl.replace(/normal\//, "large/");
        $(this).parent().attr('href', imgUrl);
    });

    //add zoom function
    var options = {
        zoomWidth: 150,
        zoomHeight: 150,
        xOffset: 30,
        yOffset: 0,
        position: 'right',
        title: false
    };
    //$('#imageContainer a.zoomImage').jqzoom(options);

});


