////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : commonscripts.js
//
// Description:
//	This file contains javascripts that are used throughout the Todo1 Personas Site.
//
// Assumptions/Comments:
//	This file should be placed under folder /usr/netscape/server4/docs/javascripts/personas in the
//  web server machine for OpenMarket.  To incude this file in your code, use the following syntax:
//	<script type="text/javascript" language="JavaScript" src="/javascripts/personas/commonscripts.js"></script>
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	03-19-2001		Maria Kaufmann		Initial implementation
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function setStyleSheet(strHostname)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : setStyleSheet
//
// Description:
//	Sets the stylesheet to use for a particular page based on the browser being used.
//
// Inputs:
//	None
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	Currently, only Microsoft Internet Explorer and Netscape are supported.
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	03-19-2001		Maria Kaufmann		Initial implementation
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	var strBrowserName = navigator.appName.toLowerCase();
	if (strBrowserName.indexOf("netscape") != -1 )
	{
		// Visitor is using Netscape.  Include stylesheet for Netscape.
		document.write("<LINK REL='stylesheet' type='text/css' href='http://" + strHostname +
			"/css/personas/ne_styles.css'>");
	}
	else if (strBrowserName.indexOf("microsoft") != -1 )
	{
		// Visitor is using Microsoft Internet Explorer.  Include stylesheet for MS IE.
		document.write("<LINK REL='stylesheet' type='text/css' href='http://" + strHostname + 
			"/css/personas/ie_styles.css'>");
	}
}

function OLBPCommerce()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : OLBPCommerce
//
// Description:
//	Opens a new window where the user is taken to the Online Banking Application for Commerce Bank. 
//
// Inputs:
//	None
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	None
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	05-16-2003		Maria Cruz		Initial implementation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	window.open('https://commercebank.olb.todo1.com/servlet/msfv/BMNBMUS33/Login/loginFrame.htm',
'bank','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}


function popupOLBPichincha()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : linkOLBPichincha
//
// Description:
//	Opens a new window where the user is taken to the Online Banking Application for Banco del Pichincha.  The
// 	script closes the current browser window.
//
// Inputs:
//	None
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	None
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	01-25-2002		Maria Kaufmann		Initial implementation
//  05-17-2002      Maria Cruz			Changed the url
//  11-19-2002		Maria Cruz			Added parameter alwaysRaised=yes (Jim requested it)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	window.open('https://pichincha.olb.todo1.com/servlet/msfv/B2000/Login/loginFrame.htm?BankID=2000',
'bank','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}


function goToSelectedLink(productMenu)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : goToSelectedLink
//
// Description:
//	Takes user to the link associated with the option selected from the dropdown menu (productMenu).
//
// Inputs:
//	productMenu:	the name of the dropdown (select) object containing the menu options.
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	None
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	01-25-2002		Maria Kaufmann		Initial implementation
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	var i = 0;
    var strOptionValue;
	var strLinkURL;
	var strTarget;

	//  Iterate through dropdown options to se which one was selected.	
    while (i < productMenu.options.length) 
	{
	    if ( productMenu.options[i].selected ) 
		{
			// Get the url link associated with selected option
            strOptionValue = productMenu.options[i].value;
			var ipos = strOptionValue.indexOf("!!");
			if ( ipos == -1)
				strLinkURL = strOptionValue;
			else
			{
				strLinkURL = strOptionValue.substring(0, ipos);
				strTarget = strOptionValue.substr(ipos+2);
			}
			
            break;
        }
		i++;	  
	}
	
	// Go to the selected link if not ""
	if (strLinkURL != "")
	{
	  if ( strTarget.indexOf("_top") != -1 )
	  {
		  window.location.href = strLinkURL;		  
	  }
	  else
	  {
		  window.open(strLinkURL,'win','width=680,height=550,scrollbars=yes,resizable=no');		  
	  }
	}
	productMenu.selectedIndex = 0;
}

function openPopup(strURL, iWidth, iHeight, strScrollbars, strToolbar, strMenubar, 
					strResizable, strStatus, strLocation, strDirectories) 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : openPopup
