	// SOME VARIABLE DECLARATIONS
	////////bival//////////////////
				
	var sFrom = 0;
	var sTo = 0;
	var rowNumner = 5;
	var rows=0;
	var SLast=0;
	var SFast=0;
	
	////////////////////////////////
var dialogWin = new Object();
var leftShift, topShift;
var decimalPointDelimiter = ".";
sNN6="NN6";
function isNN4(){return (null!=document.layers)}
function isOpera(){return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1)}
function isNN6(){return (navigator.userAgent.toLowerCase().indexOf("mozilla/5")!=-1)}
function isIE5(){return (navigator.appVersion.toLowerCase().indexOf("msie 5")!=-1)}
function isWebTV(){return (navigator.appName.toLowerCase().indexOf("webtv")!=-1)}
gbNN4=isNN4();
gbIE5=isIE5(); 
gbNN6=isNN6();
gbOpera=isOpera();
gbDom=(gbNN6||gbIE5||gbOpera);
gbIE4=(!(gbDom||gbNN4));

var sLiabilities = 'liabilities';
var sCollateral = 'collateral';
var sHedge = 'hedge';
var sAnalytics = 'analytics';var sAnalytics = 'analytics';

var urlWSA = 'http://www.wallstreetanalytics.com/wallstreetanalytics/interface/wsaweb/us/about/index.jsp';
var urlOverview = 'http://www.wallstreetanalytics.com/wallstreetanalytics/interface/wsaweb/us/products/product.jsp?GUID=1034155155280';
var urlProducts = 'http://www.wallstreetanalytics.com/wallstreetanalytics/interface/wsaweb/us/products/index.jsp';
var urlCDOnet = "http://www.wallstreetanalytics.com/wallstreetanalytics/interface/wsaweb/us/products/product.jsp?GUID=990014674057";

var sBreakEven = "<html><body bgcolor='#E9FDFD'><font color='blue'> break-even</font></body></html>";
var iUpdatedMillliSeconds = 1600;
var sPpHeader ='<table width="538" height="1%" class="exptable"><tr><td height="1%" class="expheader" nowrap width="352">&nbsp;Tranche</td><td height="1%" class="expheader" nowrap width="100" align="right">Amount&nbsp;</td><td height="1%" class="expheader" nowrap width="80" align="right">Percent&nbsp;</td></tr>';
var sPpHeaderNN ='<table width="538" height="1%" class="exptable" cellpadding="1" cellspacing="1"><tr><td height="1%" class="expheader" nowrap width="352">&nbsp;Tranche</td><td height="1%" class="expheader" nowrap width="100" align="right">Amount&nbsp;</td><td height="1%" class="expheader" nowrap width="80" align="right">Percent&nbsp;</td></tr>';
var sPp1='<tr><td height="1%" class="expbottom" nowrap width="352">&nbsp;Total for Portfolio</td><td height="1%" class="expbottom" nowrap width="100" align="right">';
var sPp2='&nbsp;</td><td height="1%" class="expbottom" nowrap width="80" align="right">';
var sPp3='%&nbsp;</td></tr></table>';

var sPp01 = '<html><head><title>Portfolio Exposure Details</title></head><LINK href="cdostyles.css" rel="STYLESHEET" type="text/css"/><body bottommargin="0" topmargin="0" marginheight="0" marginwidth="0" rightmargin="0" leftmargin="0"><table class="exptable" width="538" cellspacing="1" cellpadding="0"><tr><td width="538"><IMG height="1" alt="" src="images/spacer.gif" width="538" border="0"/></td></tr><tr><td  width="538" height="1%" class="exptop" nowrap>&nbsp;&nbsp;Exposure&nbsp;by&nbsp;';
var sPp02 = '</td></tr></table>';
var sPp03 = '<table width="540" height="15" class="exptable" cellpadding="0" cellspacing="1"><tr><td align="center" class="bgwhite"><span class="copyright">Copyright &copy; 2003. Wall Street Analytics, Inc. All rights reserved.</span></tr></td></body></html>';

var sPp101 = '<tr><td bgcolor="#ffffff" height="1%">&nbsp;';
var sPp101NN1 = '<tr><td bgcolor="#f0f0f0" height="1%">&nbsp;';
var sPp101NN2 = '<tr><td bgcolor="#E9E9E9" height="1%">&nbsp;';
var sPp103 ='&nbsp;</td><td bgcolor="#ffffff" height="1%" align="right">';
var sPp103NN1 ='&nbsp;</td><td bgcolor="#f0f0f0" height="1%" align="right">';
var sPp103NN2 ='&nbsp;</td><td bgcolor="#E9E9E9" height="1%" align="right">';
var sPp105 ='%&nbsp;</td></tr>';

var sExpIndexHref1 = '<a href="#" class="white_href" onmousedown="javascript:setIndexBtn(\'down\');" onmouseout="javascript:setIndexBtn(\'up\');" onclick="javascript:sortByIndex();">';
var sExpIndexHref2 = '</a>';
EXP_INDEX_DESC = 0;
EXP_INDEX_ASC = 1;
EXP_VALUE_DESC = 2;
EXP_VALUE_ASC = 3;
/////////////////////////////////////////////////////////////////
function unLoadMeNN()
{
	if( gbNN6 )
	{
		if( self.dialogWin.win && ! self.dialogWin.win.closed)
		{
			self.dialogWin.win.close();
		}
	}
}
/////////////////////////////////////////////////////////////////
function validateNumberInput(theEvent)
{
	/*	this function allows to input into the text field only 
		numeric values or decimal point.
		It doesn't check if the result string is positive number.*/
	if( (( 48 > theEvent.keyCode ) || ( event.keyCode > 57 )) && event.keyCode != 46 )	
	{
		event.returnValue=false;
	}
}
/////////////////////////////////////////////////////////////////
function openMySettings()
{
  if( window.document.location.href.indexOf("single_scenario") == -1
		|| (window.document.location.href.indexOf( "single_scenario" ) != -1 
		     && self.actMode == true) )
  {
	wd = 270;
	ht = 270;
	wdNN = 350;
	htNN = 310;
	if( window.showModalDialog )
	{
		var ms_url = "my_settings.jsp?pagerefresh=" + 10000 * Math.random();
		var params = "center=yes;dialogWidth=" + wd + "pt;dialogHeight=" + ht + "pt;status=no";
		var sReturn = showModalDialog( ms_url , "" , params );
		if( sReturn!="" )
		{
			if( sReturn == "farewell_for_parent" )
			{
				window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
			}
			else
			{
			}
		}
	}	
	else if( gbNN6 )
	{  	
		openMySettings_NN( "my_settings.jsp?pagerefresh=" + 10000 * Math.random() ,wdNN, htNN  );
	}
	else 
	{
		alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
	}
  }
}
/////////////////////////////////////////////////////////////////
function openMytypes()
{

  if( window.document.location.href.indexOf("single_scenario") == -1
		|| (window.document.location.href.indexOf( "single_scenario" ) != -1 
		     && self.actMode == true) )
  {
	wd = 270;
	ht = 180;
	wdNN = 350;
	htNN = 310;

	if( window.showModalDialog )
	{
		var ms_url = "my_types.jsp";
		var params = "center=yes;dialogWidth=" + wd + "pt;dialogHeight=" + ht + "pt;status=no";
		var sReturn = showModalDialog( ms_url , "" , params );

		
		if( sReturn!="" )
		{
			if( sReturn == "farewell_for_parent" )
			{
				window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
			}
			else
			{
			}
		}
		
	
	valuationsubmit(sReturn);
		
	}	
	else if( gbNN6 )
	{  	
		openMyTypes_NN( "my_types.jsp?pagerefresh=" + 10000 * Math.random() ,wdNN, htNN  );
	}
	else 
	{
		alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
	}
  }

//window.location.reload() ;

}



