function fExcelDownload()
{
	document.navigationForm.target="_blank";
  	document.navigationForm.xls.value="Y";
  	document.navigationForm.submit();
  	document.navigationForm.xls.value="";
  	document.navigationForm.target="";
}
 
function submitLetter(letter) {
  document.navigationForm.startLetter.value = letter;
  document.navigationForm.submit();
}

function submitLetterPerf(letter) {
  document.navigationForm.startLetter.value = letter;
  document.navigationForm.performers.value = "0";
  document.navigationForm.subset.value = "1";
  document.navigationForm.submit();
}

function submitNext(nextLocator) {
  document.navigationForm.nextLocator.value = nextLocator;
  document.navigationForm.direction.value = "next";
  document.navigationForm.submit();

}
function submitPrevious(previousLocator) {
  document.navigationForm.previousLocator.value = previousLocator;
  document.navigationForm.direction.value = "previous";
  document.navigationForm.submit();
}
function submitPerformers(argForm) {
var str = argForm.performers.options[argForm.performers.selectedIndex].value;
	if(str.length<=0){
		return false;
	}
	document.performersForm.performers.value = str;
	document.performersForm.submit();

  
}

//
function  MM_openBrWindow(theURL,winName,features) { //v1.0
//  window.open(path + theURL,winName,features);
  window.open(theURL,winName,features);
}
function trimString (str) {
  str = this != window? this : str
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '')
}

