document.observe('dom:loaded', function(){
	if ($('photo_list')) {
		galleryCounter = $('photo_list_elements').immediateDescendants().length;
		startCounter = 1;
		if (galleryCounter == 1) {
			$('photo_left').className = 'photo_left disabled';
			$('photo_right').className = 'photo_right disabled';
		} else {
			$('photo_left').observe('click', function(){
				if (startCounter != 1) {
					startCounter--;
					new Effect.Move('photo_list_scroll', {x: -208*(startCounter-1), mode: 'absolute', duration: 0.5});
					$('photo_list_num').innerHTML = startCounter+' / '+galleryCounter;
				};
				if (startCounter != 1) {
					$('photo_right').className = 'photo_right';
				} else {
					$('photo_right').className = 'photo_right';
					$('photo_left').className = 'photo_left left_disabled';
				};
			});
			$('photo_right').observe('click', function(){
				if (startCounter != galleryCounter) {
					startCounter++;
					new Effect.Move('photo_list_scroll', {x: -208*(startCounter-1), mode: 'absolute', duration: 0.5});
					$('photo_list_num').innerHTML = startCounter+' / '+galleryCounter;
				};
				if (startCounter != galleryCounter) {
					$('photo_left').className = 'photo_left';
				} else {
					$('photo_left').className = 'photo_left';
					$('photo_right').className = 'photo_right right_disabled';
				};
			});
		}
	}
	if ($('photo_full')) {
		$$('a[class="photo_src"]').each(function(element){
			element.onclick = function(){
				$('photo_big').style.visibility = 'hidden';
				$('photo_big').src = element.href;
				$('photo_big').observe('load', function(){
					$('photo_big').style.visibility = 'visible';
					$('pshown').value = element.id;
				})
				return false;
			}
		});
		/*$('p_l').observe('click', function(){
			
		});*/
	}
	$$('a[class="sprite_letter"]').each(function(element){
		element.onclick = function(){
			$('c_form').show();
			$('dark').observe('click', function(){
				$('c_form').hide();
			});
			$$('a[class="close"]').each(function(element){
				element.onclick = function(){
					$('c_form').hide();
					return false;
				}
			});
			return false;
		}
	});
	$$('a[class="sprite_subscription"]').each(function(element){
		element.onclick = function(){
			$('s_form').show();
			$('s_dark').observe('click', function(){
				$('s_form').hide();
			});
			$$('a[class="s_close"]').each(function(element){
				element.onclick = function(){
					$('s_form').hide();
					return false;
				}
			});
			return false;
		}
	});
});
function str_ireplace( f_needle, f_replace, f_haystack ){  
	var result = '';
	var index = 0;
 
	var haystack = f_haystack.toLowerCase();
	var needle = f_needle.toLowerCase();
	 
	while((index = haystack.indexOf(needle)) > -1){
		result += f_haystack.substring(0, index);
		result += f_replace;
 
		haystack = haystack.substring(index + f_needle.length);
		f_haystack = f_haystack.substring(index + f_needle.length);
	}
	 
	return result + f_haystack;
}

/*  */
jQuery(document).ready(function($) {
	$('span.pressable').click(function() {
		if (!$(this).hasClass('active')) {
			$('span.pressable').removeClass('active');
			$(this).addClass('active');
			var arr = [];
			arr = $(this).attr('id').split('_');
			$(this).parent().parent().parent().find('ul.post').hide();
			$('ul.post#c_'+arr[1]).show();
		}
	});
});