//function openMytypes()
//{
// alert ("abc");
//  var ReturnValue = showModalDialog("my_types.jsp","Passed String",
//    "dialogWidth:400px; dialogHeight:225px; status:no; center:yes");
	
  
//  window.location.reload() ;
//}






/////////////////////////////////////////////////////////////////
function openMySettings_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
function openMyTypes_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}
/////////////////////////////////////////////////////////////////
function getURLParam( param ) 
{
	var queryStr = window.document.location.search.substring(1);
	var qryStrPairs = queryStr.split("&");
	for( var i = 0; qryStrPairs.length > i; i++ )
	{
		var posn = qryStrPairs[i].indexOf( '=' );
		if( posn != -1 )
		{
			if( qryStrPairs[i].substring(0, posn) == param)
			{
				return unescape( qryStrPairs[i].substring(posn + 1) );
			}
		}
	}
	return "";
}
/////////////////////////////////////////////////////////////////
function trackingVisitors( ) 
{
}
//====//
function changeMe(spanID, clsName)
{
	if( self.actMode )
	{
		changeClass(spanID, clsName);
	}
}
//====//
function changeClass(hrefId, clsName)
{//	alert( hrefId + "," + clsName );
	if(document.links)
	{
		for(var i=0;document.links.length > i;i++)
		{
			if( document.links[i].id == hrefId)
			{
				document.links[i].className = clsName;
			}
		}
	}
	if( ! gbNN6 )
	{
		if(document.all.tags)
		{
			var spans =  document.all.tags("span");
			for( var i=0; spans.length > i; i++ )
			{
				if( spans[i].id == hrefId)
				{
					spans[i].className = clsName;
				}
			}
		}
	}
}
//====//
function changeChoiceImg(imgName, actInact)
{
	if (window.document.images ) 
	{
		if (preloadFlag == false)
		{
			preloadImages();
		}
		img_obj = window.document[imgName];
		if(img_obj)
		{
			img_obj_src = img_obj.src;

			if(actInact =="inact")
			{ 
				if( img_obj_src.indexOf('images/button_choice.gif') > -1 )
				{
					img_obj.src = 'images/button_choice_inact.gif';
				}
				else if( img_obj_src.indexOf('images/button_choice_not_ready.gif') > -1 )
				{
					img_obj.src = 'images/button_choice_inact_nr.gif';
				}
			}
			else
			{
				if( img_obj_src.indexOf('images/button_choice_inact.gif') > -1 )
				{
					img_obj.src = 'images/button_choice.gif';
				}
				else if( img_obj_src.indexOf('images/button_choice_inact_nr.gif') > -1 )
				{
					img_obj.src = 'images/button_choice_not_ready.gif';
				}
			}
		}
	}
}
//////////////////////////////////////////////////////////////////
function getCookie( name ) 
{
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( (!start) && (name != document.cookie.substring( 0, name.length )) )
	{
		return null;
	}
    if (start == -1)
	{
		return null;
	}
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 )
	{
		end = document.cookie.length;
	}
    return unescape( document.cookie.substring( len, end ) );
}
//////////////////////////////////////////////////////////////////
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 dialogPositionNN(Dw,Dh)
{
	leftShift = window.screenX + ( (window.outerWidth - Dw) / 2 );
	topShift = window.screenY + ( window.outerHeight - Dh ) / 2;
}

//////////////////////////////////////////////////////////////////

function dialogOpenNN( _url, Dw, Dh, aFixedOne ) 
{	
	var params = ( aFixedOne ? ",resizable=no,scrollbars=no" : ",resizable=yes,scrollbars=yes" ) ;
	
	if( dialogWin.win && ! dialogWin.win.closed)
	{
		dialogWin.win.close();
	}

	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) 
	{
		dialogWin.returnedValue = "";
		dialogPositionNN(Dw,Dh);
		var attr = "screenX=" + leftShift + 
			   ",screenY=" + topShift + ",width=" + 
			   Dw + ",height=" + Dh + params + ",help=no,status=no";
		
		dialogWin.win=window.open(_url, "", attr);
		
		if( dialogWin.opener == null )
		{
			dialogWin.opener = self;
		} 
		dialogWin.win.focus();
	} 
	else 
	{
		dialogWin.win.focus()
	}
	
	return true;
}
/*
//////////////////////////////////////////////////////////////////

function dialogOpenNNold(_url, Dw, Dh) 
{	
	if( dialogWin.win && ! dialogWin.win.closed)
	{
		dialogWin.win.close();
	}

	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) 
	{
		dialogWin.returnedValue = "";
		dialogPositionNN(Dw,Dh);
		var attr = "screenX=" + leftShift + 
			   ",screenY=" + topShift + ",width=" + 
			   Dw + ",height=" + Dh+",resizable=yes,scrollbars=yes,help=no,status=no";
		
		dialogWin.win=window.open(_url, "", attr);
		
		if( dialogWin.opener == null )
		{
			dialogWin.opener = self;
		} 
		dialogWin.win.focus();
		
	} 
	else 
	{
		dialogWin.win.focus()
	}
	
	return true;
}
*/
//////////////////////////////////////////////////////////////////