function ValidateMaile(emaileString) {
	var TempVal  = emaileString
	var AtSym    = TempVal.indexOf('@')
	var Period   = TempVal.lastIndexOf('.')
	var Space    = TempVal.indexOf(' ')
	var Length   = TempVal.length - 1   // Array is from 0 to length-1
    
	if 	(	(AtSym < 1) ||                     // '@' cannot be in first position
			(Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
      		(Period == Length ) ||             // Must be atleast one valid char after '.'
      		(Space  != -1))                    // No empty spaces permitted
	 {	
	     	 alert("Please provide a valid e-mail address, such as: jdoe@bankofny.com")
	      	 return false
      }
	return true
}
function submitNextSorted(pageNumber) {
  //document.navigationForm.pageNumber.value = pageNumber;
  document.navigationForm.direction.value = "nextPage";
  document.navigationForm.submit();

}
function submitPreviousSorted(pageNumber) {
  //document.navigationForm.pageNumber.value = pageNumber;
  document.navigationForm.direction.value = "previousPage";
  document.navigationForm.submit();
}
function validateSubset(){
	perfVal =new Array('0','1','6','7','2','8','3','4','5','9','10');
	perf 	=new Array(	"All Sorted by Name",
					"Daily Price Performance (% Chg.)",
					"MTD Price Performance (% Chg.)",
					"QTD Price Performance (% Chg.)",
					"YTD Price Performance (% Chg.)",
					"52-Wk Price Performance (% Chg.)",
					"Daily Trading Volume",
					"Daily Trading Volume W/ Price Up",
					"Daily Trading Volume W/ Price Down",
					"50-Day Avg Trading Volume",
					"200-Day Avg Trading Volume");
	perfVal50 =new Array('1','6','7','2','8','3','4','5','9','10','100');
	perf50 	=new Array(	
					"Daily Price Performance (% Chg.)",
					"MTD Price Performance (% Chg.)",
					"QTD Price Performance (% Chg.)",
					"YTD Price Performance (% Chg.)",
					"52-Wk Price Performance (% Chg.)",
					"Daily Trading Volume",
					"Daily Trading Volume W/ Price Up",
					"Daily Trading Volume W/ Price Down",
					"50-Day Avg Trading Volume",
					"200-Day Avg Trading Volume",
					"");
					
					
	vlue=document.navigationForm.subset.options[document.navigationForm.subset.selectedIndex].value
	
	txt=vlue
//document.forms[0].favorite.value=txt
	j=0;
	k=0;
	myObj=new Object();
	if (txt=="0"){
		//alert(txt);
		j=1;
		k=1;
		//document.performersForm.performers.options[0]=null;
		//document.performersForm.performers.options[0].text="Select a DR Performance Table ";
		//document.performersForm.performers.options[0].value=15;
		//document.performersForm.performers.selectedIndex=0;
		/*
		for (i=0;i<(11);i++){
				document.performersForm.performers.options[i].text=perf50[i];
				document.performersForm.performers.options[i].value=perfVal[i];
				j++;
			}
		*/
		document.navigationForm.performers.options[0] =null;
		document.navigationForm.performers.selectedIndex=0;
	}else{
			//document.performersForm.performers.options[0].text=perf[0];
			//document.performersForm.performers.options[0].value=perfVal[0]
			//document.performersForm.performers.options[10] =new Option();
			//var no = new Option();
			//no.value = "0";
			//no.text = "test";
			//document.performersForm.performers.options[document.performersForm.performers.options.length] = no;

   
			
			
			for (i=0;i<(11);i++){
				document.navigationForm.performers.options[i] =new Option();
				document.navigationForm.performers.options[i].text=perf[i];
				document.navigationForm.performers.options[i].value=perfVal[i];
				j++;
			}
		document.navigationForm.performers.selectedIndex=0;
	}
	/*
	for (i=0;i<(11-k);i++){
			document.performersForm.performers.options[i].text=perf[j];
			document.performersForm.performers.options[i].value=perfVal[j];
			j++;
	}
	*/
	//x=document.performersForm;
	//x.performers.value=
}





function ValidateInformed(argForm) {
	var Temp     		= argForm.email;
	var TempVal  		= trimString(Temp.value);
	argForm.email.value = TempVal	;
     	 
	if (ValidateMaile(TempVal)==false)	{	 	
	         Temp.focus();
	         Temp.select();
	         return false;
     }
}

function ValidateInformedNew(argForm) {
	if(argForm.email.value == ""){
		alert("You must enter your email address");
		argForm.email.focus();
		return false;
	}

	if(ValidateMaile(trimString(argForm.email.value)) == false){
		argForm.email.focus();
		return false;
	}

	if(argForm.name.value == "" ){
		alert("You must enter your name");
		argForm.name.focus();
		return false;
	}
}

function ValidateFeedback(argForm) {	
	check = 0;
	for(i=0;i<argForm.title.length;i++){
		if(argForm.title[i].checked){
			check = 1;
		}
	}
	if(check==0){
		alert("You must select a title")
		argForm.title[0].focus()
		return false;
	}
	
	else if(argForm.firstName.value == "" ){
		alert("You must enter your first name");
		argForm.firstName.focus();
		return false;
		}
	
	else if(argForm.lastName.value == ""){
		alert("You must enter your last name");
		argForm.lastName.focus();
		return false;
		}
		
	else if(argForm.email.value== ""){
		alert("You must enter your email address");
		argForm.email.focus();
		return false;
	}else if(argForm.feedback.value == ""){
		alert("Please enter your ADR-related message.");
		argForm.feedback.focus();
		return false;
		}

	var Temp     		= argForm.email
	var TempVal  		= trimString(Temp.value)
	argForm.email.value = TempVal	
 	 
	if (ValidateMaile(TempVal)==false){
	         Temp.focus();
	         Temp.select();
	         return false;
       }
}

function formHandler(aform) {
  var URL = aform.site.options[aform.site.selectedIndex].value;
  if(URL.length<=0){
	return false;
	}
  window.location.href = URL;
  return true;
}

function formHandler2(form2) {
  var URL = document.form2.site.options[document.form2.site.selectedIndex].value;
  window.location.href = URL;
}


function handleIndexTableForm(argForm){
	var str = argForm.viewPerformanceTables.options[argForm.viewPerformanceTables.selectedIndex].value;
	if(str.length<=0){
		return false;
	}
	window.location.href = str;	
	return true;
}

function launchLink(fileName){
   var periodPos = fileName.indexOf(".");
   var ext = fileName.substring(periodPos + 1, fileName.length);
   if (ext == "pdf") {
      window.open(fileName);
   }  else  {
      document.location = fileName;
   }
}
/*------------------*/

  // define the 2 cookie names for storing the current page values 
  // (they should be unique for each page where this code appears),
  // then define the list of images to rotate through
  var permCookieName = "Ind_PermLastImage";
  var tempCookieName = "Ind_TempCurrentImage";
  

      
  function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
      endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
  }

  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) {
    document.cookie = name + "=" + escape (value) +
      ((expires == null) ? "" : ("; expires=" + expires.toGMTString()));
  }

