function ChangeTabsSix(form, tab)
{
    try
    {
	$('First').className = (tab == 'First' ? 'tabOn' : 'tabOff');
	$('Second').className = (tab == 'Second' ? 'tabOn' : 'tabOff');
	$('Third').className = (tab == 'Third' ? 'tabOn' : 'tabOff');
	$('Fourth').className = (tab == 'Fourth' ? 'tabOn' : 'tabOff');
	$('Fifth').className = (tab == 'Fifth' ? 'tabOn' : 'tabOff');
	$('Sixth').className = (tab == 'Sixth' ? 'tabOn' : 'tabOff');
	
	$('tabFirst').className = (tab == 'First' ? 'selected' : '');
	$('tabSecond').className = (tab == 'Second' ? 'selected' : '');
	$('tabThird').className = (tab == 'Third' ? 'selected' : '');
	$('tabFourth').className = (tab == 'Fourth' ? 'selected' : '');
	$('tabFifth').className = (tab == 'Fifth' ? 'selected' : '');
	$('tabSixth').className = (tab == 'Sixth' ? 'selected' : '');
	$('TabName').value=tab;
	CheckTab(tab);
		
	}
	catch(err)
	{
	}
	
	
}

function CheckTab(tab)
{
	var browsertype=window.navigator.userAgent;
		 if(browsertype.indexOf("MSIE 6.0")>=0)
		 {
			 var tabObj=$('tab'+tab);
			 $('tabFirst').style.height="27px";
			 $('tabFirst').style.borderBottom="0px solid #F0F0F0";
			 $('tabSecond').style.height="27px";
			 $('tabSecond').style.borderBottom="0px solid #F0F0F0";
			 $('tabThird').style.height="27px";
			 $('tabThird').style.borderBottom="0px solid #F0F0F0";
			 $('tabFourth').style.height="27px";
			 $('tabFourth').style.borderBottom="0px solid #F0F0F0";
			 $('tabFifth').style.height="27px";
			 $('tabFifth').style.borderBottom="0px solid #F0F0F0";
			 tabObj.style.height='27px';
			 tabObj.style.borderBottom='3px solid #F0F0F0';
		 }
}

/*************** ProductScan Page Javascript ********************/
// To Calculate Portfolio Weight
function CalcPortfolioPercentage()
{
	var elements = document.getElementsByTagName("INPUT");
	var totalpercentage = 0;
	var formattedNum = 0;
	
	for(var l=0;l<elements.length;l++)
	{
		if((IsTextBox(elements[l]) == true) && (elements[l].name == 'PortfolioPercentage') && (elements[l].value != ''))
		{
			if(checkNumeric(elements[l],0,100) == true)
			{			    
				totalpercentage += eval(elements[l].value);
				elements[l].value = eval(roundNumber(elements[l].value,"2"));
			}
		}
	}
	document.getElementById('total').value = eval(roundNumber(totalpercentage,"2"));
}

// Return true if argument is input textbox
function IsTextBox(txt)
{
	return (txt.type == 'text');
}


// To Check Numeric value in text input
function checkNumeric(objName,minval, maxval)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval)
{
	// only allow 0-9 be entered, plus any values passed
	var checkOK = "0123456789" + ".";
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	var returnVal = "";
	document.getElementById('ValidValues').value = '0';
	
	for (i = 0;  i < checkStr.value.length;  i++)
	{
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
		{
		   if(!StringContains(allNum,ch,'.'))
		   {
				allNum += ch;
			}
			else
			{
				allValid = false;
				break;
			}
		}
	}
	if (!allValid)
	{	
		DisplayWarningMsg("WeightingWarning", "Numeric values must be entered");
		return (false);
	}

	// set the minimum and maximum
	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	if (chkVal != "" && !(prsVal > minval && prsVal <= maxval))
	{
		DisplayWarningMsg("WeightingWarning", "Percentage value must be within 1-100");
		return (false);
		
	}
	else
	{
	DisplayWarningMsg("WeightingWarning", "");
	}
	document.getElementById('ValidValues').value = '1';
	return (true);
}

