/* --- Initialize page --- */
$(document).ready(function(){
	
	
	var $gallery = $("div#inside_pics");

	// Create extra elements & navigation links
	$gallery
		.before('<div class="cycle_arrows event_arrows" id="cntrlrs"><a href="#" id="gallery-previous" class="disabled"></a><a href="#" id="gallery-next"></a></div>')
		.wrap('<div id="gallery-wrapper"></div>')
		.wrap('<div id="gallery-innerwrapper"></div>');

	// Remove IE's alt tooltip
	// if ($.browser.msie) { $gallery.find("img").attr("title", ""); }

	
//hide the buttons
	$("#cntrlrs").hide();
	
	 $("#features").hover(
      function () {
        $("#cntrlrs").fadeIn("slow");
      }, 
      function () {
        $("#cntrlrs").fadeOut("slow");
      }
    );

	
	// Settings
	var currentimage = 0;
	var currentpage = 0;  // 6 images per page
	var imagecount = $gallery.find("li").size();

	if (imagecount<=1)
	{
		$("#gallery-next").addClass("disabled");
	}

	// Image width
	var $firstimage = $gallery.find("img:first");
	var imageWidth = 268;
	var gallerywidth = 268;
	var galleryheight = 200;
	

	// Set the strip's actual width to be safe
	$gallery.width(imageWidth * imagecount);


	// Movement links
	$("#gallery-next").click(function(){
//


//
		// Do not move on last page
		if ((currentpage+1) >= imagecount) { return false; }

		// Undisable other link
		$("#gallery-previous").fadeIn("slow");

		// Slide images
		$gallery.animate({left: -gallerywidth*++currentpage}, 1000, "swing", function(){

			// Disable link if last page
			if ((currentpage+1) >= imagecount) { $("#gallery-next").fadeOut("slow"); }

			// Click first link in group (put inside callback for smoother scrolling)
			$("#gallery-innerwrapper img").eq(currentpage).click();
		});

		return false;
	});

	$("#gallery-previous").click(function(){
//

		// Do not move on first page
		if (currentpage == 0) { return false; }

		// Undisable other link
		$("#gallery-next").fadeIn("slow");

		// Slide images
		$gallery.animate({left: -gallerywidth*--currentpage}, 1000, "swing", function(){

			// Disable link if first page
			if (currentpage == 0) { $("#gallery-previous").fadeOut("slow"); }

			// Click first link in group (put inside callback for smoother scrolling)
			$("#gallery-innerwrapper img").eq(currentpage).click();
		});

		return false;
	});





	



});
