﻿$(document).ready(function() {

    var MCfirstInQueue;
    var MClastInQueue;
    var MCcurrentPage = 1;
    var collectionCount = $('.MyCollectionsCollectionHolder').size();
    /*
    $('.btnLoadMore').hide();
    $('.MyCollectionsCollectionHolder').hide();
    $('#MCtotalPagesInt').text(collectionCount);
    
    if (MCcurrentPage == 1) {
    $('#MCcurrentPageInt').text('1');

    $('#MCcurrentPageIntPlus4').text('4');
    //$('#previouPage').hide();
    var MCi = 1;
    while (MCi < 5) {

    $("#myCollectionItem" + MCi).show();
    MCi++;
    }
    }
    $(".MCNextGallery").click(function () {
        
    $(".MyCollectionsCollectionHolder").animate({ opacity: "0" });
    MCfirstInQueue = (MCcurrentPage * 4) + 1;
    MClastInQueue = MCfirstInQueue + 4;
    $('#MCcurrentPageIntPlus4').text(MCfirstInQueue);
    if (MClastInQueue > collectionCount || MClastInQueue == collectionCount) {
    //$('#nextGrey').show();
    //$('#nextPage').hide();
    while (MClastInQueue > collectionCount) {

    MClastInQueue--;
    }

    }

    $('#MCcurrentPageInt').text(MCfirstInQueue);

    MCcurrentPage++;

    $('#MCcurrentPageIntPlus4').text(MClastInQueue);
    for (MCd = 0; MCd <= collectionCount; MCd++) {
    $("#myCollectionItem" + MCd).hide();
    }
    //$("#productInList" + firstInQueue).show();
    $("#myCollectionItem" + (MCfirstInQueue + 1)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 2)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 3)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 4)).show();

    //$('#previouPage').show();
    //$('#lastgrey').hide();
    $(".MyCollectionsCollectionHolder").animate({ opacity: "1" });
    if ($('#MCcurrentPageIntPlus4').text() == collectionCount.toString()) {
    $('.MCNextGallery').hide();
            
    if (loadMethod == 1) {
    $('.MCNextGallery').hide();
    $('.btnLoadMore').show();
    }
    else {
    $('#MCImg2').show();
    }
    } else {
    $('.MCNextGallery').show();
    $('#MCImg2').hide();
    }
    if ($('#MCcurrentPageInt').text() == '1') {
    $('.MCPreviousPage').hide();
    $('#MCImg1').show();

    } else {
    $('.MCPreviousPage').show();
    $('#MCImg1').hide();
    }
    });
    $(".MCPreviousPage").click(function () {
    $(".MyCollectionsCollectionHolder").animate({ opacity: "0" });
    MCcurrentPage--;
    if (MCcurrentPage == 1 || MCcurrentPage < 1) {
    for (MCdT = 0; MCdT <= collectionCount; MCdT++) {
    $("#collectionCount" + MCdT).hide();
    }
    $('#MCcurrentPageInt').text('1');
    $('#MCcurrentPageIntPlus4').text('4');
    $('.MCNextGallery').attr('disabled', 'disabled');
    //$('#previouPage').hide();
    // $('#lastgrey').show();
    //$('#nextGrey').hide();
    //$('#nextPage').show();
    var MCiT = 1;
    while (MCiT < 5) {

    $("#myCollectionItem" + MCiT).show();
    MCiT++;
    }
    } else {
    //alert(MCcurrentPage);

    MCcurrentPage = MCcurrentPage - 1;
    MCfirstInQueue = (MCcurrentPage * 4) + 1;
    MClastInQueue = MCfirstInQueue + 4;

    if (MClastInQueue > collectionCount || MClastInQueue == collectionCount) {


    while (MClastInQueue > collectionCount) {
    MClastInQueue--;
    }
    }
    $(".MyCollectionsCollectionHolder").hide();

    $('#MCcurrentPageInt').text(MCfirstInQueue);


    $('#MCcurrentPageIntPlus4').text(MClastInQueue);
    for (MCdT = 0; MCdT < collectionCount; MCdT++) {
    $("#myCollectionItem" + MCdT).hide();
    }
    // $("#PictureID" + firstInQueue).show();
    $("#myCollectionItem" + (MCfirstInQueue + 1)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 2)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 3)).show();
    $("#myCollectionItem" + (MCfirstInQueue + 4)).show();

    }
    $(".MyCollectionsCollectionHolder").animate({ opacity: "1" });
    if ($('#MCcurrentPageIntPlus4').text() == collectionCount.toString()) {
    $('.MCNextGallery').hide();
    if (loadMethod == 1) {
    $('.MCNextGallery').hide();
    $('.btnLoadMore').show();
    }
    else {
    $('#MCImg2').show();
    }
    } else {
    $('.MCNextGallery').show();
    $('#MCImg2').hide();
    }
    if ($('#MCcurrentPageInt').text() == '1') {
    $('.MCPreviousPage').hide();
    $('#MCImg1').show();
    } else {
    $('.MCPreviousPage').show();
    $('#MCImg1').hide();
    }

    });
    */

    //THIS IS THE CODE FOR THE MY COLLECTION SIDE BAR
    var commentListCount = $(".myCollectionLatest").size();
    var mycollclickCount = 0;
    var showingcomments = 5;
    if ($('.licomment').size() > 0) {
        showingcomments = 4;
        //alert("this");
    }
    if ($('.lookInSeasonList').size() > 0) {
        showingcomments = 5;
    }
    if ($('.lookDescMiddle').size() > 0) {
        showingcomments = 8;
    }
    if ($('.MyCollectionsCollectionHolder').size() > 0) {
        showingcomments = 5;
    }
    if ($('.searchresultboxforcollection').size() > 0) {
        showingcomments = 6;
    }
    // if (commentListCount > 5) {
    $(".myCollectionLatest").hide();
    $(".myCollectionLatest").closest('.licomment').hide();
    for (i = 0; i < showingcomments; i++) {
        $("#mycollectioncomment" + i).show();
        $("#mycollectioncomment" + i).closest('.licomment').show();
    }
    $('#mycolldown').click(function() {
        if (showingcomments > commentListCount) {
        } else {
            mycollclickCount++;
            $("#mycollectioncomment" + mycollclickCount).hide();
            $("#mycollectioncomment" + mycollclickCount).closest('.licomment').hide();

            $("#mycollectioncomment" + showingcomments).closest('.licomment').show();
            $("#mycollectioncomment" + showingcomments).show();
            showingcomments++;
        }
    });
    $('#mycollup').click(function() {
        if (showingcomments <= 5) {

        } else {
            $("#mycollectioncomment" + mycollclickCount.toString()).show();
            $("#mycollectioncomment" + mycollclickCount.toString()).closest('.licomment').show();
            mycollclickCount--;
            showingcomments--;
            $("#mycollectioncomment" + showingcomments.toString()).hide();
            $("#mycollectioncomment" + showingcomments.toString()).closest('.licomment').show();

        }
    });
    //}
    //this is the scroller on the products page


    var productcommentListCount = $(".comment").size();
    //alert(productcommentListCount);
    var productcollclickCount = 0;
    var productshowingcomments = 7;
    $(".comment").hide();

    if (productcommentListCount < 8) {
        $('.scrollarrowtop').hide();
        $('.scrollarrowbottom').hide();
    }
    for (i = 0; i < productshowingcomments; i++) {
        $("#productcomment" + i).show();
    }
    $('#productcommentscrolldown').click(function() {
        if (productshowingcomments > productcommentListCount) {

        } else {

            productcollclickCount++;
            $("#productcomment" + productcollclickCount.toString()).hide();

            $("#productcomment" + productshowingcomments.toString()).show();
            productshowingcomments++;
        }
    });
    $('#productcommentscrollup').click(function() {
        if (productshowingcomments <= 5) {

        } else {
            $("#productcomment" + productcollclickCount.toString()).show();
            productcollclickCount--;
            productshowingcomments--;
            $("#productcomment" + productshowingcomments.toString()).hide();

        }
    });
});
