var current_photo_num = 0;
var total_photos_num;
var arrs_imgs = new Array();
arrs_imgs[0] = new Image();
arrs_imgs[0].src = '/images/arr_l.gif';
arrs_imgs[1] = new Image();
arrs_imgs[1].src = '/images/arr_l_na.gif';
arrs_imgs[2] = new Image();
arrs_imgs[2].src = '/images/arr_r.gif';
arrs_imgs[3] = new Image();
arrs_imgs[3].src = '/images/arr_r_na.gif';
function scroll_photos(scroll_by){
	if(scroll_by == 0)
		return;
	var i = 0;
	var to_show = new Array();
	var id, el;
	if(scroll_by > 0){
		for(; i < scroll_by; i++){
			id = 'fp_photo' + (current_photo_num + 3 + i);
			if(el = document.getElementById(id))
				to_show.push(el);
			else
				break;
		}

		for(i = 0; i < to_show.length; i++){
			id = 'fp_photo' + (current_photo_num + i);
			el = document.getElementById(id);
			if(el)
				el.style.display = "none";
			to_show[i].style.display = "";
		}
		current_photo_num += to_show.length;
	}
	else{
		for(; i > scroll_by; i--){
			id = 'fp_photo' + (current_photo_num + i - 1);
			if(el = document.getElementById(id))
				to_show.push(el);
			else
				break;
		}
		for(i = 0; i < to_show.length; i++){
			id = 'fp_photo' + (current_photo_num + 2 - i);
			el = document.getElementById(id);
			if(el)
				el.style.display = "none";
			to_show[i].style.display = "";
		}
		current_photo_num -= to_show.length;
	}
	var arr1 = document.getElementById('p_scroll_left');
	if(arr1)
		arr1.src = current_photo_num <= 0 ? arrs_imgs[1].src : arrs_imgs[0].src;
	var arr2 = document.getElementById('p_scroll_right');
	if(arr2)
		arr2.src = current_photo_num + 3 >= total_photos_num ? arrs_imgs[3].src : arrs_imgs[2].src;
}

var the_one_window;
var last_w=0,last_h=0;
function popupi(href,w,h){
	var pos_x=(screen.width-w)/2;
	var pos_y=(screen.height-h)/2;
	if(the_one_window&&(last_w!=w||last_h!=h)){
		the_one_window.close();
	}
	last_w=w;
	last_h=h;
	the_one_window=window.open('view_photo.php?f='+href,'the_one_window','width='+w+',height='+h+',scrollbars=0,menubar=0,status=1,toolbar=0,left='+pos_x+',screenX='+pos_x+',top='+pos_y+',screenY='+pos_y);
	the_one_window.focus();
	return false;
}