
function popImagePG(imageURL, imageTitle, thumb_name, w, h)
{
	PopupPic(imageURL.replace(thumb_name, "thumbs800x600/"), imageTitle, w, h);
}

function PopupPic(sPicURL, title, w, h) { 
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height=100,width=100,top='+wint+',left='+winl+'resizable=0';
  	window.open(base_href + "picturedetail.html?" + sPicURL + "&" + title + "", "", winprops);
}

var timerId = 0;
var scrolled = 0;
var total_width = 0;

function scroll_news()
{		
	if (!total_width)
		total_width = document.getElementById("news_slide").scrollWidth - document.getElementById("news_slide_2").offsetWidth;
		
	var inc = 1;
	if (timerId)
	{
		clearTimeout(timerId);
		timerId = 0;
	}
	scrolled += inc;
	// alert(total_width);
	if (scrolled >= total_width)
	{
		// alert(total_width);
		// alert(scrolled);
		
		document.getElementById("news_slide").scrollLeft = 0;
		scrolled = 0;
		// alert("resetting");
	}
	else 
		document.getElementById("news_slide").scrollLeft += inc;

	timerId = setTimeout("scroll_news('" + scrolled + "', '" + total_width + "')", 25);
}

function scroll_news_stop()
{
	clearTimeout(timerId);
	timerId = 0;
}


function gallery_zoom(title, img_folder)
{
	Modalbox.show("_slideshow.php?folder="+img_folder,
		{title: title,
		width: 800 + 20,
		height: 600 + 70});
   
}


var images = [];
var images_pos = 0;
var images_count = 0;

function slide_next_img()
{
	if ((images_pos + 1) < images_count)
	{
		// go next
		images_pos++;
	}
	else
	{
		// go first
		images_pos = 0;
	}
	if (images[images_pos])
	{
		document.getElementById("slide_big_image").src = images[images_pos]["path"];
//		document.getElementById("MB_caption").innerHTML = images[images_pos]["name"];
	}
}

function slide_prev_img()
{
	if ((images_pos - 1) >= 0)
	{
		// go prev
		images_pos--;
	}
	else
	{
		// go last
		images_pos = images_count - 1;
	}
	if (images[images_pos])
	{
		document.getElementById("slide_big_image").src = images[images_pos]["path"];
//		document.getElementById("MB_caption").innerHTML = images[images_pos]["name"];
	}
}

var ss_timerid = 0;

function play_pause_ss()
{
	if (ss_status == "stop")
	{
		ss_status = "play";
		document.getElementById("play_pause_ss").innerHTML = "Pause";
		slideshow_me();
	}
	else
		pause_ss();
}

function pause_ss()
{
	ss_status = "stop";
	document.getElementById("play_pause_ss").innerHTML = "Play";
	clearTimeout(ss_timerid);
	ss_timerid = 0;
}

function slideshow_me()
{
	slide_next_img();
	ss_timerid = setTimeout("slideshow_me()", 1500);
}