function StringContains(value, addChar, checkChar)
{
   var ch ="";
   var allValid = false;
	for (i = 0;  i < value.length;  i++)
	{
		ch = value.charAt(i);
		if(ch == checkChar && addChar == checkChar)
		{
			allValid = true;
		}
	}
	
	return allValid;
}

function roundNumber(num, dec) 
{
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}


// Validating fund weight and redirecting to portfolio pdf
function ViewPortfolio(url)
{
	var shortlist= document.getElementById("typecodelist").value;
	var shortlistArr = shortlist.split(',');
	
	var weight = '';
	var elements = document.getElementsByTagName("INPUT");
	var isvalid = 1;
	var weightingWarning = "";
	var ss ='';
	var arrCount =0;
	
		/* Span Clculation */
	var spanSelectedindex=document.MainForm.DurationMonths.selectedIndex;
	var span = document.MainForm.DurationMonths.options[spanSelectedindex].value;
	var timeSpan= document.getElementById("Month").value;
	var fundNameList= document.getElementById("FundName").value;
	var spanValue = eval(span);
	var fundSpan = new Array();
	var fundname = new Array();
	fundSpan = timeSpan.split(",");
	fundname = fundNameList.split(",");
	var errorFund = "";
	
	for(var l=0;l<elements.length;l++)
	{
		if((IsTextBox(elements[l]) == true) && (elements[l].name == 'PortfolioPercentage'))
		{
			if(elements[l].value != '')
			{
				if(checkNumeric(elements[l],0,100) == true)
				{
					weight = (weight != '' ? (weight + ',') : '');
					weight += elements[l].value;
					ss += (ss.length == 0)? shortlistArr[arrCount]:","+shortlistArr[arrCount];
					var fS = eval(fundSpan[arrCount])
					if(fS < spanValue)
					{
						errorFund += "<br/>"+fundname[arrCount];
					}
				}
				else
				{
					isvalid = 0;
					weightingWarning = "Numeric values must be entered<br/>";
				}
			}
			
			arrCount++;
			
		}
	}
	
	//
	var benchmarkWarning = "";
	var spanWarning = "";
	if(document.MainForm.total.value > 100 || document.MainForm.total.value < 100)
	{
		isvalid = 0;
		weightingWarning = "Weightings should add up to 100 exactly<br/>";
	}
	
	var selectedindex=document.MainForm.Indices.selectedIndex;
	var benchmark='';
	var benchmarkOption ='';
	if(selectedindex == 0)
	{
		selectedindex=document.MainForm.Sectors.selectedIndex;
		benchmarkOption = document.MainForm.Sectors;// .options[selectedindex].value;
	}
	else
	{
		benchmarkOption = document.MainForm.Indices;
	}
	
	if(selectedindex == 0)
	{
		isvalid = 0;
		benchmarkWarning ="Please select a benchmark.";
	}
	/* Span Clculation */
	/*
	var spanSelectedindex=document.MainForm.DurationMonths.selectedIndex;
	var span = document.MainForm.DurationMonths.options[spanSelectedindex].value;
	var timeSpan= document.getElementById("Month").value;
	var fundNameList= document.getElementById("FundName").value;
	var spanValue = eval(span);
	var fundSpan = new Array();
	var fundname = new Array();
	fundSpan = timeSpan.split(",");
	fundname = fundNameList.split(",");
	var errorFund = "";
	for(t=0;t<fundSpan.length;t++)
	{
	   var fS = eval(fundSpan[t])
		if(fS < spanValue)
		{
			
			errorFund += "<br/>"+fundname[t];
		}
	}
	*/
	if(errorFund.length>0)
	{
		isvalid = 0;
		spanWarning += "<br/>The following fund(s) don't have enough historical data for the time span chosen:" + errorFund;
	}
	
	
	if(isvalid == 1 && document.MainForm.total.value == 100)
	{
		benchmark = benchmarkOption.options[selectedindex].value;
		var benchmarktext = URLEncode(benchmarkOption.options[selectedindex].text);
		
		
	    window.open(url + "?typecodes=" + ss + "&weights=" + weight + "&timespan=" + span + "&benchmark=" + benchmark + "&benchmarkname=" + benchmarktext+ "&FundRangeCode="+ $('HDFundRangeCode').value,"Portfolio")
	}
	DisplayWarningMsg("WeightingWarning", weightingWarning);
	DisplayWarningMsg("SpanWarning", spanWarning);
	DisplayWarningMsg("BenchmarkWarning",benchmarkWarning);
	return false;
}