function newImage(arg) 
{
	if (self.document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

//////////////////////////////////////////////////////////////////

function changeImages() 
{
	if (self.document.images && (self.preloadFlag == true)) 
	{
		for (var i=0; i<changeImages.arguments.length; i+=2) 
		{
			self.document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//////////////////////////////////////////////////////////////////

function PickDefRateTypeChoice_NN(url, Dw, Dh)
{
	dialogOpenNN( url, Dw, Dh);
}

//////////////////////////////////////////////////////////////////

function PickDefRateTypeChoice(params) 
{
	if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
	{
		var page = self.page;
		if( window.showModalDialog )
		{
			var sReturn;
			var dr_url = "def_rates_choice.jsp?pagerefresh=" + 10000 * Math.random();
			sReturn = showModalDialog(dr_url,"","center=yes;dialogWidth=180pt;dialogHeight=245pt;status=no");

			if (sReturn!="") 
			{
				if(sReturn!="farewell_for_parent") 
				{
					var url = page + "?hist=no&defratetype=" + sReturn + params;
					redirect(addSingleScenarioParamsToURL(url));
				}
				else
				{
					window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
				}
			}
			else
			{
				resetWaitingTask();
			}
		} 
		else if( gbNN6 )
		{  	
			PickDefRateTypeChoice_NN( "def_rates_choiceNN.jsp?" + "page=" + page + params, 200, 250 );
		}
		else 
		{
			alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
		}
	}
}

//////////////////////////////////////////////////////////////////

function PickRecoveryRateTypeChoice(params) 
{
  if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
  {
	var page = self.page;
   	if (window.showModalDialog) 
   	{
      var sReturn;  
	  sUrl = "recovery_rates_choice.jsp?pagerefresh=" + 10000 * Math.random()
      sReturn = showModalDialog(sUrl,"","center=yes;dialogWidth=200pt;dialogHeight=200pt;status=no");

      if (sReturn!="") 
	  {
	 	if(sReturn!="farewell_for_parent") 
		{
	     	var url = page + "?hist=no&recratetype=" + sReturn + params;
			redirect(addSingleScenarioParamsToURL(url));// do not need to replace location  and erase history
		}
		else
		{
			window.document.location.replace("login.jsp");
		}
      } 
	  else
	  {
		resetWaitingTask();
	  } 
    } 
	else if( gbNN6 )
	{  	
		pickRecoveryRateTypeChoice_NN( "recovery_rates_choice.jsp?page=" + page + params, 280, 250 );
	}
   	else 
	{
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   	}
  }
}

//////////////////////////////////////////////////////////////////
function pickRecoveryRateTypeChoice_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
	return true;
}	

//////////////////////////////////////////////////////////////////
function AddTrancheToMyPortfolio_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
	return true;
}
//////////////////////////////////////////////////////////////////
function setInterestRates_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
	return true;
}
//////////////////////////////////////////////////////////////////
function setInterestRates()
{
 if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
 {
   if (window.showModalDialog) 
   {
     var sReturn;  
	 var sir_url = "set_interest_rates.jsp?fx=" + self.sCurrency + "&pagerefresh=" + 10000 * Math.random();
     sReturn = showModalDialog(sir_url,"","center=yes;dialogWidth=340pt;dialogHeight=340pt;status=no");
	
	 if (sReturn!="") 
	 { 
  		if(sReturn!="farewell_for_parent") 
		{
			self.setRatesBtn( sReturn );
			resetWaitingTask();
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }
	 else
	 {
		resetWaitingTask();
	 }
   }
   else if( gbNN6 )
   { 
	 setInterestRates_NN( "set_interest_rates.jsp?fx=" + self.getCurrency() + "&pagerefresh=" + 10000 * Math.random(), 500, 470 );
   } 
   else
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   }
 }
}
//////////////////////////////////////////////
function resetWaitingTask()
{	
	if( self.page.indexOf("single_scenario") > -1 )
	{
		if( self.taskWasSent == 'yes' && self.taskReady == 'no' )
		{
			self.reloadResultFrame();
			if( self.PriceYieldResultFrame )
			{
				self.PriceYieldResultFrame.reloadProcessBar();
			}
		}
	}
}

//////////////////////////////////////////////////////////////////
function wasUpdated()
{
	self.document["updated"].src = "images/updated.gif";
	resetWaitingTask();
	setTimeout('stopWasUpdated()', iUpdatedMillliSeconds);
}
//////////////////////////////////////////////////////////////////
function wasUpdatedNN()
{
	self.document["updated"].src = "images/updated.gif";
	setTimeout('stopWasUpdated()', iUpdatedMillliSeconds);
}
//////////////////////////////////////////////////////////////////
function stopWasUpdated()
{
	self.document["updated"].src = "images/spacer.gif";
}

//////////////////////////////////////////////////////////////////
function AddTrancheToMyPortfolio( params, page, deal, tranche ) 
{
 if( self.page.indexOf("single_scenario") == -1 
     || (self.taskWasSent == 'no' 
	 || ( self.taskWasSent != 'no' && self.taskReady =='yes' ) ))
 {
   if (window.showModalDialog) 
   {
     var sReturn;  
	 var atp_url = "add_tranche_to_my_portfolio.jsp?pagerefresh=" + 10000 * Math.random();
	 atp_url += "&deal=" + deal + "&tranche=" + tranche;
     sReturn = showModalDialog(atp_url,"","center=yes;dialogWidth=340pt;dialogHeight=320pt;status=no");  
	
	 if (sReturn!="") 
	 {
  		if(sReturn!="farewell_for_parent") 
		{
			if( sReturn=="updated" )
			{
				self.wasUpdated();
			}
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }
	 else
	 {
		resetWaitingTask();
	 }
   }
   else if( gbNN6 )
   {
   	  var atp_url = "add_tranche_to_my_portfolio.jsp?" + "page=" + page + params
   	  atp_url += "&deal=" + deal + "&tranche=" + tranche;   
	  AddTrancheToMyPortfolio_NN( atp_url , 400, 400 );
   } 
   else
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   }
 }
 return true;
}
//////////////////////////////////////////////////////////////////
function ModifyTask_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}

//////////////////////////////////////////////////////////////////

function cutTaskDescription( text )
{
	description = text;
	if( description.length > 500 )
	{
		description = description.substring(0, 500 );
	}
	description = breakLongWords( description, 26 );
	return description;	
}

//////////////////////////////////////////////////////////////////

function breakLongWords( text, maxWordLength )
{
	var space = " ";
  	var wordsArray = text.split(space);
	var newText = "";
	for( var i = 0; i < wordsArray.length; i++ )
	{
		word = wordsArray[i];
		len = word.length;
		if( i != 0 )
		{
			newText += space;
		}
		
		if( len > maxWordLength )
		{
			var newWord = "";
			for( var j = 0; j < len; j+= maxWordLength )
			{
				if( j != 0 )
				{
					newWord += space;
				}
				newWord += word.substring( j, j + maxWordLength );
			}
			newText += newWord;
		}
		else
		{
			newText += word;
		}
	}
	return newText;
}

//////////////////////////////////////////////////////////////////

function ModifyTask_P(portfolio, task_id, page, params, refresh) 
{
  var url = "modify_task_p.jsp?id=" + task_id + "&portfolio="+ escape(portfolio) 
  			+ "&page=" + escape(page) ;
  if (window.showModalDialog) 
  {
    var sReturn;
    sReturn = showModalDialog(url,"","center=yes;dialogWidth=330pt;dialogHeight=270pt;status=no");
		
	if (sReturn!="") 
	{
  		if( sReturn != "farewell_for_parent" )
		{
			if( sReturn == "delete" )
			{
				/*			
				var portfolioname = newArray[1];
				var url = page + "?action=delete_p" + "&id=" + task_id + params 
							   + "&hist=no" + "&portfolio=" + escape(portfolio);
	   	   		window.document.location.replace( url );
				*/
			}
			else if( sReturn == "cancel" )
			{
				if(refresh == 'true')
				{
					window.refreshMe();
				}
			}
			else if( sReturn == "ok" )
			{
				window.refreshMe();	
			}
			else
			{
				/*
					var description = newArray[1];
			    	var url = page + "?action=modify_p" + "&description=" + escape(description) + "&id=" 
							   + task_id + params + "&hist=no" + "&portfolio=" + escape(portfolio);
	    	   		window.document.location.replace( url );
				*/
			}
		}
		else
		{
			parent.window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }	 
	 else
	 {
		if(refresh == 'true')
		{
		 	window.refreshMe();
		}
	 }
  } 
  else if( gbNN6 )
  {
	ModifyTask_NN( url + "&page=" + page, 400, 380 );
  }
  else  
  {
    alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
  }
}

//////////////////////////////////////////////////////////////////

function ModifyTask(task_id, page, params, refresh) 
{
  if (window.showModalDialog) 
  {
    var sReturn;  
    sReturn = showModalDialog("modify_task.jsp?id=" + task_id,"","center=yes;dialogWidth=330pt;dialogHeight=270pt;status=no");
		
	if (sReturn!="") 
	{
  		if(sReturn!="farewell_for_parent")
		{
	     	var newArray = sReturn.split("_!_!_!_!_!_!_!_!_!_");
			var action = newArray[0];

			if( action == "delete" )
			{			
				var portfolioname = newArray[1];
				var url = page + "?action=delete" + "&id=" + task_id + params + "&hist=no";
	   	   		window.document.location.replace( url );
			}
			else if( action == "cancel" )
			{
				if(refresh == 'true')
				{
					window.refresh();
				}
			}
			else
			{
				var description = newArray[1];
			    var url = page + "?action=modify" + "&description=" + escape(description) + "&id=" + task_id + params + "&hist=no";
	    	   	window.document.location.replace( url );
			}
		}
		else
		{
			parent.window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }	 
	 else
	 {
		if(refresh == 'true')
		{
			window.refresh();
		}
	 }
  } 
  else if( gbNN6 )
  {
	ModifyTask_NN( "modify_task.jsp?id=" + task_id + "&page=" + page, 400, 380 );
  }
  else  
  {
    alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
  }
}

//////////////////////////////////////////////////////////////////

function M(investment_id) 
{
	ModifyInvestment(investment_id);
}

//////////////////////////////////////////////////////////////////

function ModifyInvestment(investment_id) 
{
  if (window.showModalDialog) 
  {
    var sReturn;  
    sReturn = showModalDialog("modify_investment.jsp?id=" + investment_id,"","center=yes;dialogWidth=320pt;dialogHeight=330pt;status=no;scroll=yes;");
		
	if (sReturn!="") 
	{
  		if(sReturn!="farewell_for_parent")
		{
			
			if( sReturn=="updated" )
			{
				self.document.location.reload(true);
//				parent.wasUpdated();
			}
		}
		else
		{
			parent.window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }
  } 
  else if( gbNN6 )
  {
	UpdatePortfolio_NN( "modify_investment.jsp?id=" + investment_id, 400, 380 );
  }
  else 
  {
    alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
  }
}
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////

function D(investment_id) 
{
	deleteInvestment(investment_id) ;
}
//////////////////////////////////////////////////////////////////

function deleteInvestment(investment_id) 
{
	if( confirm("Do You really want to delete this Investment?") )
	{	
		var url = "my_portfolio.jsp?action=delete_investment"
									+ "&id=" + investment_id
 									+ "&hist=no&newparam=portfolio&newparamvalue=" 
									+ escape(self.portfolio_name);
		parent.window.document.location = url;
	}
}

//////////////////////////////////////////////////////////////////

function UpdatePortfolio_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}

//////////////////////////////////////////////////////////////////

function UpdatePortfolio() 
{

var pg = "";
if( gbNN6 )
{
	pg = self.getPage();
}
else
{
	pg = self.pagename  ;
}

 if( pg.indexOf("single_scenario") == -1 
     || (self.taskWasSent == 'no' 
	 || ( self.taskWasSent != 'no' && self.taskReady =='yes' ) ))
 {
   if (window.showModalDialog) 
   {
     var sReturn;  
	 var mp_url = "modify_portfolio.jsp?pagerefresh=" + 10000 * Math.random();
     sReturn = showModalDialog(mp_url,"","center=yes;dialogWidth=310pt;dialogHeight=300pt;status=no");

     if (sReturn !=null && sReturn!="" && sReturn!="undefined") 
	 {
		if(sReturn!="farewell_for_parent") 
		{
	     	var newArray = sReturn.split("_!_!_!_!_!_!_!_!_!_");
			var portfolioname = newArray[0];
			var description = newArray[1];
			var action = newArray[2];
			var url = self.pagename + "?portfolionewname=" + portfolioname 
								+ "&portfolionewdescription=" + description
								+ "&action=" + action
								+ "&hist=no&newparam=portfolio&newparamvalue=" + portfolioname;
       		redirect(url);
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }
	 else
	 {	
		if( self.pagename.indexOf("single_scenario") > -1 )
		{
			resetWaitingTask();
		}
	 }
   } 
   else if( gbNN6 )
   {
	 UpdatePortfolio_NN( "modify_portfolio.jsp?pagerefresh=" + 10000 * Math.random(), 400, 350 );
   }
   else  
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   }
 }
}

//////////////////////////////////////////////////////////////////

function AddNewPortfolio_NN( url, Dw, Dh )
{
	self.parentAlive = true;
	dialogOpenNN( url, Dw, Dh);
}


//////////////////////////////////////////////////////////////////

function acceptAgreement_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}

//////////////////////////////////////////////////////////////////

function acceptAgreement()
{
  if (window.showModalDialog)
  {  	
    var sReturn;  
	var winUrl = "confirm.jsp?pagerefresh=" + 10000 * Math.random();
    sReturn = showModalDialog(winUrl,"","center=yes;dialogWidth=655px;dialogHeight=580px;status=no");

    if (sReturn!="") 
	{		
		if( sReturn == "confirmed")
		{
			return true;
		}
		else
		{
			return false;
		}
    }
	else
	{
		return false;
	}
  } 
  else if( gbNN6 )
  {
  	acceptAgreement_NN( "login_nn_confirm.jsp?page=refresh", 620, 500 );
  }
  else
  {
	 alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required");
  }

  return false;
  
}

//////////////////////////////////////////////////////////////////

function AddNewPortfolio()
{
var pg = "";
if( gbNN6 )
{
	pg = self.getPage();
}
else
{
	pg = self.pagename  ;
}

 if( pg.indexOf("single_scenario") == -1 
     || (self.taskWasSent == 'no' 
	 || ( self.taskWasSent != 'no' && self.taskReady =='yes' ) ))
 {
   if (window.showModalDialog)
   {  	
     var sReturn;  
	 var ap_url = "add_new_portfolio.jsp?pagerefresh=" + 10000 * Math.random();
     sReturn = showModalDialog(ap_url,"","center=yes;dialogWidth=310pt;dialogHeight=290pt;status=no");

     if (sReturn!="") 
	 {		
		if(sReturn!="farewell_for_parent") 
		{
	     	var newArray = sReturn.split("_!_!_!_!_!_!_!_!_!_");
			var portfolioname = newArray[0];
			var description = newArray[1];
			var url = self.pagename + "?addportfolio=" + portfolioname 
								+ "&description=" + description
								+ "&hist=no&newparam=portfolio&newparamvalue=" + portfolioname;
       		redirect(url);
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }	
	 else
	 {	
		if( self.pagename.indexOf("single_scenario") > -1 )
		{
			resetWaitingTask();
		}
	 }	
   } 
   else if( gbNN6 )
   {
	 AddNewPortfolio_NN( "add_new_portfolio.jsp?pagerefresh=" + 10000 * Math.random(), 400, 350 );
   }
   else
   {
 	  alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required");
   }
 }
}

//////////////////////////////////////////////////////////////////

function SetRecoverySchedule_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh); 
}

//////////////////////////////////////////////////////////////////

function SetRecoverySchedule(in_params, check_use_schedule)
{
 if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
 {	 
   params = in_params;
   if(check_use_schedule == "check_use_schedule" ) 
   {
	 params +="&use_schedule=check";
   }
  
   if (window.showModalDialog) 
   {
     var sReturn;  
	 var srs_url = "set_recovery_schedule.jsp?pagerefresh=" + 10000 * Math.random();
     sReturn = showModalDialog(srs_url,"","center=yes;dialogWidth=200pt;dialogHeight=400pt;status=no");

	 if (sReturn!="") 
	 {
  		
		if(sReturn!="farewell_for_parent") 
		{
	     	var newArray = sReturn.split("_!_!_!_!_!_!_!_!_!_");
		    var url = self.page + "?hist=no&set_rs=yes" + sReturn + params;
	        self.document.location.replace(addSingleScenarioParamsToURL(url));
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
     }  
	 else
	 {
		resetWaitingTask();
	 }    
   } 
   else if( gbNN6 )
   {
 	 SetRecoverySchedule_NN( "set_recovery_schedule.jsp?params=yes" + params, 280, 480 );
   }
   else  
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   }
 }
}

//////////////////////////////////////////////////////////////////

function fillComments_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
}