function runCookie( ){  
	//var path='';
	if (imgPath==null)
		imgPath="";
	var imagesList = new Array(
     	imgPath+"images/adr_london.jpg",
    	imgPath+"images/adr_newyork.jpg", 
    	imgPath+"images/adr_prague.jpg",
		imgPath+"images/adr_sydney.jpg");
	
	var currentImageID = GetCookie(tempCookieName);
	var lastImageID = GetCookie(permCookieName);
	var timeFrame=365 * 24 * 3600 * 1000;
	if (currentImageID == null)
	{
	    if (lastImageID == null)
	    {
	        currentImageID = "0";
	    }
	    else
	    {
	        var nextInt = parseInt(lastImageID) + 1;
	        if (nextInt >= imagesList.length)
	            nextInt = 0;
	        currentImageID = nextInt;
	    }
	
	    SetCookie(tempCookieName, currentImageID);
	    var thenewdate = new Date ();
	    thenewdate.setTime(thenewdate.getTime() + (timeFrame));
	    SetCookie(permCookieName, currentImageID, thenewdate);
	}
	
	var imageName = imagesList[currentImageID];
	document.write(' <img src="'+imgPath+'images/img_spacer.gif" width="2" height="1" border="0"><IMG src=\"'+imageName+'\" height=62 width=618 border=0></td>');
}




function topNav(menuName){
	if (menuName=="home") {  
        document.write('<img src="'+imgPath+'images/tnav_home_on.gif"  height="17" width="94" border="0" alt="Home">');
 	} else { 
        document.write('<a href="'+path+'home.jsp"><img src="'+imgPath+'images/tnav_home_off.gif"  height="17" width="94" border="0" alt="Home"></a>');
  	}
	if (menuName=="whatsnew") {  
        document.write('<img src="'+imgPath+'images/tnav_whatsnew_on.gif"  height="17" border="0" width="100" alt="What\'s New">');
  	} else { 
        document.write('<a href="'+path+'whatsnew.jsp"><img src="'+imgPath+'images/tnav_whatsnew_off.gif"  height="17" width="100" border="0"  alt="What\'s New"></a>');
  	}
	if (menuName=="drcalendar") {   
        document.write('<img src="'+path+'images/tnav_drcalendar_on.gif"  height="17"  width="123" border="0" alt="DR Calendar">');
   	} else { 
        document.write('<a href="http://bny.ccbn.com/highlight.asp?client=bny"><img src="'+imgPath+'images/tnav_drcalendar_off.gif"  height="17"  width="123"  border="0" alt="DR Calendar"></a>');
  	}
    if (menuName=="contactus") {  
        document.write('<img src="'+imgPath+'images/tnav_contactus_on.gif"  height="17"  width="102" border="0"   alt="Contact Us">');
   	} else {   
        document.write('<a href="'+path+'contactus.jsp"><img src="'+imgPath+'images/tnav_contactus_off.gif"   height="17"  width="102" border="0"  alt="Contact Us"></a>');
   	}
   	document.write('<a href="#" onClick="javascript:open(\''+path+'popup_terms_of_use.html\',\'popup\', \'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,height=600,width=480\');return false;"><img src="'+imgPath+'images/tnav_terms_off.gif"  height="17" border="0"  width="109" alt="Terms of Use"></a>');
   	if (menuName=="siteguide") {  
        document.write('<img src="'+imgPath+'images/tnav_siteguide_on.gif"  height="17" border="0" width="93"  alt="Site Guide">');
  	} else { 
    	document.write('<a href="'+path+'siteguide.jsp"><img src="'+imgPath+'images/tnav_siteguide_off.gif"  height="17" width="93" border="0"  alt="Site Guide"></a>');
  	} 

}