function URLEncode(value)
{
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
}

function DisplayWarningMsg(id, text)
{
	var obj = document.getElementById(id);
	//obj.firstChild?obj.firstChild.data=text:obj.appendChild(document.createTextNode(text))
	obj.innerHTML = text;
}

function ResetMenu(ctrl)
{
	document.getElementById(ctrl).selectedIndex = 0;
}

function GotoShortListPage()
{
	var shortListedTypeCode = $("Typecodelist");
	window.location ="shortlist.aspx?ShortListedTypeCodes="+shortListedTypeCode.value;
}

/*************** End ProductScan Page ********************/

function loadFlt(url,height,width,scrollbars)
{
	var browser = navigator.appName + " " + navigator.appVersion; 
    	var Newwindow = window.open(url,"choose","resizable=no,height=" + height + ",width=" + width + ",scrollbars=" + scrollbars + ",top=5,left=200");
	
      	if ( browser.substring(0, 8) =="Netscape") 
      	{ 
        	Newwindow.creator = self; 
      	}
        else 
	{
          	if (Newwindow.opener == null) 
          	{
			Newwindow.opener = self;
		} 
      	} 
	
}


function showhide(id){ 
                if (document.getElementById){ 
                                obj = document.getElementById(id); 
                                if (obj.className.indexOf("displayNone") > -1){ 
                                                obj.className = obj.className.replace("displayNone", ""); 
                                } else { 
                                                obj.className = "displayNone";
                                } 
                } 
}
 

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

if (window.addEventListener) //DOM method for binding an event
window.addEventListener("load", externalLinks, false);
else if (window.attachEvent) //IE exclusive method for binding an event
window.attachEvent("onload", externalLinks);
else if (document.getElementById) //support older modern browsers
window.onload=externalLinks;

function ProductTypeChange(obj)
{
  $('ProductType').value=obj.value;
  //$('ShortListedTypeCodes').value="";
  $('RangeName').value="";
  $('FundRangeCode').value="";
  $('ManagerGroup').value="";
  $('SectorCode').value="";
  $('CrownRating').value="";
  $('TabName').value="";
  $('PageIndex').value="";
  //$('PreviousUniv').value="";
  document.forms[0].submit();
}
function ProductCodeChange(obj)
{
   $('RangeName').value=obj.text;
   $('FundRangeCode').value=obj.value;
   if(obj.value.toUpperCase() == 'WOM' || obj.value.toUpperCase() == 'WOMA' || obj.value.toUpperCase() == 'WOM0' || obj.value.toUpperCase() == 'WOMC')
   {
       $('ManagerGroup').value= '';
       $('SectorCode').value = '';
       $('CrownRating').value= '';
       $('AlphaManagerRating').value = '';
       $('OBSRRating').value= ''; 
   }
   document.forms[0].submit();
}
function ManagerChange(obj)
{
  $('ManagerGroup').value=obj.value;
  document.forms[0].submit();
}
function SectorChange(obj)
{
  $('SectorCode').value=obj.value;
  document.forms[0].submit();
}
function CrownRatingChange(obj)
{
  $('CrownRating').value=obj.value;
  document.forms[0].submit();
}
function AlphaManagerRatingChange(obj)
{
  $('AlphaManagerRating').value=obj.value;
  document.forms[0].submit();
}
function OBSRRatingChange(obj)
{
  $('OBSRRating').value=obj.value;
  document.forms[0].submit();
}

function SetPageIndex(no)
{
$('PageIndex').value=no;
document.forms[0].submit();
}

function $(id)
{
   return document.getElementById(id);
}

function Sort(sortColumn,direc)
{
	if($('SortColumn').value==sortColumn)
	{
		if(direc=="ASC")
		{
		direc="DESC";
		}
		else
		{
		direc="ASC";
		}

	}
$('SortDirection').value=direc;
$('SortColumn').value=sortColumn;
document.forms[0].submit();
}

