/* commonscripts.js */


// jumpTo function scrolls the page to specified coordinates when called

function jumpTo(intX,intY) {
	self.scrollTo(intX, intY);
	}
	

// Set the siteRoot variable here to be available as-needed in scripts
//
// Partners - production server
var siteRoot = "http://nsmc.partners.org";
//
// Epistrophy - testing locally
// var siteRoot = "http://192.168.15.160";
//
// Crepuscule - testing locally
//var siteRoot = "http://localhost/nsmc";


// Pop-up window function for legacy Make a Donation form
function Start(page) {

OpenWin = this.open(page, "CtrlWindow", 

"height=500,width=780,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");

}


// Generic pop-up window function
// Example: <a href="javascript: makePopup('pageToLoadIn.htm','nameOfNewPage','height=400,width=520,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');">Open Popup Window</a>

function makePopup(page, newPopupName, chrome) {
	newPopupWin = this.open(page, newPopupName, chrome);
}



// Pop-up window function for RSS feed pages
// Example: <a href="javascript: makePopup('pageToLoadIn.htm','nameOfNewPage','height=400,width=520,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');">Open Popup Window</a>

function makeRSSPopup(page) {
	newPopupWin = this.open(page, "RSSWindow", "height=400,width=500,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}


// Loads the Jobs documents into an Iframe if they are supported, into a pop-up window if Iframes are not supported

function jsLoadJob(iJobId)
{
	if (document.getElementById)
	{
		document.location = '../jobs_search/jobs_search=' + iJobId;
		return false;
	}
	else
	{
		return true;
	}
}

function jsLoadJobSearch()
{
	if (document.getElementById)
	{
		document.location = '../jobs_search/jobs_search';
		return false;
	}
	else
	{
		return true;
	}
}

// Loads the Find a Doctor pages into an Iframe if they are supported, into a pop-up window if Iframes are not supported

function jsLoadPhysicians()
{
	if (document.getElementById)
	{
		document.location = '../physician/find_a_physician';
		// change this when we launch
		//document.location = 'http://www.nsmc.partners.org/web/physician/find_a_physician';
		return false;
	}
	else
	{
		return true;
	}
}

// Drop-Down Menu Navigation

function navigateTo (url) {
     document.location= url;
}

// Iframe handler script for Jobs Search page
// This script scrolls the parent page to the top whenever the embedded iframe loads a new document

function handleIframe(){
	scroll(0,0);
}

//Function to create a Date string
//Written by Eric Rasmussen, Green Lantern Design, 06/25/02
//Modified from The JavaScript Bible, 3rd ed. by Danny Goodman
//for the ASMP NE site

///// BROWSER DETECTION /////
NS6 = (document.getElementById&&!document.all);

function MakeArray(n) {
	this.length = n
	return this
}

monthNames = new MakeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"

dayNames = new MakeArray(7)
dayNames[1] = "Sunday"
dayNames[2] = "Monday"
dayNames[3] = "Tuesday"
dayNames[4] = "Wednesday"
dayNames[5] = "Thursday"
dayNames[6] = "Friday"
dayNames[7] = "Saturday"

function dateString(today) {
	var theDay = dayNames[today.getDay() + 1]
	var theMonth = monthNames[today.getMonth() + 1]
	var theYear = today.getYear()
	if (NS6) theYear = theYear + 1900
	//return theDay + ", " + theMonth + " " + today.getDate() + ", " + theYear
	return theMonth + " " + today.getDate() + ", " + theYear
}
 


// function called from Flash slideshow
// opens a window with larger version of the slide

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function slideshow_DoFSCommand(command, args) {
	var slideshowObj = InternetExplorer ? document.slideshow : document.slideshow;
	var picPath = command;
	var picCaption = args;
	var fullSizePicPath = picPath.replace(/_thumb/g,'');
	fullSize = window.open("", "", "height=500,width=700,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
	var newContent = "<html><head><title>NSMC - North Shore Medical Center</title>";
	newContent += "<style type='text/css' media='screen'>@import 'http://nsmc.partners.org/common/styles/nsmcstyles.css';</style>";
	newContent += "</head>";
	newContent += "<body bgcolor=#CCCCCC text=#243669>";
	newContent += "<div align='center'>";
	newContent += "<table border=0 cellspacing=0 cellpadding=0 class='slideshow-fullsize-table'>";
	newContent += "<tr><td align=center valign=top colspan='2'>";
	newContent += "<div class='slideshow-fullsize-image'><img src='" + fullSizePicPath + "' border=0 /></div>";
	newContent += "</td></tr>";
	newContent += "<tr><td align=left valign=top>";
	newContent += "<div class='slideshow-caption'>" + picCaption + "</div>";
	newContent += "</td>";
	newContent += "<td align=right valign=top>";
	newContent += "<div class='slideshow-link'><a href='javascript:window.close()'>";
	newContent += "Close Window</a></div>";
	newContent += "</td></tr></table></div></body></html>";
	// write HTML to new window document
	fullSize.document.write(newContent);
	fullSize.document.close();
}

// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") 
  
!= -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub slideshow_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call slideshow_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}




// BrowserCheck Object
// provides most commonly needed browser checking variables
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

// automatically create the "is" object
is = new BrowserCheck()


function WM_netscapeCssFix() {
  /*
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Taylor
    Author Email: taylor@wired.com
    Author URL: http://www.taylor.org/
    */

  // This part was inspired by Matthew_Baird@wayfarer.com
  // It gets around another unfortunate bug whereby Netscape 
  // fires a resize event when the scrollbars pop up. This 
  // checks to make sure that the window's available size 
  // has actually changed.
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  // This function checks to make sure the version of Netscape 
  // in use contains the bug; if so, it records the window's 
  // width and height and sets all resize events to be handled 
  // by the WM_netscapeCssFix() function.
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