function rotateImages( ){  

	if (imgPath==null)
		imgPath="";
	var imagesList = new Array(
     	imgPath+"images/adrx_banner_london.jpg",
    	imgPath+"images/adrx_banner_nyc.jpg", 
    	imgPath+"images/adrx_banner_prague.jpg",
	imgPath+"images/adrx_banner_hongkong.jpg");
	/*
	var currentImageID 	= GetCookie(tempCookieName);
	var lastImageID 	= GetCookie(permCookieName);
	var timeFrame=365 * 24 * 3600 * 1000;
	if (currentImageID == null)
	{
	    if (lastImageID == null)
	    {
	        currentImageID = "0";
	    }
	    else
	    {
	        var nextInt = parseInt(lastImageID) + 1;
	        if (nextInt >= imagesList.length)
	            nextInt = 0;
	        currentImageID = nextInt;
	    }
	
	    SetCookie(tempCookieName, currentImageID);
	    var thenewdate = new Date ();
	    thenewdate.setTime(thenewdate.getTime() + (timeFrame));
	    SetCookie(permCookieName, currentImageID, thenewdate);
	}
	*/
 
	var currentImageID =get_random();
	var imageName = imagesList[currentImageID];
	document.write(' <img src="'+imgPath+'images/img_spacer.gif" width="2" height="1" border="0"><IMG src=\"'+imageName+'\" border=0></td>');
}

 

//---------------------------------------
var yestoopen=false;
var oxfordCookieName = "oxfordCookie39";
var counter=1*10000;
var oxfortTimeFrame=365 * 24 * 3600 * 1000;

function runoxford(){
// 	openoxford();
	//alert (counter);
//	setTimeout('runoxford()',counter);	
// 	init(); 	
}

function  openoxford(){
	var yestoopennum = GetCookie(oxfordCookieName);
	 
	if ((yestoopen)&&((yestoopennum=="1")||(yestoopennum=="2"))){
		counter=6*2.5*10000;
		yestoopen=false;
		 
	 	window.open('popup_oxford.html','popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,height=425,width=480')
			
	}
}

function closeoxford(){
	var yestoopennum = GetCookie(oxfordCookieName);
	var thenewdate = new Date ();
	thenewdate.setTime(thenewdate.getTime() + (oxfortTimeFrame));
	
	if (yestoopennum=="1"){
		SetCookie( oxfordCookieName, "2",thenewdate);
		yestoopen=true;
	}else if (yestoopennum=="2"){
		SetCookie( oxfordCookieName, "0",thenewdate);
		yestoopen=false;
	}	
	
}
function suspendoxford(){
	var yestoopennum = GetCookie(oxfordCookieName);
	var thenewdate = new Date ();
	thenewdate.setTime(thenewdate.getTime() + (oxfortTimeFrame));
		
		SetCookie( oxfordCookieName, "0",thenewdate);
		yestoopen=false;
	
	
}
function setoxford(){
	var thenewdate = new Date ();
	thenewdate.setTime(thenewdate.getTime() + (oxfortTimeFrame));
	SetCookie( oxfordCookieName, "1",thenewdate);
	
}
function init(){
	//alert (document.cookie);

	var yestoopennum = GetCookie(oxfordCookieName);
	//alert ("yestoopennum="+yestoopennum);
	if (yestoopennum==null){
		setoxford();
		yestoopen=true;
	}else if (yestoopennum=='1'){
		yestoopen=true;
	}else if (yestoopennum=='2'){
		yestoopen=true;
	}else{
		yestoopen=false;
	}
}
//---------------------------------------	

