    ////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
   //         JavaScript code for SES Education Foundation         \\
  //     Written by Kevin Stanek of Stanek Software Development     \\
 //                            29 Aug 2009                           \\
////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// find our path
var rootDir = this.location.toString();
rootDir = rootDir.substring(0, rootDir.lastIndexOf("/") + 1);

// determine the computer platform
var platMac = (navigator.appVersion.indexOf("Mac") != -1);
var platWin = (navigator.appVersion.indexOf("Win") != -1);

// determine the browser in use
var browNet = (navigator.appName.indexOf("Netscape") != -1);
var browMic = (navigator.appName.indexOf("Microsoft") != -1);

var macOSX = (navigator.userAgent.indexOf("Mac OS X") != -1);

// other global variables

// -----------------------------------------------
// CondLoad
// -----------------------------------------------
function CondLoad(frm, url, opt)
{
	var rtnVal = false;
	var oldUrl = frm.location.href;
	if (typeof(opt) == "undefined") opt = "";
	if (oldUrl.indexOf("?") > -1)
	{
		oldUrl = oldUrl.substr(0,oldUrl.indexOf("?"));
	}
	if (oldUrl != url)
	{
		frm.location.replace(url + opt);
		rtnVal = true;
	}
	return rtnVal;
}

// -----------------------------------------------
// ExtLink
// -----------------------------------------------
function ExtLink(extLink)
{
	extWin = OpenSecWin(2, extLink);
}

// -----------------------------------------------
// GetAdobeReader
// -----------------------------------------------
function GetAdobeReader()
{
	extWin = OpenSecWin(2, "http://www.adobe.com/products/acrobat/readstep2.html");
}

// -----------------------------------------------
// Init
// -----------------------------------------------
function Init()
{
}

// -----------------------------------------------
// IntLink
// -----------------------------------------------
function IntLink(localPath)
{
	intWin = OpenSecWin(1, rootDir + localPath + ".htm");
}

// -----------------------------------------------
// JournalEntries
// -----------------------------------------------
function JournalEntries(fieldStudy)
{
	intWin = OpenSecWin(6, rootDir + "JournalEntries/" + fieldStudy + "/home.htm");
}

// -----------------------------------------------
// LinkNA
// -----------------------------------------------
function LinkNA()
{
	alert("This link will be supported very soon.");
}

// -----------------------------------------------
// OpenSecWin
// -----------------------------------------------
function OpenSecWin(winStyle, URL)
{
	var winLf, winTp, winHt, winWd;
	var openFeatures;
	var winName;

	// get full window size
	if (browNet)
	{
		if (platMac)
		{
			winHt = 470; winWd = 788;
		}
		else
		{
			winHt = 470; winWd = 788;
		}
	}
	else
	{
		if (platMac)
		{
			winHt = 454; winWd = 772;
		}
		else
		{
			winHt = 451; winWd = 789;
		}
	}
	winHt += (768 - 600);
	winWd += (1024 - 800);

	if (winStyle == 1)	// internal link
	{
		winLf = 25;
		winTp = 25;
		winHt -= 50;
		winWd -= 50;
		winName = "IntLink";
		openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
	}
	else if (winStyle == 2)	// external link
	{
		winLf = 50;
		winTp = 25;
		winHt -= 100;
		winWd -= 100;
		winName = "ExtLink";
		openFeatures = "toolbar=yes,status=yes,resizable=yes,menubar=yes,scrollbars=yes,location=yes";
	}
	else if (winStyle == 3)	// PDF link
	{
		winLf = 25;
		winTp = 25;
		winHt -= 50;
		winWd -= 50;
		winName = "PDF";
		openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=no";
	}
	else if (winStyle == 4)	// PayPal link
	{
		winLf = 0;
		winTp = 10;
		winHt -= 20;
		winWd += 10;
		winName = "PayPal";
		openFeatures = "toolbar=no,status=yes,resizable=yes,menubar=yes,scrollbars=yes";
	}
	else if (winStyle == 5)	// Slide show link
	{
		winLf = 0;
		winTp = 10;
		winHt = 480;
		winWd = 420;
		winName = "SlideShow";
		openFeatures = "toolbar=no,status=no,resizable=no,menubar=no,scrollbars=no";
	}
	else if (winStyle == 6)	// Journal entries link
	{
		winLf = 370;
		if (screen.width > 800) winLf = 430;
		winTp = 10;
		winHt = 480;
		winWd = 420;
		winName = "JournalEntries";
		openFeatures = "toolbar=no,status=no,resizable=no,menubar=no,scrollbars=no";
	}
	else if (winStyle == 7)	// Thank you letters link
	{
		winLf = 370;
		if (screen.width > 800) winLf = 594;
		if (screen.width >= 1280) winLf = 860;
		winTp = 10;
		winHt = 480;
		winWd = 420;
		winName = "ThankYouLetters";
		openFeatures = "toolbar=no,status=no,resizable=no,menubar=no,scrollbars=no";
	}

	// set size and location
	openFeatures = openFeatures + ",height=" + winHt;
	openFeatures = openFeatures + ",width=" + winWd;
	openFeatures = openFeatures + ",left=" + winLf;
	openFeatures = openFeatures + ",top=" + winTp;

	// open the window
	win = self.open(URL, winName, openFeatures, "");

	// bring the window to the top
	win.focus();
	return win;
}


// -----------------------------------------------
// PayPalDonation
// -----------------------------------------------
function PayPalDonation()
{
	OpenSecWin(4, rootDir + "How_You_Can_Help/Donate_Money/PayPalDonation.htm");
}

// -----------------------------------------------
// PDFLink
// -----------------------------------------------
function PDFLink(pdfName)
{
//	if (macOSX)
//	{
//		top.sbmt.location.replace(rootDir + "pdf/" + pdfName + ".pdf");
//	}
//	else
//	{
		OpenSecWin(3, rootDir + "pdf/" + pdfName + ".pdf");
//	}
}

// -----------------------------------------------
// PrintPage
// -----------------------------------------------
function PrintPage(win)
{
	if (typeof(win.print) == "undefined")
	{
		win.alert("Your browser does not support printing from a script. Use the Print command from the File menu instead.");
	}
	else
	{
		win.print();
	}
}

// -----------------------------------------------
// ReloadOnResize
// -----------------------------------------------
function ReloadOnResize(win)
{
	if ((navigator.userAgent.indexOf("Safari") > -1) ||
		(navigator.userAgent.indexOf("OmniWeb") > -1) ||
		(navigator.userAgent.indexOf("Opera") > -1))
	{
		win.document.location.reload(false);
	}
}

// -----------------------------------------------
// SESEFFooterLink
// -----------------------------------------------
function SiteMap()
{
	CondLoad(top.main, rootDir + "Site_Map/home.htm");
}

// -----------------------------------------------
// SESEFFooterLink
// -----------------------------------------------
function SESEFFooterLink()
{
	CondLoad(top.main, rootDir + "Contact_Us/home.htm");
}

// -----------------------------------------------
// SlideShow
// -----------------------------------------------
function SlideShow(fieldStudy)
{
	intWin = OpenSecWin(5, rootDir + "SlideShows/" + fieldStudy + "/home.htm");
}

// -----------------------------------------------
// ThankYouLetters
// -----------------------------------------------
function ThankYouLetters(fieldStudy)
{
	intWin = OpenSecWin(7, rootDir + "ThankYouLetters/" + fieldStudy + "/home.htm");
}
