﻿var pageCountTotal = 1;
var pageCount = 1;
var numItems = 16;
var api;

function GalleryInit(nItems) {
}
/*
        //alert("GALLERY INIT " + nItems);

        numItems = nItems;
        
        var numRows = Math.floor(numItems / 4);
        var height = 176 * numRows + 15;
        $("div.scrollable").css("height", height + "px");
        $("div.scrollable div.items div").css("height", height + "px");
        $('div.scrollable div.items').css('width', '20000em');
        $('#viewAllButton, #mostRecentButton').css('display', 'block');
		$('#viewAllButton_, #mostRecentButton_').css('visibility', 'visible');
        //$('#prevBottom').css('background-position', '0px -34px'); 
    };


    /*$(document).ready(function() {



        setupScroller();

        $("#viewAllButton,#viewAllButton_").removeClass("button_");
        $("#viewAllButton,#viewAllButton_").addClass("button");
        $("#mostRecentButton,#mostRecentButton_").removeClass("button");
        $("#mostRecentButton,#mostRecentButton_").addClass("button_");

        api = $("div.scrollable").scrollable({ api: true, size: 1, next: ".next", prev: ".prev" });


        $("#nextBottom").click(function() {
            api.onSeek(function() {
                if (parseInt(this.getPageIndex() + 1) == parseInt(pageCountTotal)) { $('#nextBottom').css('background-position', '1px -34px'); } else { $('#nextBottom').css('background-position', '1px 0px'); };

            });
            api.next();

        })
        $("#prevBottom").click(function() {
            api.onSeek(function() {
                if (parseInt(this.getPageIndex() + 1) == 1) { $('#prevBottom').css('background-position', '1px -34px'); } else { $('#prevBottom').css('background-position', '1px 0px'); };
                if (parseInt(this.getPageIndex() + 1) == parseInt(pageCountTotal)) { $('#nextBottom').css('background-position', '1px -34px'); } else { $('#nextBottom').css('background-position', '1px 0px'); };
            });
            api.prev();
        })


        $("div.navi a").each(function(i) {
            $(this).html("" + (i + 1));
            //$(this).after("<span class='seperator' style='float:left'>|</span>");
            pageCountTotal = i + 1;
        });

        $('#pageCount,#pageCount_').html(pageCount + " / " + pageCountTotal);

		
        pageit(0, 10);
		$('#prevBottom').css('background-position', '1px -34px'); 
		
        if (pageCountTotal == 1) { $('.next,.prev,div.navi a').css('visibility', 'hidden'); }


        $("div.navi span:last").remove();

        $.nyroModalSettings({ galleryCounts: '' });

        $(".navi a").click(function() {
            $('#pageCount,#pageCount_').html($(this).html() + " / " + pageCountTotal)
            //alert($(this).html());
        });

        /*$(".next").click(function() {
        if (pageCountTotal != 1) {
        pageCount += 1;
        $('#pageCount').html(pageCount + " / " + pageCountTotal);
        }

        });
        $(".prev").click(function() {
        pageCount -= 1;
        $('#pageCount').html(pageCount + " / " + pageCountTotal);

        });


        //update controls when index is changeds
        if (api) {
            api.onSeek(function() {
                pageCount = api.getIndex() + 1;
                $('#pageCount,#pageCount_').html(pageCount + " / " + pageCountTotal);
                if ((pageCount > 1) && (pageCount < pageCountTotal)) {
                 //   pageit(pageCount -2, pageCount + 8);
				 pageit(Math.min(pageCount-2, pageCountTotal-8), Math.min(pageCount+8, pageCountTotal));
               // } else {
					
					
				}
				
                if (pageCount > 0) {$('#prevBottom').css('background-position', '1px 0px'); } else { $('#prevBottom').css('background-position', '1px -34px'); }
				
				if (pageCount == pageCountTotal){$('#nextBottom').css('background-position', '1px -34px');}else{
					$('#nextBottom').css('background-position', '1px 0px');
					}
            });
        };

        function pageit(j, k) {
            //if ($('.navi a').size() > 10 - 2) {
                $('.navi a').each(function(i) {
                    if (((i > k - 1)) || ((i <= j - 1))) {
                        $(this).css('display', 'none');
                    } else {
                        $(this).css('display', 'block');
                    }

                });
            //}
        }*/


        /*$("#viewAllButton,#viewAllButton_").click(function(event) {

            event.preventDefault();
            api.getConf().speed = 0;
            api.setPage(0);
            api.getConf().speed = 400;

            //var index = $('#uploadChoice div').index(this);
            $("div.scrollable").css("overflow", "visible");
            $("div.scrollable").css("height", "auto");

			$("div.scrollable div.items").css("float", "left");
            $("div.scrollable div.items").css("position", "relative");
            $("div.scrollable div.items div").css("height", "auto");
            $("div.scrollable div.items div").css("clear", "both");
            
			$(".prev, .next,div.navi a").css("visibility", "hidden");
            
			$("#viewAllButton,#viewAllButton_").addClass("button_");
            $("#viewAllButton,#viewAllButton_").removeClass("button");
            
			$("#mostRecentButton,#mostRecentButton_").removeClass("button_");
            $("#mostRecentButton,#mostRecentButton_").addClass("button");
            
			$('.next,.prev,div.navi').css('visibility', 'hidden');
            $('div.scrollable div.items').css('width', 'auto');
            $("#pageCount").css('display', 'none');


            return false;

        });

        $("#mostRecentButton,#mostRecentButton_").click(function(event) {
            api.getConf().speed = 0;
            api.setPage(0);
            api.getConf().speed = 400;
            event.preventDefault();


            setupScroller();
            
			$("#viewAllButton,#viewAllButton_").addClass("button");
            $("#viewAllButton,#viewAllButton_").removeClass("button_");
            
			$("#mostRecentButton,#mostRecentButton_").removeClass("button");
            $("#mostRecentButton,#mostRecentButton_").addClass("button_");
			
			$('#prevBottom').css('background-position', '1px -34px'); 
			
             $('.next,.prev,div.navi a').css('visibility', 'visible'); 
			
            $('div.scrollable div.items').css('width', '20000em');
            $('div.navi').css('visibility', 'hidden');
            $("#pageCount").css('display', 'inline');
            return false;
        }
		);


        function setupScroller() {

            var numRows = Math.floor(numItems / 4);
            var height = 176 * numRows + 15;

            $("div.scrollable").css("overflow", "hidden");
            $("div.scrollable").css("height", height + "px");

            $("div.scrollable div.items").css("position", "absolute");
            $("div.scrollable div.items").css("width", "20000em");

            $("div.scrollable div.items div").css("height", height + "px");
            $("div.scrollable div.items div").css("clear", "none");

            $("a.prev, a.next, a.prevPage, a.nextPage").css("display", "block");

        }*/

