function MM_preloadImages() {
//v3.0
  var d=document;
  if(d.images){
    if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){
        d.MM_p[j]=new Image;
	d.MM_p[j++].src=a[i];
      }
    }}

function MM_swapImgRestore() {
//v3.0
 var i,x,a=document.MM_sr;
 for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
   x.src=x.oSrc;
}

function MM_findObj(n, d) {
//v3.0 var p,i,x;
 if(!d) d=document;
 if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
 } if(!(x=d[n])&&d.all) x=d.all[n];
 for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++)
   x=MM_findObj(n,d.layers[i].document);
 return x;
}

function MM_swapImage() {
 //v3.0
 var i,j=0,x,a=MM_swapImage.arguments;
 document.MM_sr=new Array;
 for(i=0;i<(a.length-2);i+=3)
 if ((x=MM_findObj(a[i]))!=null){
   document.MM_sr[j++]=x;
   if(!x.oSrc) x.oSrc=x.src;
   x.src=a[i+2];
 }
}

function ShowQuote() {
	if (frmQuote.FundSymbol.value == "") {
		alert ("You must enter a stock symbol.");
		return false;
	}

	HelpWin ('http://www.nylim.newsalert.com/bin/chartsnip?Symbol=' + frmQuote.FundSymbol.value + '&ChartType=1year&redirect=1', 450,250);
}


function initNSMenus() {
	if (navigator.appName == "Netscape" && document.layers) {
		HM_a_MainMenus = [];
		tmpDTab = "DJIA";
	}
	HM_tab_count = 1;
	objtmp='indexTab1';
	HM_i_count = 0;
}

//if Netscape4.x, return val2
function IEvsNS (val1, val2) {
	if (navigator.appName == "Netscape" && document.layers) {
		return val2;
	} else {
		return val1;
	}
}

function CreateMenu(ctext, imenu, clink, isnewwin) {
	//write actual menu position
	a_MenuPos[imenu] = HM_i_count;
	ctext2 = ctext.replace("'", "\\'");
	cmenu = "'HM_Menu" + imenu + "'";
	if (imenu > 0) {
		ceventtext = "onMouseOver=\"MouseOverMenu(this,'" + ctext2 + "',true);popUp(" + cmenu + ",event);\" onmouseout=\"MouseOverMenu(this,'" + ctext2 + "',false);popDown(" + cmenu + ",event);\" ";
	} else {
		ceventtext = "onMouseOver=\"MouseOverMenu(this,'" + ctext2 + "',true);\" onmouseout=\"MouseOverMenu(this,'" + ctext2 + "',false);\" ";
	}

	if (clink != "") {
		if (isnewwin) {
			clink = "window.open('" + clink + "')";
		} else {
			clink = "document.location='" + clink + "'";
		}
		clinktext = "onclick=\"" + clink + "\"";
	} else {clinktext = "";}

	if (navigator.appName == "Netscape") {
		if (document.layers) {
			if (clink != "") {
				HM_a_MainMenus[HM_i_count] = clink;
			}
			document.write("<tr><td height=24>");
			document.write("	<ILAYER height=22>");
			document.write("		<LAYER ID=L" + HM_i_count + " class=bgLeftNav " + ceventtext + " onclick=\"\" width=100%>");
			document.write(				ctext + " &nbsp; ");
			document.write("		</LAYER>");
			document.write("	</ILAYER>");
			document.write("</td></tr>");
		} else {
			document.write ("<tr><td>");
			document.write ("	<span " + ceventtext + clinktext + "><div class=bgLeftNavNS6 height=24 width=100%>" + ctext + " &nbsp; </div></span>");
			document.write("</td></tr>");
		}
	} else {
		document.write("<tr><td height=24 class=bgLeftNav " + ceventtext + clinktext + ">");
		document.write(		ctext + " &nbsp; ");
		document.write("</td></tr>");
	}
	HM_i_count++;
}

function MouseOverMenu(obj, ctext, isover) {
	if (navigator.appName == "Netscape") {
		if (document.layers) {
			if (isover) {
				HM_i_count = obj.name.substr(1);
				obj.bgColor=strSiteColor;
				ctext = '<p class="bgLeftNavOver">' + ctext + ' &nbsp; </p>';
			} else {
				if (HM_i_count == obj.name.substr(1)) {HM_i_count = -1};
				obj.bgColor=null;
				ctext = '<p class="bgLeftNav">' + ctext + ' &nbsp; </p>';
			}
			obj.document.write(ctext);
			obj.document.close();
			obj.document.captureEvents(Event.MOUSEDOWN);
			obj.document.onmousedown = function(){MainMenuClickNS();}

		} else {
			//var fobj = document.getElementById("la1");
			obj = obj.childNodes[0];

			if (isover) {
				obj.className="bgLeftNavNS6Over";
			} else {
				obj.className="bgLeftNavNS6";
			}
		}
	} else {
		if (isover) {
			obj.className = "bgLeftNavOver";
		} else {
			obj.className = "bgLeftNav";
		}
	}
}