//////////////////////////////////////////////////////////////////

function fillComments( )
{
 if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
 {	
   var curDescription = self.document.RunAnalysis.description.value;
	
   if (window.showModalDialog) 
   {
	 var sReturn;
	 var url = "fill_comments.jsp?description=" + escape(curDescription);
	 sReturn = showModalDialog( url ,"Fill Comments","center=yes;dialogWidth=330pt;dialogHeight=260pt;status=no");
	 if (sReturn!="") 
	 {
  		if(sReturn!="farewell_for_parent")
		{
		  	var newArray = sReturn.split("_!_!_!_!_!_!_!_!_!_");
			var action = newArray[0];
			var newDescription = newArray[1];
	    	self.document.RunAnalysis.description.value= newDescription;
			resetWaitingTask();
		}
		else
		{
			window.document.location.replace("login.jsp?pagerefresh=" + 10000 * Math.random());
		}
	 }
	 else
	 {
		resetWaitingTask();
	 }
	  
   }
   else if( gbNN6 )
   {
     var url = "fill_comments.jsp?description=" + escape(curDescription);
	 fillComments_NN( url, 360, 300 );
   } 
   else
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required");
   }
 }
}

//////////////////////////////////////////////////////////////////

function redirect (url)
{
  window.document.location=(url);
}