$(document).ready(function() {


    $('#PagingDiv').css("display", "block")

    $(function() {
        $('.nyroText,.nyroText_,.goldFrameText').click(function(e) {
            e.preventDefault();
            var title = $(this).attr('title');
            var content = '<span class="textOnly">Text: ' + $(this).attr('rev') + '</span>';

            $.nyroModalManual({
                content: content,
                title: title,
                width: 850,
                height: 490
            });
            return false;
        });
        $('.nyroImageText,.goldFrameImageText').click(function(e) {
            e.preventDefault();


            //if (ie6) {
            

            //}

            // if (ie6) {
            //    title = $(this).attr('title') + '<br/>' + $(this).attr('rev');
            //} //else {
            title = '<span><span>Text: ' + $(this).attr('rev') + '</span></span>' + $(this).attr('title') + "";
            //}
            var url = $(this).attr('href');

            $.nyroModalManual({
                title: title,
                type: 'image',
                url: url
            });
            return false;
        });
        $('.nyroImage,.goldFrameImage').click(function(e) {
            e.preventDefault();

            var url = $(this).attr('href');

            var title;

            title = '<span><span>Text: None</span></span>' + $(this).attr('title') + "";


            $.nyroModalManual({
                title: title,
                type: 'image',
                url: url
            });
            return false;
        });


    });


    $('.nyroText,.nyroText_,.goldFrameText,.nyroImageText,.goldFrameImageText,.nyroImage,.goldFrameImage').click(function(e) {

        if ($(this).parent().find('.galleryStarClick').length > 0) {
            $('h1#nyroModalTitle').css('background', 'url(../images/gallery_star.jpg) !important');
        }
        else {
            $('h1#nyroModalTitle').css('background', 'none !important');
        }
    });


});
    