function SelectAll(obj)
{
	var items=document.getElementsByTagName('input'); 
	for(i=0;i<items.length;i++)
    {
       if(items[i].type=='checkbox')
       {
		 if(obj.checked)
	     {
         items[i].checked=true;
         }
         else
         {
         items[i].checked=false;
         }
       }
    }
}

function SelectInstrument(id,obj)
{

 var tabIds=new Array();
 tabIds="Prices,PerformanceCumMonths,PerformanceCumYears,PerformanceDiscrete,TableRisk,TableRatings".split(',');
 for(i=0;i<tabIds.length;i++)
 {
   var objChk=$(tabIds[i]+obj.value);
   if(objChk!=null && objChk.type=='checkbox')
   {
	   if($(id).checked)
	   {
	   objChk.checked=true;
	   }
	   else
	   {
	   objChk.checked=false;
	   }
   }
  }
}

function SelectDefault()
{
if($('ItemsPerPageCB')!=null && $('ItemsPerPage')!=null){
$('ItemsPerPageCB').value=$('ItemsPerPage').value;}
}

function UpdateToShortList(chk)
{
    var shortListedCodes=GetShortListedCodes(true);
    var shortListedCount=0;
    var totalText="[count total shortlist]";
    var tmpText;
    var previousCount=0;
    var prevoiusSortListed='';
    var previousUniv=$('PreviousUniv').value;
    var univ='';
    prevoiusSortListed=$('ShortListedTypeCodes').value;
    
    if(shortListedCodes=="" && prevoiusSortListed=="" && chk==1)
    {
       $('WarningLabel').innerHTML="<b>Please select funds for your shortlist and click 'Update shortlist' before going to 'View shortlist'.</b>";
	    $('WarningLabel').style.display="block";
	    return;
    }
    
    if(shortListedCodes=="")
    {
      shortListedCount=shortListedCodes.split(',').length-1;
    }
    else
    {
      shortListedCount=shortListedCodes.split(',').length;
    }
    
    if(shortListedCount>20)
    {
		prevoiusSortListed=$('ShortListedTypeCodes').value;
		previousCount=prevoiusSortListed.split(',').length;
		previousCount=prevoiusSortListed==""?(previousCount-1):previousCount;
		tmpText=previousCount+ (previousCount>1? " fund(s)":" fund");
		$('TotalShortlist').innerHTML="<b>"+totalText.replace("count",tmpText)+"</b>";
    }
    else
    {
		$('ShortListedTypeCodes').value=shortListedCodes;
		tmpText=shortListedCount+ (shortListedCount>1? " fund(s)":" fund");
		$('TotalShortlist').innerHTML="<b>"+totalText.replace("count",tmpText)+"</b>";
    }
	$('WarningLabel').innerHTML="A maximum of 20 funds can be shortlisted at a time";
	$('WarningLabel').style.display=shortListedCount>20?"block":"none";
	univ=CheckMutipleUniverse(shortListedCodes);
	if((previousUniv=='' && univ != '?') && chk==1 )
	{
	   $('PreviousUniv').value=univ;
	   previousUniv=$('PreviousUniv').value;
	}
	
	if(univ!=previousUniv && chk==1 && (univ!='' || ($('ProductType').value=="Whole of Market" || shortListedCodes!="") ) )
	{
	   if($('ProductType').value!="Whole of Market" || shortListedCodes== "")
	   { 
	      if(univ=='')
	         {
	            return;
	         }
	   }; 
	   
	   $('ShortListedTypeCodes').value=prevoiusSortListed;
	   previousCount=prevoiusSortListed.split(',').length;
	   previousCount=prevoiusSortListed==""?(previousCount-1):previousCount;
	   tmpText=previousCount+ (previousCount>1? " fund(s)":" fund");
	   $('TotalShortlist').innerHTML="<b>"+totalText.replace("count",tmpText)+"</b>";
	   $('WarningLabel').style.display="block";
	   $('WarningLabel').innerHTML="Only funds from the same fund universe can be shortlisted.";
	}
	
	if(previousCount==0 && shortListedCount==0)
	{
	   $('PreviousUniv').value='';
	}
}