/////////////////////////////////////////////////////////////////

function redirectWithOneEncodedParam (urlWithParam, paramValue)
{	
  window.document.location=(urlWithParam + escape(paramValue));
}

/////////////////////////////////////////////////////////////////

function redirectWithTwoEncodedParams(url, param_1, paramvalue_1, param_2, paramvalue_2)
{	
  window.document.location=(url + "?" + param_1 + "=" + escape(paramvalue_1) + "&" + param_2 + "=" 
  + escape(paramvalue_2));
}

//////////////////////////////////////////////////////////////////

function runAnalysis(  result_Type )
{
  if( self.PriceYieldResultFrame )
  {
	var gourl = "process_bar_anal_frm.jsp";
	  
	if( result_Type == sLiabilities )
	{
	  gourl = "process_bar_frame.jsp";
	}
	else if( result_Type == sCollateral )
	{
	  gourl = 'process_bar_collateral_frame.jsp';
	}
	else if( result_Type == sHedge )
	{
	  gourl = 'process_bar_hedge_frame.jsp' ;
	}
	
	self.PriceYieldResultFrame.location.replace( gourl + '?pagerefresh=' + 10000 * Math.random() );
  }
    window.document.RunAnalysis.resultType.value = result_Type;
  	window.document.RunAnalysis.submit();
	
  	return true;
}

//////////////////////////////////////////////////////////////////

function disablePriceYield(active_field)
{
  if(self.taskResultType != self.sAnalytics )
  {

    if ( active_field == "yield")
    {
		document.RunAnalysis.discount_margin.disabled=true;
		document.RunAnalysis.discount_margin.style.backgroundColor="silver";	   
		document.RunAnalysis.discount_margin.style.color="silver";
		document.RunAnalysis.Price.disabled=true;	   
		document.RunAnalysis.Price.style.backgroundColor="silver";
		document.RunAnalysis.Price.style.color="silver";
		document.RunAnalysis.Yield.disabled=false;
		document.RunAnalysis.Yield.style.backgroundColor="white";	   
		document.RunAnalysis.Yield.style.color="black";
    }
	else if( active_field == "price" )
    {
		document.RunAnalysis.Price.disabled=false;
		document.RunAnalysis.Price.style.backgroundColor="white";
		document.RunAnalysis.Price.style.color="black";
		document.RunAnalysis.discount_margin.disabled=true;
		document.RunAnalysis.discount_margin.style.backgroundColor="silver";
		document.RunAnalysis.discount_margin.style.color="silver";
		document.RunAnalysis.Yield.disabled=true;
		document.RunAnalysis.Yield.style.backgroundColor="silver";
		document.RunAnalysis.Yield.style.color="silver";
    }
	else if( active_field == "dismarg" )
	{
		document.RunAnalysis.discount_margin.disabled=false;
		document.RunAnalysis.discount_margin.style.backgroundColor="white";	   
		document.RunAnalysis.discount_margin.style.color="black";
		document.RunAnalysis.Price.disabled=true;
		document.RunAnalysis.Price.style.backgroundColor="silver";
		document.RunAnalysis.Price.style.color="silver";
		document.RunAnalysis.Yield.disabled=true;
		document.RunAnalysis.Yield.style.backgroundColor="silver";
		document.RunAnalysis.Yield.style.color="silver";
	}
  }
   	return true;
}


//////////////////////////////////////////////////////////////////

function activatePriceYield(field)
{

  if(self.taskResultType != self.sAnalytics )
  {
    if ( field == "yield")
    {
	   document.RunAnalysis.discount_margin.disabled=false;
       document.RunAnalysis.discount_margin.style.backgroundColor="white";	   
       document.RunAnalysis.discount_margin.style.color="black";
   	   document.RunAnalysis.Price.disabled=true;	   
       document.RunAnalysis.Price.style.backgroundColor="silver";
       document.RunAnalysis.Price.style.color="silver";
    }

	if ( field == "price")
    {
	   document.RunAnalysis.Price.disabled=false;
       document.RunAnalysis.Price.style.backgroundColor="white";
       document.RunAnalysis.Price.style.color="black";
   	   document.RunAnalysis.discount_margin.disabled=true;
       document.RunAnalysis.discount_margin.style.backgroundColor="silver";
       document.RunAnalysis.discount_margin.style.color="silver";
    }
  }
   	return true;
}


