function cm_divCreate3( id_, tOffset_, bOffset_ )
{
	var offsetDiff = ( bOffset_ - tOffset_ );

	document.write( "<DIV ID=\"" + id_ + "\" " );
	document.write( "STYLE=\"z-index:-1; position:absolute; " );
	document.write( "top:" + tOffset_ + "px;" );
	document.write( "width:1px;" );
	document.write( "height:"+ offsetDiff + "px;" );
	document.write( "overflow:visible;background:#cccccc;\">" );
	document.write( "<img " );
	document.write( " src=\"" + "<%= _grid.getResourcePath() %>clear.gif" + "\" " );

	document.write( "border=\"0\" alt=\"\" width=\"1+\" height=\" " + offsetDiff + "\"/> " );
	document.write( "</DIV>" );
	
	return ""
}

function drawLine( id_, tableMinH_, contY_, footerY_ )
{
	if ( footerY_ - contY_ < tableMinH_ - PANEL_TOP )
		cm_divCreate3( id_, contY_ + PANEL_TOP, contY_ + tableMinH_ - PANEL_TOP );

	else
		cm_divCreate3( id_, contY_ + PANEL_TOP, footerY_ );
}

function draw( isFirstMin_, isThirdMin_ )
{
	if (isFirstMin_ == null || isThirdMin_ == null)
		return;
		
	var BORDER_TOP = 15;
	var tableMinH_ = 354;
	var cont = document.getElementById( 'pos_anchor' ); 
	var contY_ = _getPageOffsetTop( cont ) + PANEL_TOP - BORDER_TOP;
	var footer = document.getElementById( 'footer1' );
	var footerY_ = _getPageOffsetTop( footer );

	if ( isFirstMin_ && isThirdMin_ )
		; // do nothing

	else if ( isThirdMin_ )
		drawLine( "img1", tableMinH_, contY_, footerY_ );

	else if ( isFirstMin_ )
		drawLine( "img2", tableMinH_, contY_, footerY_ );

	else
	{
		drawLine( "img1", tableMinH_, contY_, footerY_ );
		drawLine( "img2", tableMinH_, contY_, footerY_ );
	}
}
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function acknowledgeDisclaimer()
{
  var form = document.getElementById( "DisclaimerFormID" );
	//this only for secure for first time logins
	if (envType == "MSIMSEC")
		DeleteCookie("JSESSIONID","/msim/portal");
	//var submitUrl = window.location + "&MSIM_DA=" + form.MSIM_DA.value;  
	//location.href = submitUrl;
	form.submit();
}

function printCountryNotLaunchedLinks() {	
	document.getElementById('RoleComboDiv').innerHTML='<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table68"><tr><img width="20" height="5" border="0" src="/msamg/msimintl/docs/en_IE/images/clear.gif"/></tr> <tr><img width="20" height="5" border="0" src="/msamg/msimintl/docs/en_IE/images/clear.gif"/></tr> <tr><img width="20" height="5" border="0" src="/msamg/msimintl/docs/en_IE/images/clear.gif"/></tr> 	<tr>		<td width="50%" valign="top" nowrap="true"> 		<IMG height=8 alt="" src="/msamg/msimintl/docs/en_US/images/misc/bullet_red.gif" width=9 border=0> 			<A class=ColumnLink href="http://www.morganstanleyinvestmentfunds.com">MS INVF Daily Prices</A> 				<BR> 					<IMG height=8 alt="" src="/msamg/msimintl/docs/en_US/images/misc/bullet_red.gif" width=9 border=0> 			<A class=ColumnLink href="/liquidity">Morgan Stanley Funds p.l.c.</A> 				<BR> 					<IMG height=8 alt="" src="/msamg/msimintl/docs/en_US/images/misc/bullet_red.gif" width=9 border=0> 			<A class=ColumnLink href="/im/institutional/">Institutional Investor</A> </td> 	</tr> </table>';
}

function openPopWindowForRoles(selectedCountry, selectedRoleId, submitUrl) {
	var funcRetVal = -1;
	var docPath = "/msamg/msimintl/docs/";
	var htmlPath = "/common/welcome_popup.htm";
	var iiFileToOpen = docPath + contentLocale + htmlPath; 
	var fpFileToOpen = docPath + contentLocale + htmlPath; 
	//alert (" file to open " + fileToOpen);
	//alert (" selected country " + selectedCountry);
	
	// work order 569 global landing page redesign

	if (((selectedCountry == 'GB')
		|| (selectedCountry == 'AT')
		|| (selectedCountry == 'AU')
		|| (selectedCountry == 'DE')
		|| (selectedCountry == 'IE')
		|| (selectedCountry == 'IT')
		|| (selectedCountry == 'FR')
		|| (selectedCountry == 'ES')
		|| (selectedCountry == 'HK')
		|| (selectedCountry == 'CH')
		|| (selectedCountry == 'DK')
		|| (selectedCountry == 'FI')
		|| (selectedCountry == 'PE')
		|| (selectedCountry == 'PT')
		|| (selectedCountry == 'CL')
		|| (selectedCountry == 'LU')
		|| (selectedCountry == 'NL')
		|| (selectedCountry == 'NO')
		|| (selectedCountry == 'SE')
		|| (selectedCountry == 'UN')
		|| (selectedCountry == 'GR'))
		&& (selectedRoleId == 'II')) {									
		funcRetVal = 1;	window.open(iiFileToOpen,'Information','left=0,top=0,toolbar=0,menubar=0,dependant=1,location=0,scrollbars=1,resizable=1,width=400,height=590');			
	}

	if (((selectedCountry == 'DK')
		|| (selectedCountry == 'FI')
		|| (selectedCountry == 'CL')
		|| (selectedCountry == 'LU')
		|| (selectedCountry == 'PE')
		|| (selectedCountry == 'NL')
		|| (selectedCountry == 'NO')
		|| (selectedCountry == 'PT')
		|| (selectedCountry == 'UN')
		|| (selectedCountry == 'SE')
		|| (selectedCountry == 'GR'))
		&& (selectedRoleId == 'FP')) {									
		funcRetVal = 1;	window.open(fpFileToOpen,'Information','left=0,top=0,toolbar=0,menubar=0,dependant=1,location=0,scrollbars=1,resizable=1,width=400,height=590');			
	}


	if (funcRetVal == -1) {
			document.DRFormName.action=submitUrl;
			document.DRFormName.submit();
		}
}

function i18nValue(strToReplace) {
	strToReplace = strToReplace.replace(/&gt;/g,">");
	strToReplace = strToReplace.replace(/&lt;/g,"<");
	strToReplace = strToReplace.replace(/&#39;/g,"'");
	strToReplace = strToReplace.replace(/&quot;/g,"\"");
	return strToReplace;
}
	
function mailToFunction(mailToAddress) {	
document.location.href="MailTo:" + mailToAddress;
}

function hideStableProduct()
{
	var vehOptionsObj = document.getElementById("vehicleInfo");	
	if (vehOptionsObj != null)
	{
		var i;
		for (i=0; i<vehOptionsObj.length; i++)
		{
			if (vehOptionsObj.options[i].value == 'SV_static')
			{
				vehOptionsObj.remove(i);
			}
		}
	}
}

