// global1.js


//============================================================================================================================
function gInitialize(section) {
	gInitializeNavigation();
	
	var dirPath = "../";
	if (section == "top") {
		dirPath = "";
	} else if (section == "pro") {
		MM_preloadImages();
	}
	

	// Proload the rollover images potentially common to any page
	MM_preloadImages(dirPath+'images/all-r.gif',dirPath+'images/cli-r.gif',dirPath+'images/com-r.gif',dirPath+'images/con-r.gif',dirPath+'images/new-r.gif',dirPath+'images/pro-r.gif');
}

//============================================================================================================================
function gInitializeNavigation() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("navTopLevel");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if ((node.nodeName=="LI") && ((node.className=="top") || (node.className=="current"))) {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

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 gInsertNavigation(section){
	var dirPath;
	var classTxt = "";
	var txtCurrent = 'class="current"';
	var txtNotCurrent = 'class="top"';
	var d = document;

	d.write('<ul id="navTopLevel">');

	// Products  ----------------------------------------------------
	if (section == "pro") {
		dirPath = ""; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "products/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../products/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-pro" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>Products Overview</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'about-prepayment-model.htm"><nobr>Prepayment Models</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'score.htm"><nobr>Score</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'default-model.htm"><nobr>Default Model</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'interest-rate-process.htm"><nobr>Interest Rate Process</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'dynamic-aggregator.htm"><nobr>Dynamic Aggregator</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'calculators.htm"><nobr>Calculators</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'research-reports.htm"><nobr>Research & Reports</nobr></a></li>');	
	d.write('<li><a href="'+dirPath+'client-support.htm"><nobr>Client Support</nobr></a></li>');	
	d.write('</ul>');
	d.write('</li>');

	// Clients  ----------------------------------------------------
	if (section == "cli") {
		dirPath = ""; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "clients/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../clients/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-cli" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>AFT Clients</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'alm-managers.htm"><nobr>ALM Managers</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'broker-dealers.htm"><nobr>Brokers/Dealers</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'money-managers.htm"><nobr>Money Managers</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'insurance-companies.htm"><nobr>Insurance Companies</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'mortgage-bankers.htm"><nobr>Mortgage Bankers</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'case-studies.htm"><nobr>Case Studies</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'faqs.htm"><nobr>FAQs</nobr></a></li>');
	d.write('</ul>');
	d.write('</li>');


	// Alliances  ----------------------------------------------------
	if (section == "all") {
		dirPath = ""; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "alliances/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../alliances/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-all" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>Strategic Alliances</nobr></a></li>');
	d.write('</ul>');
	d.write('</li>');

	// Company  ----------------------------------------------------
	if (section == "com") {
		dirPath = ""; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "company/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../company/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-com" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>About Applied Financial</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'management.htm"><nobr>Management</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'contact-us.htm"><nobr>Contact Us</nobr></a></li>');
	d.write('</ul>');
	d.write('</li>');

	// News & Events  ----------------------------------------------------
	if (section == "new") {
		dirPath = "/news-and-events/"; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "news-and-events/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../news-and-events/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-new" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'articles.htm"><nobr>Articles</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>Latest News</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'press-releases.htm"><nobr>Press Releases</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'events.htm"><nobr>Events</nobr></a></li>');
	d.write('<li><a href="/webinars/"><nobr>Webinars</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'presentations.htm"><nobr>Presentations</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'research-reports.htm"><nobr>Research & Reports</nobr></a></li>');
	d.write('<li><a href="'+dirPath+'durations.htm"><nobr>Durations Newsletter</nobr></a></li>');
	d.write('</ul>');
	d.write('</li>');

	// Contact Us  ----------------------------------------------------
	if (section == "con") {
		dirPath = ""; classTxt = txtCurrent;
	} else if (section == "top") {
		dirPath = "contact-us/"; classTxt = txtNotCurrent;
	} else {
		dirPath = "../contact-us/"; classTxt = txtNotCurrent;
	}

	d.write('<li id="nav1-con" '+classTxt+'>');
	d.write('<a href="'+dirPath+'index.htm"></a>');
	d.write('<ul>');
	d.write('<li><a href="'+dirPath+'index.htm"><nobr>Contact Information</nobr></a></li>');
	d.write('</ul>');
	d.write('</li>');

}
//========================================================================================================
// Open a popup window.
//
function openPopup(dirPath, fileName, fileExt, fileWidth, fileHeight, titleTxt, headTxt, descTxt, copyright) {

	var windWidth, windHeight, s1, s2, showCopyright, scale;

	var debug = 0;
	var chromeTop = 25;
	var chromeRight = 6;
	var chromeBottom = 6;
	var chromeLeft = 6;
	var marginTop = 8;
	var marginRight = 8;
	var marginBottom = 8;
	var marginLeft = 8;
	var textAreaHeight = 40;
	var maxWindowWidth = 715;  //designed to not occlude 800x600
	var maxWindowHeight = 556;
	
	var padWidth = marginLeft + marginRight; //20;
	var padHeight = marginTop + textAreaHeight + marginBottom; //80;
	var maxImageWidth = maxWindowWidth - chromeLeft - chromeRight - padWidth; //6 chrome left, 6 chrome right, 10 pad left, 10 pad right
	var maxImageHeight = maxWindowHeight - chromeTop - chromeBottom - padHeight; // 24 chrome top, 6 chrome bottom, 10 pad top, 40 pad top, 10 pad bottom
	var fileNameFull = fileName + "." + fileExt;
	var filePath = dirPath + fileNameFull;
	
	if ((fileWidth > maxImageWidth) || (fileHeight > maxImageHeight)) {
		if ((fileWidth - maxImageWidth) > (fileHeight - maxImageHeight)) {
			artwork = "<img src='" + filePath + "' align=bottom border=0 alt='Primal' width='" + maxImageWidth + "'>";
			scale = maxImageWidth / fileWidth;
		} else {
			artwork = "<img src='" + filePath + "' align=bottom border=0 alt='Primal' height='" + maxImageHeight + "'>";
			scale = maxImageHeight / fileHeight;
		}
	} else {
		artwork = "<img src='" + filePath + "' align=bottom border=0 alt='Primal'>";
		scale = 1;
	}
	if (debug) alert("scale:" + scale);

	/*windWidth = Number(fileWidth) + padWidth + chromeLeft + chromeRight;				//windWidthDiv2 = Math.floor(windWidth/2);
	windHeight = Number(fileHeight) + padHeight + chromeTop + chromeBottom -30;			//windHeightDiv2 = Math.floor(windHeight/2);
	if (debug) alert("windWidth:" + windWidth + ";  windHeight:" + windHeight);
	
	if (windWidth > maxWindowWidth) {
		if (debug) alert("setting maxWindowWidth:" + maxWindowWidth);
		windWidth = maxWindowWidth;
	}

	if (windWidth > screen.availWidth) {
		//windWidth = screen.availWidth - 60;
	}

	if (windHeight > maxWindowHeight) {
		if (debug) alert("setting maxWindowHeight:" + maxWindowHeight);
		windHeight = maxWindowHeight;
	}

	if (windHeight > screen.availHeight) {
		//windHeight = screen.availHeight - 30;
	} */

	if (titleTxt == "") {
		titleTxt = "Primal";
	}
	
	showCopyright = (copyright != "") ? true : false;
	
	// Values for width/height passed to window.open() is for client area ONLY, so subtract window chrome from the maximum size.
	windWidth = maxWindowWidth - chromeLeft - chromeRight;
	windHeight = maxWindowHeight - chromeTop - chromeBottom;
	
	// Dreamweaver MX misinterprets the explicit appearance of the script tag in document.writeln calls, so obfuscate it:
	s1 = "script";
	s2 = "<" + s1 + " language='JavaScript'>function disableRightClick(){return false;} function x(){window.close();} document.oncontextmenu=disableRightClick;</" + s1 + ">"
	s2 = "";

	w=window.open("","","toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=yes,width="+windWidth+",height="+windHeight+",screenX="+((screen.availWidth/2)-(windWidth/2))+",screenY="+((screen.availHeight/2)-(windHeight/2)-15)+",left="+((screen.availWidth/2)-(windWidth/2))+",top="+((screen.availHeight/2)-(windHeight/2)-15)+",status=no");
	w.document.open();
	w.document.writeln("<html><head><title>" + titleTxt + "</title>");
	w.document.writeln("<style>");
	w.document.writeln("body {margin:8px 8px 8px 8px;}"); //cursor:pointer; cursor:hand
	w.document.writeln(".t1 {font-size:9px; font-family:Verdana,Arial,Helvetica,sans-serif; color:#5F7A7A;}");
	w.document.writeln("a.close {font-size:9px; font-family:Verdana, Arial,Helvetica,sans-serif; color:#1567A3;}");
	w.document.writeln("a.close:hover {font-size:9px; font-family:Verdana, Arial,Helvetica,sans-serif; color:#9D1847;}");
	w.document.writeln("p {padding-top:0px; padding-bottom:6px; margin:0px;}");
	w.document.writeln(".head {color:#B79728; font-weight:bold; padding-bottom:6px;}");
	w.document.writeln(".copyright {font-size:9px; font-family:Verdana,Arial,Helvetica,sans-serif; color:#000000;padding-top:9px;}");
	w.document.writeln("</style>");
	w.document.writeln(s2);
	w.document.writeln("</head><body>");
	w.document.writeln("<table border=0 cellpadding=0 cellspacing=0 align=center valign=middle width='100%' height='100%' xonmousedown='x();'");
	w.document.writeln("<tr valign=top><td align=left valign=top class='t1'>");
	if (headTxt != "") {
		w.document.writeln("<div class='head'>" + headTxt + "</div>");
	}
	if (descTxt != "") {
		w.document.writeln(descTxt);
	}
	w.document.writeln("</td>");
	w.document.writeln("<td align=right valign=top class='t1' nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='close' href='javascript:window.close();'>Close this Window</a>");
	if (showCopyright) {
		w.document.writeln("<div class='copyright'>&copy; 2004 Applied Finanical Technology</div>");
	}
	w.document.writeln("</td>");
	w.document.writeln("</tr>");
	w.document.writeln("<tr><td valign=middle align=center colspan=2 class='art'>" + artwork + "</td></tr>");
	w.document.writeln("</table></body></html>");
	w.document.close();
}