function testResults (form) {
    var username = form.username.value;
if (username == "personal")
   {
   Javascript:location='chase-personal-02.html';
   }
else if (username == "business")
   {
   Javascript:location='chase-business-02.html';
   }
else if (username == "commercial")
   {
   Javascript:location='chase-commercial-02.html';
   }
else if (username == "corporate")
   {
   Javascript:location='jpmorgan-corporate-02.html';
   }
else
   {
	alert ("For the purposes of this demo, please use one of the following user names - personal, business, commercial, or corporate. Any password will work.");
	}
    
}

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 move_in(img_name,img_src) {
	document[img_name].src=img_src;
	}

	function move_out(img_name,img_src) {
	document[img_name].src=img_src;
	}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/* Below here are scripts pulled from main html file */

/* pre cache CSS rollover images just in case */

img1 = new Image();
img1.src = "images/bkgrd_nav.jpg";
img2 = new Image();
img2.src = "images/bkgrd_nav_on.jpg";
img3 = new Image();
img3.src = "images/bkgrd_nav_selected.jpg";
img4 = new Image();
img4.src = "images/bkgrd_subnav.jpg";
img5 = new Image();
img5.src = "images/bkgrd_subnav_selected.jpg";
img6 = new Image();
img6.src = "images/bkgrd_subnav_on.jpg";

/* javascript flash object tag writer */
function home_flash() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="712" height="222">')
	document.write('<param name="movie" value="flash/JPM_Home_Flash.swf">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="flash/JPM_Home_Flash.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="712" height="222"></embed>')
	document.write('</object>')
}

function home_flash2() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="712" height="222">')
	document.write('<param name="movie" value="flash/JPM_Home_Flash_v2.swf">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="flash/JPM_Home_Flash_v2.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="712" height="222"></embed>')
	document.write('</object>')
}

function ts_flash() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="346" height="225">');
	document.write('<param name="movie" value="flash/JPM_TS_Landing.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="flash/JPM_TS_Landing.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="346" height="225"></embed>');
	document.write('</object>');
}

/* Function to swap input fields in client login box */
function checkSelected() 
{
	if (document.myForm.selection.value == "page1") {
		if (document.getElementById("loginIntroText"))
		{ document.getElementById("loginIntroText").style.display = "none";}
		if (document.getElementById("loginFields"))
		 {document.getElementById("loginFields").style.display = "block";}
		if (document.getElementById("loginSubmit"))
		 {document.getElementById("loginSubmit").style.display = "block";}
		if (document.getElementById("goButton"))
		 {document.getElementById("goButton").style.display = "none";}
    }
      
	if (document.myForm.selection.value == "page2") {
         window.location = "http://www.jpmorgan.com/";
    }
}

/* The IE navigation fixes (fix to prevent IE navs from losing z-index over select box, fix so that IE lists can recognize a hover event */
navManager = function() {
	if(document.getElementById("navContainer")){
		sfHover("navContainer","LI"," navHover"," navHoverOff", "selected");
	}
	if(document.getElementById("subNav")){
		sfHover("subNav","LI"," subNavHover"," subNavHoverOff", "selected");
	}
	if(document.getElementById("leftNav")){
		sfHover("leftNav","LI"," leftNavHover"," leftNavHoverOff", "subSelected");
	}	
	if(document.getElementById("leftNav")){
		sfHover("leftNav","DIV"," leftNavHover"," leftNavHoverOff", "leftSelected");
	}		
}

function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	// IE script to cover <select> elements with <iframe>s
	for (j=0; j<ieULs.length; j++) {
		ieULs[j].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0" style="filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);"></iframe>' + ieULs[j].innerHTML);
		var ieMat = ieULs[j].firstChild;
		ieMat.style.width=ieULs[j].offsetWidth+"px";	
		ieMat.style.zIndex="-1";
		ieULs[j].style.zIndex="101";
	}
}

