// slideshow_v2.js

// could be overwritten in "parent_url/slideshow_vars.js"
// therefor parent_url/slideshow_vars.js has to be included after "slideshow_v2.js"
var slideshow_width= 574; 
var slideshow_height= 648
var slideshow_left= 100;
var slideshow_top= 50;
var slide_width= 512;
// var showslide_html= location.href.slice(0, parent_url.lastIndexOf("/"))+"index.html?";

tmp_url= location.href;
slideshow_lastIndexOf= tmp_url.lastIndexOf("slideshow")
if (slideshow_lastIndexOf > -1) {tmp_url= tmp_url.slice(0, slideshow_lastIndexOf);}
var parent_url= tmp_url.replace("works", "stayfocused");



function slideshow (u) {
/*
	alert("location.href="+location.href);
	alert("parent_url="+parent_url);
	alert("showslide_html="+showslide_html);
	alert("u="+u);
	alert("url="+showslide_html+u);
*/
	// w=width;h = height, u=uri, n=name, l=left, t=top
	o= "width="+slideshow_width+",height="+slideshow_height+",resizable=1,status=0,left="+slideshow_left+",top="+slideshow_top+",menubar=1,scrollbars=1,toolbar=0,location=0,directories=0";
	window_slideshow= window.open (showslide_html+u,"slideshow",o);
	window_slideshow.focus ();
}


function slideclose () {
	self.close();
}

function stayfocused () {
	if ((window.opener) && (!window.opener.closed)) {
		// this no longer works as indented with tabbed browsing:
		//     * not at all in safari, mac opera: nothing happens
		//     * in mac firefox only if the parent-"window" is the selected tab in the other [of possibly many] browser window

		// tmp= window.opener;
		// parent_url= tmp.location.href;
		// parent_url= window.opener.location.href;
		// parent_url= parent_url.slice(0, parent_url.lastIndexOf("/"))
		this_url= this.window.location.href.replace("works", "stayfocused");
		
		if (this_url.indexOf(parent_url) != -1) {
			window.opener.focus();
			self.blur();
			self.close();
		}
		return;
	} else {
/*
		works only if the slideshow is within GP or sf
		parent_url= this.window.location.href;
		parent_url= parent_url.slice(0, parent_url.lastIndexOf("/")) // ../slideshow
		parent_url= parent_url.slice(0, parent_url.lastIndexOf("/")) // ..
*/
		// self.location.href= parent_url;
		window_parent= window.open (parent_url)
		window_parent.focus();
		self.close();
	}
}