	/*
	* File: galleries_details.js
	* Custom logic for the page: user gallery
	*/
	
	include("http://maps.google.com/maps/api/js?sensor=false");

	$(document).ready(function () {

		var slides = $(".rotator_thumb_nosize");
		var slidesLength = slides.length;

		$("#rotatorArrLeft").mouseover(function () { $(this).addClass("rotator_arr_left_over"); });
		$("#rotatorArrLeft").mouseout(function () { $(this).removeClass("rotator_arr_left_over"); });
		$("#rotatorArrRight").mouseover(function () { $(this).addClass("rotator_arr_right_over"); });
		$("#rotatorArrRight").mouseout(function () { $(this).removeClass("rotator_arr_right_over"); });

		$(".rotator_thumb_nosize").mouseover(function () {
			$(this).addClass("rotator_thumb_over");
			$(this).find(".rotator_thumb_info_nosize").show();
		});

		$(".rotator_thumb_nosize").mouseout(function () {
			$(this).removeClass("rotator_thumb_over");
			$(this).find(".rotator_thumb_info_nosize").hide();
		});

		$(".rotator_thumb_nosize").click(function () {
			$(".rotator_thumb_nosize").removeClass("rotator_thumb_active");
			$(this).addClass("rotator_thumb_active");

		});

		$("#rotatorArrRight").click(function () {
			$(".rotator_thumb_nosize:first").appendTo(".rotator_thumbs");
		});

		$("#rotatorArrLeft").click(function () {
			$(".rotator_thumb_nosize:last").prependTo(".rotator_thumbs");
		});



		// tabs
		$("#galleriesTabs a").click(function () {
			var tabID = $(this).attr("id");
			$("#galleriesTabs a").removeClass("on");
			$(this).addClass("on");

			$("#galleriesTabsContent").find(".tab_content").hide();
			$("#" + tabID + "Content").show();
		});

		// submit comment
		$("#btnSubmitComment").click(function () {
			var html = "";
			var photoID = $("#photo_id").val();
			var userID = $("#user_id").val();
			var comment = $("#c_comments").val();

			var now = new Date();

			if (comment == "")
			{
				alert ("Please enter your comment");
				return false;
			}

			$.post("/ajax/photo_comments",
				{
					photo_id: photoID,
					user_id: userID,
					comment: comment
				},
	  		function(data)
	  		{
	    		if (data == "SUCCESS")
	    		{
						$("#be_the_first").hide();

						html += '<div class="ar_item">';
						html += '	<div class="ar_image"><a href="/user/' + username + '"><img src="' + user_photo + '" width="56" alt="' + full_name + '" title="' + full_name + '" /></a></div>';
						html += '	<div class="ar_body">';
						html += '		<div class="ar_date">' + dateFormat(now, "mmm d, yyyy, h:MM TT") + '</div>';
						html += '		<div class="ar_desc">';
						html += '			<a href="/user/' + username + '">' + full_name + '</a> wrote:';
						html += '			<div class="c" style="height: 5px;"></div>';
						html += '			<div style="padding-left: 20px;">';
						html += 				comment.replace(/\n/g,"<br />");
						html += '			</div>';
						html += '		</div>';
						html += '	</div>';
						html += '	<div class="c"></div>';
						html += '</div>';
						html += '<div class="c"></div>';
						html += '<div class="a_item_delim"></div>';

						$("#photo_comments").prepend(html);
						$("#c_comments").val("");
	    		}
	    		else
	    		{
						//error
						alert ("Error while inserting comment. Please, try again later.");
	    		}
	  		},
	  		"text"
	  	);
		});

	});
	
	
	var GM_map;
	var GM_marker;
	
	function GM_nitialize(coordinates)
	{
	  var LatLng = new google.maps.LatLng(0,0);
	  var myOptions = {
	    zoom: 1,
	    center: LatLng,
	    mapTypeId: google.maps.MapTypeId.ROADMAP
	  }
	  GM_map = new google.maps.Map(document.getElementById("GM_div"), myOptions);
	  
	  LatLng = coordinates.split(",");
	  LatLng = new google.maps.LatLng(LatLng[0],LatLng[1]);
		GM_marker = new google.maps.Marker({
			map: GM_map,
			position: LatLng
		});
	}//GM_nitialize