function sfHover(id, tagType, hoverClass, hoverClassOff, selectedClass) { 
	var ieNavs = document.getElementsByTagName('ul');
	for(i=0; i<ieNavs.length; i++) {
		var ul = ieNavs[i];
		// If they have a class of navFix add the menu hover.
		if(ul.className.match("navFix") != null)
			setHover(ul);
	}

	var sfEls = document.getElementById(id).getElementsByTagName(tagType); 
	for (var i=0; i<sfEls.length; i++) { 
		
		if (sfEls[i].className == "nohover" ) {

		} else {
	
		if(sfEls[i].className != selectedClass && sfEls[i].id != selectedClass  ) {
			
			sfEls[i].onmouseover=function() { 
				this.className = hoverClass; 
			
			} 
		
			sfEls[i].onmouseout=function() { 
				this.className=this.className.replace(new RegExp(hoverClass + "\\b"),new RegExp(hoverClassOff + "\\b") ); 
			}
		} else {
			sfEls[i].onmouseover=function() { 
				var selectedClassOver = " " + selectedClass + "Over";
				this.className = selectedClassOver;

			} 
			sfEls[i].onmouseout=function() { 
				this.className=selectedClass;
			}			
		}

		}
	} 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

if (window.attachEvent) window.attachEvent("onload", navManager);

imageArray=new Array();
numImages=new Array();
currentImage=new Array();

function switchImage(imgname)
{
	document[imgname].src=imageArray[imgname+(currentImage[imgname]+1)];
	currentImage[imgname]=(currentImage[imgname]+1)%numImages[imgname];
	setTimeout("switchImage(\""+imgname+"\")",5000);
}

function showDiv(id)
{
	document.getElementById(id).style.display="block";
}

function hideDiv(id)
{
	document.getElementById(id).style.display="none";	
}

currentemail=0;
function email_link()
{
  if (currentemail==0)
  {
	hideDiv("bodyContent");
	showDiv("emailContent");
	currentemail=1;
  }
  else
  {
	showDiv("bodyContent");
	hideDiv("emailContent");
	currentemail=0;
  }
}

function openWin( url, w, h, x, y) {
    msgWindow = window.open('','newWin','width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',top=' + x + ',left=' + y + ',scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes');
    msgWindow.location.href = url;
	if (window.focus) {msgWindow.focus()}
	return false;
}

function redirectWin( url ) {
    window.location.href = url;
    return false;
}


//Track using G-Code 
function trackLinks(clientLogin,parentLink,reportSuite) {		
//alert("parent link - " + parentLink ); 
//alert("client Login - " + clientLogin );
//alert("Report Suite - " + reportSuite );
s_linkTrackVars="prop9";
s_linkTrackEvents="None";
s_linkType="o";
s_linkName=clientLogin;
s_prop9=parentLink; 
s_lnk=s_co(this); 
s_gs(reportSuite); 

} 

function validate_email_form()
{
    if ( document.emailForm.email.value == "" )
    {
        alert ( "Please enter recipient's e-mail address" );
        return false;
    }
     if ( document.emailForm.email2.value == "" )
    {
        alert ( "Please enter your e-mail address" );
        return false;
    }
    var temp = new Array();
    var b = document.emailForm.email.value;
	temp = b.split(',');
	if(temp.length<=0) {
		alert ( "Please enter comma separated e-mail addresses" );
		return false;
	} 
  
    for(i = 0; i < temp.length; i++){
	  if(emailCheck(temp[i]) == false) return false;
	}
	for(i = 0; i < temp.length; i++)
		for(j = 0; j < temp.length; j++){
		if(i!=j && temp[i]==temp[j] ) {
			alert ( "Duplicate e-mail addresses "+temp[i] );
			return false;
		}	
	}	
	valid = emailCheck(document.emailForm.email2.value);
	if(valid == false ) return false;
	return true;
}


function emailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert( "Invalid E-mail address - " + str )
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address - " + str)
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address - " + str)
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address - " + str)
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address - " + str)
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address - " + str)
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address - " + str)
		    return false
		 }

 		 return true					
	}

// This function uses to track the traffic of client login box links 
function TrackClientLogonLinks(clientLoginIndex,clientLoginName,clientLoginValue,currentPageLink,reportSuite){
	//alert("currentPageLink ->"+currentPageLink);
	if(clientLoginIndex!=0){
		//This below given function "trackLinks" is called from JPM/Common/JavaScript
		trackLinks(clientLoginName,currentPageLink,reportSuite);
		window.open(clientLoginValue, 'appwindow'); 
	}else return false;
}

var s_pageName="http://www.jpmorgan.com/pages/jpmorgan"
var s_prop1="jpmorgan "
var s_account="jpmcglobal,jpmorgan"

var s_pageType=""
var s_server=""
var s_channel=""
var s_prop2='Generic_Content_Page_Template'
var s_prop3=""
var s_prop4=""
var s_prop5=""
/* E-commerce Variables */
var s_campaign=""
var s_state=""
var s_zip=""
var s_events=""
var s_products=""
var s_purchaseID=""
var s_eVar1=""
var s_eVar2=""
var s_eVar3=""
var s_eVar4=""
var s_eVar5=""