//////////////////////////////////////////////////////////////////

function activatePriceYieldSpread(field)
{

  if(self.taskResultType != self.sAnalytics )
  {
    if ( field == "yield")
    {
	   document.RunAnalysis.Yield.disabled=false;
       document.RunAnalysis.Yield.style.backgroundColor="white";
       document.RunAnalysis.Yield.style.color="black";

   	   document.RunAnalysis.Price.disabled=true;
       document.RunAnalysis.Price.style.backgroundColor="silver";
       document.RunAnalysis.Price.style.color="silver";

       document.RunAnalysis.Spread.disabled=true;
       document.RunAnalysis.Spread.style.backgroundColor="silver";
       document.RunAnalysis.Spread.style.color="silver";

       document.RunAnalysis.Bench.disabled=true;
       document.RunAnalysis.Bench.style.backgroundColor="silver";
       document.RunAnalysis.Bench.style.color="silver";
    }
	else if ( field == "price")
    {
	   document.RunAnalysis.Price.disabled=false;
       document.RunAnalysis.Price.style.backgroundColor="white";
       document.RunAnalysis.Price.style.color="black";

   	   document.RunAnalysis.Yield.disabled=true;
       document.RunAnalysis.Yield.style.backgroundColor="silver";
       document.RunAnalysis.Yield.style.color="silver";

       document.RunAnalysis.Spread.disabled=true;
       document.RunAnalysis.Spread.style.backgroundColor="silver";
       document.RunAnalysis.Spread.style.color="silver";

       document.RunAnalysis.Bench.disabled=true;
       document.RunAnalysis.Bench.style.backgroundColor="silver";
       document.RunAnalysis.Bench.style.color="silver";
    }
	else if ( field == "spread")
    {
	   document.RunAnalysis.Spread.disabled=false;
       document.RunAnalysis.Spread.style.backgroundColor="white";
       document.RunAnalysis.Spread.style.color="black";

       document.RunAnalysis.Bench.disabled=false;
       document.RunAnalysis.Bench.style.backgroundColor="white";
       document.RunAnalysis.Bench.style.color="black";	   

   	   document.RunAnalysis.Yield.disabled=true;
       document.RunAnalysis.Yield.style.backgroundColor="silver";
       document.RunAnalysis.Yield.style.color="silver";

   	   document.RunAnalysis.Price.disabled=true;
       document.RunAnalysis.Price.style.backgroundColor="silver";
       document.RunAnalysis.Price.style.color="silver";
	}
  }
	return true;
}

//////////////////////////////////////////////////////////////////

function activatePriceYieldPortfolioTask(field)
{
//	alert("666:" + field);

  if(self.taskResultType != self.sAnalytics )
  {
    if ( field == "yield")
    {
	   document.RunAnalysis.Yield.disabled=false;
       document.RunAnalysis.Yield.style.backgroundColor="white";
       document.RunAnalysis.Yield.style.color="black";

   	   document.RunAnalysis.Price.disabled=true;
       document.RunAnalysis.Price.style.backgroundColor="silver";
       document.RunAnalysis.Price.style.color="silver";
    }
	if ( field == "price")
    {
	   document.RunAnalysis.Price.disabled=false;
       document.RunAnalysis.Price.style.backgroundColor="white";
       document.RunAnalysis.Price.style.color="black";

   	   document.RunAnalysis.Yield.disabled=true;
       document.RunAnalysis.Yield.style.backgroundColor="silver";
       document.RunAnalysis.Yield.style.color="silver";
    }
  }
	return true;
}
		
//////////////////////////////////////////////////////////////
function getUrlParamVal( param )
{
	var queryString = self.document.location.search.substring(1);
	var qryStrPairs = queryString.split("&");
	for( var i = 0; qryStrPairs.length>i; i++ )
	{
		var posn = qryStrPairs[i].indexOf('=');
		if( qryStrPairs[i].substring(0, posn)==param)
		{
			return unescape( qryStrPairs[i].substring(posn + 1) ) ;
		}
	}
	return null;
}
//////////////////////////////////////////////////////////////////

function setIssuerDefaultsButton( ready )
{
	if( ready )
	{
		changeImages('issuer_defaults', 'images/button_choice.gif' );
	}
	else
	{
		changeImages('issuer_defaults', 'images/button_choice_not_ready.gif' );
	}
}
//====================================================//
function setIssuersArrayNN( arrIssuerDefaultsArray )
{
	if( arrIssuerDefaultsArray != null )
	{
		if( arrIssuerDefaultsArray[0] == "blank" )
		{
				// it means that there was no saved issuer defaults schedule
				// and if it has ever been, it was erased 
			setIssuerDefaultsButton( false );
			self.issuerDefaultsReady = "no";
			self.document.RunAnalysis.use_issuer_defaults.checked = false;
			self.arrIssuerDefaults = null;
		}
		else if( arrIssuerDefaultsArray[0] != "notloaded" )
		{
					//it means that there was some saved issuer defaults schedule
				setIssuerDefaultsButton( true );
				self.issuerDefaultsReady = "yes";
				self.arrIssuerDefaults = arrIssuerDefaultsArray;			
		}
		else
		{
					//it means that nothing was changed, so do nothing
		}
	}
}
//////////////////////////////////////////////////////////////////

function checkUseIssuerDefaults() 
{
//	alert(self.issuerDefaultsReady);
	if( self.issuerDefaultsReady != "yes" )
	{
		var chk = self.document.getElementById("use_issuer_defaults");
		if( chk )
		{
			chk.checked = false;
			//alert( self.issuerDefaultsReady );
			if( confirm("Please, set up Issuer Defaults Schedule first.") )
			{
				SetIssuerDefaults( getPortfolioAndDealTrancheUrlParams(), 'check_use_schedule' );
			}
		}
		else
		{
			//alert("Attention: use_issuer_defaults NOT FOUND.");
		}
	}
}
	
//////////////////////////////////////////////////////////////////