//
// Description:
//
// Inputs:
//	strURL: the URL to open in a popup window.
//	iWidth: the width of the popup window
//	iHeight: the width of the popup window
//	strScrollbars: whether to display scrollbars or not.  Valid values are 'yes' and 'no'.
//	strToolbar: whether to display the toolbar or not.  Valid values are 'yes' and 'no'.
//	strMenubar: whether to display the menubar or not.  Valid values are 'yes' and 'no'.
//	strResizable: whether to display make the window resizable or not.  Valid values are 'yes' and 'no'.
//	strLocation: whether to display the location or not.  Valid values are 'yes' and 'no'.
//	strDirectories: whether to display the directories or not.  Valid values are 'yes' and 'no'.
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	None
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	04-22-2002		Maria Cruz		Initial implementation.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	settings = "height=" + iHeight + ",width=" + iWidth + ",toolbar=" + strToolbar + ",menubar=" + strMenubar + ",scrollbars=" + strScrollbars + ",resizable=" + strResizable + ",location=" + strLocation + ",directories=" + strDirectories + ",status=" + strStatus + ",";
	
	if ((navigator.appName == "Netscape")) 
	{
		settings += "screenX=300,screenY=200";
	} 
	else 
	{
		settings += "left=300,top=200";
	}
	
	window.open(strURL, "pop", settings);
}


function openPopupMain(strURL, iWidth, iHeight, strScrollbars, strToolbar, strMenubar, 
					strResizable, strStatus, strLocation, strDirectories, iposition) 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : openPopup
//
// Description:
//
// Inputs:
//	strURL: the URL to open in a popup window.
//	iWidth: the width of the popup window
//	iHeight: the width of the popup window
//	strScrollbars: whether to display scrollbars or not.  Valid values are 'yes' and 'no'.
//	strToolbar: whether to display the toolbar or not.  Valid values are 'yes' and 'no'.
//	strMenubar: whether to display the menubar or not.  Valid values are 'yes' and 'no'.
//	strResizable: whether to display make the window resizable or not.  Valid values are 'yes' and 'no'.
//	strLocation: whether to display the location or not.  Valid values are 'yes' and 'no'.
//	strDirectories: whether to display the directories or not.  Valid values are 'yes' and 'no'.
//  iposition: the position of the new window in the browser 1=upperleft, 2=upperright, 3=bottomleft, 4=bottomrigth, 5=middle
//
// Outputs:
//	None
//
// Assumptions/Comments:
//	None
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	12-10-2002		Maria Cruz		Initial implementation.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
    var winx = (screen.width - iWidth) / 2;
    var winy = (screen.height - iHeight) / 2;
	var positionx = (screen.width - iWidth) - 30;
	var positiony = (screen.height - iHeight) - 60;

	settings = "height=" + iHeight + ",width=" + iWidth + ",toolbar=" + strToolbar + ",menubar=" + strMenubar + ",scrollbars=" + strScrollbars + ",resizable=" + strResizable + ",location=" + strLocation + ",directories=" + strDirectories + ",status=" + strStatus + ",";
	
	if ((navigator.appName == "Netscape")) 
	{
		if(iposition == 1)
		{
			settings += "screenX=0,screenY=0";
		}
		else if(iposition == 2)
		{
			settings += "screenX="+positionx+",screenY=0";
		}
		else if(iposition == 3)
		{
			settings += "screenX=0,screenY="+positiony;
		}
		else if(iposition == 4)
		{
			settings += "screenX="+positionx+",screenY="+positiony;
		}
	    else
		{
			settings += "screenX="+winx+",screenY="+winy;
		}
	} 
	else 
	{
		if(iposition == 1)
		{
			settings += "left=0,top=0";
		}
		else if(iposition == 2)
		{
			settings += "left="+positionx+",top=0";
		}
		else if(iposition == 3)
		{
			settings += "left=0,top="+positiony;
		}
		else if(iposition == 4)
		{
			settings += "left="+positionx+",top="+positiony;
		}
	    else
		{
			settings += "left="+winx+",top="+winy;
		}
	}
	
	window.open(strURL, "pop", settings);
}