function MainMenuClickNS() {
	eval(HM_a_MainMenus[HM_i_count]);
}


function CreateTabMenu (ctext,classname,image,symbol,footer) {
	document.write("<td>");
	//alert(ctext+"------"+document.layers + "-----" + document.getElementById + "---------" +document.all);

	if (document.layers) {
		//alert('layer');
		document.write("	<ILAYER id=indexTab"+HM_tab_count+"p>");
		document.write("		<LAYER id=indexTab"+HM_tab_count+" onmouseover=\"SwapMouseOver('indexTab"+HM_tab_count+"','"+footer+"','"+image+"','"+symbol+"')\"><font class="+classname+">");
		document.write(				ctext + " &nbsp; </font>");
		document.write("		</LAYER>");
		document.write("	</ILAYER>");
	} else if ((document.getElementById)&&(!document.all)) {
		//alert('element');
		document.write("	<SPAN onmouseover=\"SwapMouseOver('indexTab"+HM_tab_count+"','"+footer+"','"+image+"','')\" onclick=\"Get_Quote('"+symbol+"');\"");
		document.write("		<DIV width=100% id=indexTab"+HM_tab_count+" class="+classname+">"+ctext+"</DIV>");
		document.write("	</SPAN>");
	} else {
		//alert('else');
		document.write("	<DIV width=100% id=indexTab"+HM_tab_count+" class="+classname+" onmouseover=\"SwapMouseOver('indexTab"+HM_tab_count+"','"+footer+"','"+image+"','')\" onclick=\"Get_Quote('"+symbol+"');\">"+ctext+"</DIV>");
	}
	document.write("</td>");
	HM_tab_count++;
}


function SwapMouseOver(tabstop,ctext,image,symbol) {
	if (document.layers) {
		if (tabstop != objtmp) {
			document.layers[objtmp+"p"].document.layers[objtmp].document.write('<font size=9px class=bgIndices>' + tmpDTab + ' &nbsp; </font>');
			document.close();
			document.layers[tabstop+"p"].document.layers[tabstop].document.write('<font size=9px class=bgIndicesSelected>' + ctext + ' &nbsp; </font>');
			document.close();
			document.layers[tabstop+"p"].document.layers[tabstop].document.captureEvents(Event.MOUSEDOWN);
			document.layers[tabstop+"p"].document.layers[tabstop].document.onmousedown = function(){Get_Quote(symbol);};
			objtmp=tabstop;
			tmpDTab=ctext;
			document.layers['indexTitleP'].document.layers['indexTitle'].document.write('<font size=9px class=footnotes>' + ctext + ' &nbsp; </font>');
			document.close();
		}
	} else {
		document.getElementById(objtmp).className='bgIndices';
		document.getElementById(tabstop).className='bgIndicesSelected';
		objtmp=tabstop;
		document.getElementById("indexTitle").innerHTML=ctext;
	}
	document.images["imagename"].src="/PASS/Files/Images/Stock/"+image+".bmp";

}

function SwapMouseOut(tabstop) {
	if (tabstop != strSelectedImage) {
		myObj = document.getElementById("indexTab" + tabstop);
		myObj.className = "bgIndicesSelected";
	}
}

function HelpWin(destination, x, y)
{
	var newLeft = (screen.width - x) / 2 ;
	var newTop =  (screen.height - y) / 3 ;

	NYLIMIntranet=window.open(destination,'NYLIMIntranet','toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=no,resizable=1,width='+x+',height='+y+', left ='+newLeft+', top='+newTop );
	NYLIMIntranet.focus();
}

function PrintWin(destination, x, y)
{
	var newLeft = (screen.width - x) / 2 ;
	var newTop =  (screen.height - y) / 3 ;

	NYLIMIntranet=window.open(destination,'PrintPreview','toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,status=no,resizable=1,width='+x+',height='+y+', left ='+newLeft+', top='+newTop );
	NYLIMIntranet.focus();

	return false;
}

function check_email(str){

	var filter="/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i";
	if (filter.test(str))
		return true;
	else
		return false;
}


//======================================Referrer code==============================//
function setReferrerCookie () {
	strCookieValue = "true";
	strCookieName = "cookieReferrer";
	document.cookie = strCookieName + "=" + escape(strCookieValue) + "; path=/";
}