function SetIssuerDefaults( in_params, check_use_schedule )
{
	if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
	{
		if (window.showModalDialog)
		{
			var sReturn;
			var srs_url = "set_issuer_defaults.jsp?pagerefresh=" + 10000 * Math.random();

			if( self.page.indexOf("portfolio_single_scenario") > -1 )
			{
				srs_url += "&portfolio=" + escape(self.sPortfolio);
			}
			else
			{
	 			srs_url += "&deal=" + escape(self.sDeal) + "&tranche=" + escape(self.sTranche);
			}

			sReturnArray = showModalDialog ( srs_url, "",
									"center=yes;dialogWidth=555pt;dialogHeight=363pt;status=no" );

			if( sReturnArray != null )
			{
				if( sReturnArray[0] != "blank" )
				{
					if( sReturnArray[0] != "farewell_for_parent" )
					{				
						if(sReturnArray[0] !="notloaded" )
						{
							self.arrIssuerDefaults = sReturnArray;

							setIssuerDefaultsButton( true );
							issuerDefaultsReady = "yes";
							if( check_use_schedule == "check_use_schedule" ) 
							{
								// self.document.RunAnalysis.use_issuer_defaults.checked = true;
								/* uncomment when the same logic will be implemented for 
								   set recovery schedule, otherwise it's partial decision 
									   and will be "belmo na glazu" */
							}
						}
						else
						{
							// do nothing, it means that popup screen SetIssuerDefaults was closed before
							// the IFrame with issuers list was fully loaded.
							// so there is no change in the current status of the issuers.
						}
					}
					else
					{
						window.document.location.replace( "login.jsp?pagerefresh=" + 10000 * Math.random() );
					}
				}
				else
				{
					// alert("blank, You  know");
					self.arrIssuerDefaults = new Array(1);
					self.document.RunAnalysis.use_issuer_defaults.checked = false;
					setIssuerDefaultsButton( false );
					self.issuerDefaultsReady = "no";
					//alert(issuerDefaultsReady);
				}
			}
			resetWaitingTask();
		}
		else if( gbNN6 )
		{
			var urlWin = "set_issuer_defaults.jsp?pagerefresh=" + 10000 * Math.random() + "&params=yes" + in_params
			if( self.getPage().indexOf("portfolio_single_scenario") > -1 )
			{
				urlWin += "&portfolio=" + escape(self.getPortfolio());
			}
			else
			{
	 			urlWin += "&deal=" + escape(self.sDeal) + "&tranche=" + escape(self.sTranche);
			}
			SetIssuerDefaults_NN( urlWin, 720, 420 );
		}
		else
		{
			alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
		}
  	}
}
//////////////////////////////////////////////////////////////////

function SetIssuerDefaults_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh); 
}
/////////////////////////////////////////////////////////////////
function setIssuersArrayNN22( arrIssuerDefaultsArray )
{
		//	setIssuerDefaultsButton( arrIssuerDefaultsArray != null );
	if( arrIssuerDefaultsArray == null )
	{
			// it means that there was no saved issuer defaults schedule
			// and if it has ever been, it was erased 
		setIssuerDefaultsButton( false );
		self.document.RunAnalysis.use_issuer_defaults.checked = false;
		self.issuerDefaultsReady = "no";
		arrIssuerDefaults = null;
	}
	else
	{
		if( arrIssuerDefaultsArray.length > 0 )
		{
				//it means that there was some saved issuer defaults schedule
			setIssuerDefaultsButton( true );
			self.issuerDefaultsReady = "yes";
			arrIssuerDefaults = arrIssuerDefaultsArray;			
		}
		else
		{
				//it means that nothing was changed, so do nothing
		}
	}

}
/////////////////////////////////////////////////////////////////
function showIssuers()
{
	if( self.arrIssuerDefaults != null )
	{
		row_num = self.arrIssuerDefaults.length -1;
		if(row_num > 30)
		{
			 row_num = 31;
		}
		if( row_num > 0)
		{
			if(document.RunAnalysis.use_issuer_defaults.checked )
			{
				issDetails( row_num );
			}
		}
	}
}
/////////////////////////////////////////////////////////////////
function getDetHTML()
{
	html = "<html><head><LINK href='cdostyles.css?v=1' rel='STYLESHEET' type='text/css'/></head><body marginwidth='0' marginheight='0'></body>"
	+ "<table class='exptable' cellpadding='0' cellspacing='2' width='540'><tr><td width='540' height='1%' class='exptop' colspan='3'>&#160;&#160;Issuer Defaults Schedule</td></tr>"
	+ "<tr><td width='360' class='expheader'>&#160;&#160;Issuer</td><td width='90' class='expheader' align='right'>Default Month</td><td width='90' class='expheader' align='right'>Recovery Rate</td></tr>";
	len = arrIssuerDefaults.length > 31 ? 31 : arrIssuerDefaults.length;
	for( var i=1; i < len; i++ )
	{
		html+="<tr><td bgcolor='#ffffff' class='s'>" + arrIssuerDefaults[i][2] ;
		html+="</td><td bgcolor='#ffffff' class='j' align='right'>" + arrIssuerDefaults[i][0] ;
		html+="</td><td bgcolor='#ffffff' class='s' align='right'>" + arrIssuerDefaults[i][1] ;
		if(arrIssuerDefaults[i][1]!='')
		{
			html+= " %";
		}
		html+="</td></tr>";
	}
	if( arrIssuerDefaults.length > 31 )
	{
		html += "<tr><td width='540' height='1%' colspan='3' bgcolor='#ffffff' class='s'>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;More...</td></tr>"
	}
	html += "</table></body></html>"; 
	return html;
}
/////////////////////////////////////////////////////////////////
function fillOtherRecRate()
{
	var rrType = window.document.RunAnalysis.recratetype;
	if( rrType && rrType.value == "rr_invest_type" )
	{
		var rrOther = self.document.getElementById("rr_other");
		if( rrOther && rrOther.value == "" )
		{
			var fld;
			var arr = new Array( "rr_emsovrn", "rr_emcorp", "rr_bankloan", "rr_absmbscdo", "rr_highyield", "rr_ivestgrade" );
			for(var i = 0; i < arr.length; i++ )
			{
				fld = self.document.getElementById( arr[i] );
				if( fld && fld.value == "" )
				{
					rrOther.value = "0.0";
					break;
				}
			}
		}
	}
}
/////////////////////////////////////////////////////////////////
function issDetails(row_num)
{
  if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
  {
	var shift=row_num*16;
	var y_mouse=self.ymouse;
	var dtl=self.document.getElementById("detailsFrame");
	width=525;
	var sHeight=(row_num+2)*16+4;
	var stl=dtl.style;
	var sTop = y_mouse+self.yShift-shift  ; 
	if( 10>sTop)
	{
		sTop = 10;
	}
	stl.top=sTop;
	stl.left=xmouse+self.xShift;
	stl.height=sHeight ;
	stl.width = 540;
	var newHtml=self.getDetHTML();
	self.writeDetails(newHtml);
	stl.visibility='visible';	
	str='';
   }
	
	return true;	
}
/////////////////////////////////////////////////////////////////
function writeDetails(strHTML)
{
	self.document.getElementById("detailsFrame").document.open();
	self.document.getElementById("detailsFrame").document.write(strHTML);
	self.document.getElementById("detailsFrame").document.close();
}
//==============//
function hideIssuers()
{
	if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
	{
		self.document.getElementById("detailsFrame").style.visibility = 'hidden';
	}
	return true;		
}
//==============//
function replaceString( origStr, oldTxt, newTxt )
{
	str = origStr;
//	alert(str +":"+ oldTxt+":"+  newTxt );
	var pos = 0;
	var len = oldTxt.length;
	pos = str.indexOf( oldTxt );
	while( pos != -1 )
	{
		var preStr = str.substring( 0, pos );
		var postStr = str.substring( pos + len, str.length );
		str = preStr + newTxt + postStr;
		pos = str.indexOf( oldTxt );
	}
	return str;
}
//=========
function Select_Date( targetName, page )
{
	var elTarget = window.document.getElementById("settle_cal") ;
	
	if( self.showModalDialog )
	{
		var urla = "calendar.jsp?default=" + escape( self.default_settlement );

		var sRtn = self.showModalDialog(urla,  "","center=yes;dialogWidth=195pt;dialogHeight=190pt;status=no");		
		if( sRtn != "" )
		{
			elTarget.value = sRtn;
		}
	}
	else
	{
		var _url = "calNNfull.jsp?target=" + targetName + "&default=" + escape( self.default_settlement ) ;
		if( page )
		{
			_url += "&page=" + escape(page);
		}
		dialogOpenNN( _url , 250, 200, true ); 
	}
}
//======//
function stripDescription()
{
	var taskDescription = stripCharsInBag( window.document.RunAnalysis.description.value, '">');
	window.document.RunAnalysis.description.value = breakLongWords( taskDescription, 45 ); // cut it for good pdf view
	stripParams()	;
}
//======//
function stripParams()	
{
	var bag = "123.4567890";
	ssForm = window.document.RunAnalysis;
	arrElements = ssForm.elements;
	len = arrElements.length;
	var paramName = "";
	var paramVal = "";

	for( i=0; len>i; i++ )
	{
//		paramName = arrElements[i].name;
		paramVal = arrElements[i].value;
		if(arrElements[i].type!= "hidden")
		{
			if( arrElements[i].type.indexOf( "select" ) == -1 && arrElements[i].type!="checkbox" 
				&& arrElements[i].type !="radio" && arrElements[i].name!="settle_cal" 
				&& arrElements[i].name!="description" && arrElements[i].name!="Bench" )
			{
				arrElements[i].value= stripCharsNotInBag ( paramVal, bag);
			}
		}
	}
}
function openEconomyPopup( params, page )
{
	var url = page + "?hist=no&open_economy=true" + params;
	redirect(addSingleScenarioParamsToURL(url));// do not need to replace location  and erase history
}

