////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : commonscripts.js
//
// Description:
//	This file contains javascripts that are used throughout the Todo1 Empresas Site.
//
// Assumptions/Comments:
//	This file should be placed under folder /usr/netscape/server4/docs/javascripts/empresas 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/empresas/commonscripts.js"></script>
//
// History:
//
//	Date			Developer			Description
// -----------------------------------------------------------------------------------------------------
//	12-13-2001		Maria Kaufmann		Initial implementation
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function setStyleSheet()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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
// -----------------------------------------------------------------------------------------------------
//	12-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='/css/empresas/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='/css/empresas/ie_styles.css'>");
	}
}

function openWindow(newURL,country,chi,elem,W,H) 
{
	var path = newURL;
	
	if (path=='1') 
	{
		path = '/NASApp/cs/ContentServer?pagename=Empresas/Portal/index&country=' + country + '';
	}
	else if (path=='2') 
	{
		path = '/NASApp/cs/ContentServer?pagename=Empresas/' + elem + '';
	}
	
	settings = 'height=' + H + ',width=' + W + ',toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,'
	
	if ((navigator.appName == "Netscape")) 
	{
		settings += 'screenX=300,screenY=200'
	} 
	else 
	{
		settings += 'left=300,top=200'
	}
	
	window.open(path,'pop',settings)
}

function openPopup(strURL, iWidth, iHeight, strScrollbars, strToolbar, strMenubar, 
					strResizable, strStatus, strLocation, strDirectories) 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name : openPopup
//
// 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:
//	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-16-2002		Maria Kaufmann		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 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			Updated the url and changed some of the parameters
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	window.open('https://pichincha.olb.todo1.com/servlet/msfv/B2000/Login/loginFrame.htm?BankID=2000',
'bank','status=yes,menubar=no,scrollbars=yes,resizable=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;
}