function RedirectTo(page)
{
	document.forms[0].action=page;
	document.forms[0].submit();
}

function GoToShortList()
{
	var shortListedCount=$('ShortListedTypeCodes').value.split(',').length;
	if($('ShortListedTypeCodes').value=="")
    {
    shortListedCount=shortListedCount-1;
    }
	if(shortListedCount>0 && shortListedCount<21)
	{
	RedirectTo('shortlist.aspx')
	}
	else if(shortListedCount==0)
	{
		 $('WarningLabel').innerHTML="<b>Please select funds for your shortlist and click 'Update shortlist' before going to 'View shortlist'.</b>";
		 $('WarningLabel').style.display="block";
	}
	
}

function GoToScatterChart(page)
{
	var shortListedCount=0;
	var shortListedCodes=GetShortListedCodes(false);
	var url ="";
	var pageName="";
	var maxFund =0;
	
	var minFund = 0;
	if(page ==1)
	{
		url ="ScatterChart.aspx?CitiCodes=";
		pageName = "risk-return chart";
		maxFund = 10;
	}
	else if(page==2)
	{
		url ="ProductScan.aspx?CitiCodes=";
		pageName = "portfolio overview";
		maxFund = 20;
		minFund = 1;
	}
	else
	{
	   url ="ComparisonReport.aspx?CitiCodes=";
	   pageName = "comparison report";
	   maxFund = 4;
	   minFund = 2;
	}
	if(shortListedCodes=="")
    {
    shortListedCount=shortListedCodes.split(',').length-1;
    }
    else
    {
    shortListedCount=shortListedCodes.split(',').length;
    }
    if(shortListedCount >= minFund && shortListedCount < (maxFund+1))
    {
		 var univ=CheckMutipleUniverse(shortListedCodes);
		 if(univ!='')
		 { 
		   url +=shortListedCodes+"&Univ="+univ;
		    if(page==3)
		    {
		    OpenWindow(url);
		    }
		    else
		    {
			RedirectTo(url);
			}
		 }
		 else if(shortListedCount==0)
		 {
			$('WarningLabel').innerHTML="Please select at least one fund for the "+pageName+".";
			$('WarningLabel').style.display="block";
		 }
		 else
		 {
			$('WarningLabel').innerHTML="Only funds from the same universe can be shown on the "+pageName+".";
			$('WarningLabel').style.display="block";
		 }
    }
    else
    {
      var warningMess = "A maximum of "+maxFund+" funds can be shown on the "+pageName+".";
      if(page==2)
      {
			if(shortListedCount < minFund)
			{
			 var warningMess = "Please select at least one fund for the portfolio overview."
			}
			else
			{
			 var warningMess = "A maximum of "+maxFund+" funds can be shown on the "+pageName+".";
			}
      }
      
		 if(page==3)
		 {
			if(shortListedCount > minFund)
			{
		      var warningMess = "A maximum of four funds can be compared in one report.";
			}
			else
			{
			   var warningMess = "Please select at least two funds to compare."
			}
		 }

		 $('WarningLabel').innerHTML=warningMess;
		 $('WarningLabel').style.display="block";
    }
}