function openEconomy( params, page)
{
  if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
  {
   if (window.showModalDialog) 
   {
     var sReturn = "";  
	 
	 var ecnmy_url = "economypopup.jsp?pagerefresh=" + 10000 * Math.random();
 
	 sReturn = showModalDialog(ecnmy_url,"","center=yes;dialogWidth=815px;dialogHeight=580px;status=no;scroll=no;help=no;");  
	
	
	 if (sReturn != "" && sReturn != "undefined" ) 
	 {
  		if(sReturn != "farewell_for_parent") 
		{
			if( sReturn.indexOf("load:") > -1  )
			{
				var ecoID = sReturn.substring( 5 );
				//alert( ecoID );
				var url = page + "?hist=no&economy=" + ecoID + params;
				redirect( addSingleScenarioParamsToURL(url) );
			}
			else if( sReturn.indexOf("delete:") > -1  )
			{
				var ecoID = sReturn.substring( 7 );
				var url = page + "?hist=no&delete_eco=" + ecoID + params;
				redirect( addSingleScenarioParamsToURL(url) );
			}
			else if( sReturn.indexOf("save:") > -1 )
			{
				var ecoName = sReturn.substring( 5 );
				//alert( ecoName );
				var url = page + "?hist=no&save_eco=" + ecoName + params;
				redirect( addSingleScenarioParamsToURL(url) );
			}
		}
		else
		{
			window.document.location.replace("login.jsp?logout=true&pagerefresh=" + 10000 * Math.random());
		}
     }
	 else
	 {
		resetWaitingTask();
	 }
   }
   else if( gbNN6 )
   {
   	  var ecnmy_url = "economypopup.jsp?skip=it" + params
	  openEconomy_NN( ecnmy_url , "815px", "530px" );
   } 
   else
   {
     alert("Netscape Navigator 6.0 or later, Internet Explorer 4.0 or later are required")
   }
 }
 return true;
}
//====//
function openEconomy_NN( url, Dw, Dh )
{
	dialogOpenNN( url, Dw, Dh);
	return true;
}
//====//
function disableIt( objID, yesno )
{
	var obj = self.document.getElementById( objID );
	if( obj )
	{
		obj.disabled = yesno;
		obj.style.backgroundColor = yesno ? "silver" : "white";
	}
}
//====//

//======//

function stl_cal()
{
	if( self.taskWasSent == 'no' || (self.taskWasSent != 'no' && self.taskReady =='yes') )
	{
		Select_Date( "settle_cal" );
	}
}




/////////////////bival//////////////////////////////////////
	function setRows(){

		rows = window.ResultFrame.document.getElementById('table').rows.length;
		return window.ResultFrame.document.getElementById('table').rows.length;
	}
	function initPage(document){
	
	var From=sFrom
	var To=0;
	setRowNumbers();
	setRows();

	hideAll();
	To=(rowNumner>rows)?rows:rowNumner;
	showRows(From,To);	
	}
function initPageBody(){
	var From=sFrom
	var To=0;
	//setRows();
	hideAllBody();
	To=(rowNumner>rows)?rows:rowNumner;
	showRowsBody(From,To);	
	//hideColumn()
	
	}
	function setRowNumbers(){
	 	rowNumner=parseInt(document.getElementById('row_in_a_page').value);
		return parseInt(document.getElementById('row_in_a_page').value);
	}
	function hideAll(){

		for(i=0;i<rows;i++){
			
			window.ResultFrame.document.getElementById('row'+i).style.display="none";
			
		}

	}
function hideAllBody(){
	var i=0;

		for(i=0;i<rows;i++){

			if(document.getElementById('row'+i)!=null){
				document.getElementById('row'+i).style.display="none";
				}

		}
	}
	function showRows(From,To){ 	
		for(i=From;i<To;i++){
		window.ResultFrame.document.getElementById('row'+i).style.display="";	
		}
	SFast=From
	SLast=i;
	}
function showRowsBody(From,To){
	 	
		for(i=From;i<To;i++){
		document.getElementById('row'+i).style.display="";	
		}
	SFast=From
	SLast=i;
	}
	
	function nextPage(document){

		var from = 0;
		var to = 0;
		if(SLast>=rows){
			return;
		}
		
		from=SLast;
		to=(SLast+rowNumner)>rows?rows:(SLast+rowNumner);
		hideAll();
	
		showRows(from,to)

	}
	function previousPage(document){
		var from = 0;
		var to = 0;
		if(SFast<=0){
			return;
		}
		to=SFast;
		from=(SFast-rowNumner)<=0?0:(SFast-rowNumner);
		hideAll();
		showRows(from,to)
	}
	
	
	function onRowNumChange(){

	 var from;
		var to;
		var str=null;
	
		setRowNumbers();
		
		from=SFast;
		to=(SFast+rowNumner)>rows?rows:(SFast+rowNumner);

			hideAll();
			showRows(from,to);
			str=rowNumner;
	var temp=window.location.search;
	var temploc=(temp.indexOf("rows")==-1)?temp+"Q":temp.substring(0,temp.indexOf("rows"));
	
	var string=(window.location.search==null)?("?rows="+str):(temploc.slice(0,-1)+"&rows="+str);
	document.getElementById('myTypesForm').action="tranche_valuation_list.jsp"+string;
	document.getElementById('myTypesForm').submit();

			
	}
	
	function hideColumn(){
		for(i=0;i<rows;i++){
			document.getElementById("data"+i+"3").style.display="none";
		}
	}
	


////////////////////////////////////////////////////////////

