// Revision History
// 2005-10-06 Allan - change default mac safari width to 550 to match change in slideshow.js  

var slideShowWin=null;

function Browser() {
	var b=navigator.appName;
	if (b.indexOf('Netscape')!=-1) this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser.\nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6.0')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is=new Browser();

var dimReady=false;
var sWidth=null;
var sHeight=null;
var is_launched=null;

// This is the main entry point for invoking the slide show from a user page.
// See comments in "slideshow.html"
function launch_slideshow(slideShowFile,width,height)
{

	// revision history
	//
	// 20050923 allan: added /secure to path if coming from a secure page.

	window.is_launched=true;
	var len = launch_slideshow.arguments.length;
	// Setup some default dimension in case no args are given.
	// Inc by 10
	// change mac safari to 550 to match change in slideshow.js --Allan 2005-10-06
	var w=550 //((is.platform=="mac") ? (is.ie ? 550 : 480) : 550);
	var h=((is.ie && is.platform=="mac") ? 640 : 550); 
	var f="slideshow.html";
	
	// If already open and running, then close it first.
	if (slideShowWin != null)
	{
		slideShowWin.close();  slideShowWin = null;
	}
	// Override the defaults if alternates provided.
	if (len > 0) f = slideShowFile;
	if (len > 1) w = width;
	if (len > 2) h = height;
	

        // fix url if coming from a secure page

        if (document.location.href.indexOf("https://") != -1){
             //prh 2005 11 09: if f begins with a forward slash, assume it already has the full path to photo_gallery.html
             //and just append /secure
             if( f.indexOf("/") == 0 ){ 
             	f = "/secure" + f;
             } else {
             	
             	//prh 2005 11 09: create the full path to photo_gallery.html, beginning with secure, based on the current document.location.href
             	var path = document.location.href;
		var new_path="";
		var temp = new Array();
		temp = path.split("/");
		for(i=0;i<temp.length;i++){
			if( (temp[i].indexOf(":")==-1) && (temp[i].indexOf(".")==-1) ) {
				new_path = new_path + temp[i] + "/";
			}
		}
 
             	f = "/secure" + new_path + f;
             }
        }
	
	availX = window.screen.availWidth;
	availY = window.screen.availHeight;
	var too_big=false;
	if(w>(availX-25))
	{
		too_big=true;
		w=availX-25
	}
	if(h>(availY-30))
	{
		too_big=true;
		h=availY-30
	}
	

	// alert("(w,h)=("+w+","+h+")");
	// Open the slide show window.


	if(false) //too_big)
	{
		slideShowWin = window.open(f,'slideshow','status=no,toolbar=no,location=no,directories=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+w+',height='+h);
		slideShowWin.sWidth = sWidth = w - 14;
		slideShowWin.sHeight = sHeight = h - 14;
		slideShowWin.too_big=true;
	}else
	{
		if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) 
		{
			resizeable='yes'
		}else
		{
			resizeable='no'
		}
       		
       		slideShowWin = window.open(f,'slideshow','status=no,toolbar=no,location=no,directories=no,scrollbars=no,resizable=' + resizeable + ',copyhistory=no,width='+w+',height='+h);
		slideShowWin.sWidth = sWidth = w;
		slideShowWin.sHeight = sHeight = h;
		slideShowWin.too_big=false;
	}
	slideShowWin.requested_width = width;
	slideShowWin.requested_height = height;
//	slideShowWin.moveTo(0,0);
	slideShowWin.dimReady = dimReady = true;
}