function GetShortListedCodes(isRequired)
{
	var constPrefix=','; 
    var items=document.getElementsByTagName('input');
    var tmpSortListedCodes=constPrefix+$('ShortListedTypeCodes').value+constPrefix; 
    var shortListedCodes=',';
    var notShortListed=',';
    var codes=new Array();
    for(i=0;i<items.length;i++)
    {
       if(items[i].type=='checkbox' && items[i].checked && items[i].id.indexOf('CheckAll')<0)
       {
       if(shortListedCodes.indexOf(constPrefix+items[i].value+constPrefix)<0){
       shortListedCodes+=items[i].value+constPrefix;}
       }
       else if(items[i].type=='checkbox' && items[i].checked==false)
       {
       notShortListed+=items[i].value+constPrefix;
       }
    }
    shortListedCodes=TrimStart(shortListedCodes,constPrefix);
    shortListedCodes=Trim(shortListedCodes,constPrefix);
    if(isRequired)
    {
		var sortListed=shortListedCodes.split(',');
		var tmpSortListed=tmpSortListedCodes.split(',');
		//Checking already the citicodes sortlisted or not.
		if(tmpSortListedCodes!=',,')
		{ 
		   var k=0;
	      
			for(i=0;i<sortListed.length;i++)
			{
				if(sortListed[i]!='')
				{
					if(tmpSortListedCodes.indexOf(constPrefix+sortListed[i]+constPrefix)<0)
					{
					   codes[k]=sortListed[i];
					   k++;
					}
					
				}
			}
			for(i=0;i<tmpSortListed.length;i++)
			{
				if(tmpSortListed[i]!='' && notShortListed.indexOf(constPrefix+tmpSortListed[i]+constPrefix)<0)
				{
				   codes[k]=tmpSortListed[i];
				   k++;
				}
			}
			return codes.join(',');
		}
		else
		{
		   return shortListedCodes;
		}
	}
	else
	{
	   return shortListedCodes;
	}
}

function CheckMutipleUniverse(shortListedCodes)
{
var univ='';
var flag=true;
var codes=new Array();
codes=shortListedCodes.split(',');
for(i=0;i<codes.length;i++)
{
  var hidCodes=$('hid'+codes[i]);
  if(hidCodes!=null)
  {
	  if(univ=='')
	  {
		 univ=hidCodes.value;
	  }
	  else
	  {
		  if(univ!=hidCodes.value)
		  {
			 flag=false;
			 break;
		  }
      }
  }
}
if(flag==false)
{univ='?'};
return univ;
}

function ChangeItemPerPage(obj)
{
$('ItemsPerPage').value=obj.value;
document.forms[0].submit();
}

function ClearALL()
{
$('PageAction').value="ClearALL";
RedirectTo('shortlist.aspx');
}

function RemoveSelectedFunds()
{
	var constPrefix=','; 
    var items=document.getElementsByTagName('input');
    var tmpSortListedCodes=constPrefix+$('ShortListedTypeCodes').value+constPrefix; 
    var shortListedCodes=',';
    var notShortListed=',';
    var codes=new Array();
    for(i=0;i<items.length;i++)
    {
       if(items[i].type=='checkbox' && items[i].checked && items[i].id.indexOf('CheckAll')<0)
       {
       if(shortListedCodes.indexOf(constPrefix+items[i].value+constPrefix)<0){
       shortListedCodes+=items[i].value+constPrefix;}
       }
       else if(items[i].type=='checkbox' && items[i].checked==false && items[i].id.indexOf('CheckAll')<0)
       {
       if(notShortListed.indexOf(constPrefix+items[i].value+constPrefix)<0){
       notShortListed+=items[i].value+constPrefix;}
       }
    }
    notShortListed=TrimStart(notShortListed,constPrefix);
    notShortListed=Trim(notShortListed,constPrefix);
    $('ShortListedTypeCodes').value=notShortListed;
    $('PreviousUniv').value=CheckMutipleUniverse(notShortListed);
    RedirectTo('shortlist.aspx');
}

function Clear()
{
   $('ProductType').value="";
   $('RangeName').value="";
   $('FundRangeCode').value="";
   $('ManagerGroup').value="";
   $('SectorCode').value="";
   $('CrownRating').value="";
   document.forms[0].submit();
}

function Trim(code,params)
{
	if(code != null)
	{
		return TrimStart(TrimEnd(code,params),params);
	}
	return code;
}

function TrimStart(code,params)
{
	if(code != null && code.substring(0,1) == params)
	{
		return code.substring(1, code.length);
	}
	return code;
}

function TrimEnd(code,params)
{
	if(code != null && code.substring(code.length-1,code.length) == params)
	{
		return code.substring(0, code.length-1);
	}
	return code;
}

function OpenWindow(url)
{
window.open(url,'_blank');
}

function ScrollToTop()
{	
	if (document.referrer.indexOf('www.aegonse.co.uk') == -1)
		window.location.hash='top';
}