function getReferrerCookie() {
	var search;

  search = "cookieReferrer="
  offset = document.cookie.indexOf(search)
  if (offset != -1) {
    offset += search.length ;
    end = document.cookie.indexOf(";", offset) ;
    if (end == -1)
      end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return "";
}

function writeReferrerString(strReferralURL, defaultstring, referrerstring) {
	strReferralURL = "/" + strReferralURL + "/gi";
	if (document.referrer.search(strReferralURL) != -1) {
	} else if (getReferrerCookie()=="true") {
		setReferrerCookie();
	} else {
		document.write(defaultstring);
		return;
	}
	//if referred from other site
	document.write(referrerstring);
}


function isReferByNYL(url) {
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//======================================Referrer code==============================//


//=======================================SHA-1 code================================//
var hex_chr = "0123456789abcdef";
function hex(num)
{
  var str = "";
  for(var j = 7; j >= 0; j--)
    str += hex_chr.charAt((num >> (j * 4)) & 0x0F);
  return str;
}

/*
 * Convert a string to a sequence of 16-word blocks, stored as an array.
 * Append padding bits and the length, as described in the SHA1 standard.
 */
function str2blks_SHA1(str)
{
  var nblk = ((str.length + 8) >> 6) + 1;
  var blks = new Array(nblk * 16);
  for(var i = 0; i < nblk * 16; i++) blks[i] = 0;
  for(i = 0; i < str.length; i++)
    blks[i >> 2] |= str.charCodeAt(i) << (24 - (i % 4) * 8);
  blks[i >> 2] |= 0x80 << (24 - (i % 4) * 8);
  blks[nblk * 16 - 1] = str.length * 8;
  return blks;
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left
 */
function rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Perform the appropriate triplet combination function for the current
 * iteration
 */
function ft(t, b, c, d)
{
  if(t < 20) return (b & c) | ((~b) & d);
  if(t < 40) return b ^ c ^ d;
  if(t < 60) return (b & c) | (b & d) | (c & d);
  return b ^ c ^ d;
}

/*
 * Determine the appropriate additive constant for the current iteration
 */
function kt(t)
{
  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
         (t < 60) ? -1894007588 : -899497514;
}

/*
 * Take a string and return the hex representation of its SHA-1.
 */
function calcSHA1(str)
{
  var x = str2blks_SHA1(str);
  var w = new Array(80);

  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
  var e = -1009589776;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;
    var olde = e;

    for(var j = 0; j < 80; j++)
    {
      if(j < 16) w[j] = x[i + j];
      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
      t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j)));
      e = d;
      d = c;
      c = rol(b, 30);
      b = a;
      a = t;
    }

    a = add(a, olda);
    b = add(b, oldb);
    c = add(c, oldc);
    d = add(d, oldd);
    e = add(e, olde);
  }
  return hex(a) + hex(b) + hex(c) + hex(d) + hex(e);
}
//=======================================SHA-1 code================================//

// Extended Tooltip Javascript
// copyright 9th August 2002, by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
if (document.getElementById) {
	ai = 1; DH = 1;
}else {
	if (document.all) {
		al = 1; DH = 1;
	} else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1; DH = 1;
		}
	}
}


function fd(oi,ws) {
	if (ws == 1) {
		if (ai) {
			return (document.getElementById(oi).style);
		} else {
			if (al) {
				return (document.all[oi].style);
			} else {
				if (an) {
					return (document.layers[oi]);
				}
			};
		}
	} else {
		if (ai) {
			return (document.getElementById(oi));
		} else {
			if (al) {
				return (document.all[oi]);
			} else {
				if (an) {
					return (document.layers[oi]);
				}
			};
		}
	}
}

function pw() {
	if (window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth; return (null);
}

function popUp(evt,oi) {
	if (DH) {
		var wp = pw();
		ds = fd(oi,1);
		dm = fd(oi,0);
		st = ds.visibility;
		if (dm.offsetWidth)
			ew = dm.offsetWidth;
		else if (dm.clip.width)
			ew = dm.clip.width;
		if (st == "visible" || st == "show") {
			ds.visibility = "hidden";
		} else  {
			if (evt.y || evt.pageY) {
				if (evt.pageY) {
					tv = evt.pageY + 20;
					lv = evt.pageX - (ew/4);
				} else {
					tv = evt.y + 20 + document.body.scrollTop;
					lv = evt.x  - (ew/4) + document.body.scrollLeft;
				}
				if (lv < 2)
					lv = 2;
				else if (lv + ew > wp)
					lv -= ew/2;
				ds.left = lv;
				ds.top = tv;
			}
			ds.visibility = "visible";
		}
	}
}
