// /_scripts/global.js
window.onerror = onError;

var w3c = (document.getElementById) ? 1:0
n = (document.layers) ? 1:0
ie = (document.all) ? 1:0
ie6 = (document.getElementById) ? 1:0
var pc	= (navigator.platform.indexOf('Win') == 0) ? 1:0;
var mac	= (navigator.platform.indexOf('Mac') == 0) ? 1:0;

var start_div = 1;

function show_next(id){
	var next_div = 	parseInt(id) + 1;
	
	if (id == 5){
		next_div = 1;
	}	

	if (n)
	{ 
		document.layers['Person' + id].visibility = "hide";
		document.layers['Person' + next_div].visibility = "show";
		
		document.layers['Text' + id].visibility = "hide";
		document.layers['Text' + next_div].visibility = "show";
	}
	else if (ie6) 
	{
		document.getElementById('Person' + id).style.visibility = "hidden";
		document.getElementById('Person' + next_div).style.visibility = "visible";
		
		document.getElementById('Text' + id).style.visibility = "hidden";
		document.getElementById('Text' + next_div).style.visibility = "visible";
	}
	else if (ie)
	{ 		
		document.all['Person' + id].style.visibility = "hidden";
		document.all['Person' + next_div].style.visibility = "visible";
		
		document.all['Text' + id].style.visibility = "hidden";
		document.all['Text' + next_div].style.visibility = "visible";
	} 
	
	
	start_div = next_div
}

function show_pervious(id){
	var pervious_div = 	parseInt(id) - 1;
	
	
	if (id == 1){
		pervious_div = 5;
	}
	
	if (n)
	{ 
		document.layers['Person' + id].visibility = "hide";
		document.layers['Person' + pervious_div].visibility = "show";
		
		document.layers['Text' + id].visibility = "hide";
		document.layers['Text' + pervious_div].visibility = "show";
	}
	else if (ie6) 
	{
		document.getElementById('Person' + id).style.visibility = "hidden";
		document.getElementById('Person' + pervious_div).style.visibility = "visible";
		
		document.getElementById('Text' + id).style.visibility = "hidden";
		document.getElementById('Text' + pervious_div).style.visibility = "visible";
	}
	else if (ie)
	{ 				
		document.all['Person' + id].style.visibility = "hidden";
		document.all['Person' + pervious_div].style.visibility = "visible";
		
		document.all['Text' + id].style.visibility = "hidden";
		document.all['Text' + pervious_div].style.visibility = "visible";
	} 	
	
	start_div = pervious_div
}

function show(id){
	// Netscape
	if (n)
	{
		document.layers[id].visibility = "show";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{
		document.getElementById(id).style.visibility = "visible";
	}
	else if (ie)
	{
		document.all[id].style.visibility = "visible";			
	}
}

function hide_graph()
{
	// Netscape 4
	if (n)
	{
		for (i=0; i < 8; i++) 
		{
			document.layers['graph' + i].visibility = "hide";
		}
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{
		for (i=0; i < 8; i++) 
		{
			document.getElementById('graph' + i).style.visibility = "hidden";
		}
	}
	else if (ie)
	{
		for (i=0; i < 8; i++) 
		{
			document.all['graph' + i].visibility = "hidden";
		}
	}
}

function hide_graph_retail()
{
	// Netscape 4
	if (n)
	{
		for (i=0; i < 11; i++) 
		{
			document.layers['graph' + i].visibility = "hide";
		}
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{
		for (i=0; i < 11; i++) 
		{
			document.getElementById('graph' + i).style.visibility = "hidden";
		}
	}
	else if (ie)
	{
		for (i=0; i < 11; i++) 
		{
			document.all['graph' + i].visibility = "hidden";
		}
	}
}

function show_pie_arrows(id){		

	// Netscape 4
	if (n)
	{
		for (i=1; i < 8; i++) 
		{
			document.layers['gray_arrow' + i].visibility = "visible";
			document.layers['over_arrow' + i].visibility = "hidden";
		}	
		
		document.layers['gray_arrow' + id].visibility = "hidden";
		document.layers['over_arrow' + id].visibility = "visible";
		
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{	
		for (i=1; i < 8; i++) 
		{
			document.getElementById('gray_arrow' + i).style.visibility = "visible";
			document.getElementById('over_arrow' + i).style.visibility = "hidden";
		}	
		
		document.getElementById('gray_arrow' + id).style.visibility = "hidden";
		document.getElementById('over_arrow' + id).style.visibility = "visible";
	
	}
	else if (ie)
	{
		for (i=1; i < 8; i++) 
		{
			document.all['gray_arrow' + i].visibility = "visible";
			document.all['over_arrow' + i].visibility = "hidden";
		}	
		
		document.all['gray_arrow' + id].visibility = "hidden";
		document.all['over_arrow' + id].visibility = "visible";
	}
	
}

function show_pie_text(id, color){		

	// Netscape 4
	if (n)
	{
		for (i=1; i < 8; i++) 
		{
			document.layers['pietext' + i].color = "#000000";
		}	
		
		
			document.layers['pietext' + id].color = color;
		
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{	
		for (i=1; i < 8; i++) 
		{
			document.getElementById('pietext' + i).style.color = "#000000";
		}	
		
			document.getElementById('pietext' + id).style.color = color;
	}
	else if (ie)
	{
		for (i=1; i < 8; i++) 
		{
			document.all['pietext' + i].color = "#000000";
		}
		
			document.all['pietext' + id].color = color;
	}
	
}

function show_pie_arrows_retail(id){		

	// Netscape 4
	if (n)
	{
		for (i=1; i < 11; i++) 
		{
			document.layers['gray_arrow' + i].visibility = "visible";
			document.layers['over_arrow' + i].visibility = "hidden";
		}	
		
		document.layers['gray_arrow' + id].visibility = "hidden";
		document.layers['over_arrow' + id].visibility = "visible";
		
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{	
		for (i=1; i < 11; i++) 
		{
			document.getElementById('gray_arrow' + i).style.visibility = "visible";
			document.getElementById('over_arrow' + i).style.visibility = "hidden";
		}	
		
		document.getElementById('gray_arrow' + id).style.visibility = "hidden";
		document.getElementById('over_arrow' + id).style.visibility = "visible";
	
	}
	else if (ie)
	{
		for (i=1; i < 11; i++) 
		{
			document.all['gray_arrow' + i].visibility = "visible";
			document.all['over_arrow' + i].visibility = "hidden";
		}	
		
		document.all['gray_arrow' + id].visibility = "hidden";
		document.all['over_arrow' + id].visibility = "visible";
	}
	
}

function show_pie_text_retail(id, color){		

	// Netscape 4
	if (n)
	{
		for (i=1; i < 11; i++) 
		{
			document.layers['pietext' + i].color = "#000000";
		}	
		
		
			document.layers['pietext' + id].color = color;
		
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{	
		for (i=1; i < 11; i++) 
		{
			document.getElementById('pietext' + i).style.color = "#000000";
		}	
		
			document.getElementById('pietext' + id).style.color = color;
	}
	else if (ie)
	{
		for (i=1; i < 11; i++) 
		{
			document.all['pietext' + i].color = "#000000";
		}
		
			document.all['pietext' + id].color = color;
	}
	
}


function hide(id)
{
	// Netscape 4
	if(ns4){
		var lyrs = document.layers;
		for (i=0; i < lyrs.length; i++)
		{
			lyrs[i].visibility = "hide";
		}
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6)
	{
      var lyrs = document.getElementsByTagName("DIV");
      for (i=0; i < lyrs.length; i++)
	  {
         lyrs[i].style.visibility = "hidden";
      }
	}
}

//===============================================================================================================================================================
//=     FUNCTION:       onError() 
//=     PARAMETERS:     sMessage as string is the error reason 
//=						sUrl as string is the URL that raised the error 
//=						sLine is the line number of the error 
//=     RETURNS:        integer 
//=     PURPOSE:        All javascript errors are directed to this funciton by window.error 
//=						The true return value supresses any browser javascript errors. 
//=     AUTHOR:         Steve Jansen, Byte Interactive <stj@byteinteractive.com> 
//=     DATE:           Decmeber 11th, 2000 
//===============================================================================================================================================================
function onError(sMessage, sURL, sLine) 
{ 
        var sPrompt; 
        sPrompt = "________________________________________________________\n\n" 
        sPrompt += "A client-side javascript error has occured.\n" 
        sPrompt += "________________________________________________________\n\n" 
        sPrompt += "Line:\t" + sLine + "\n" 
        sPrompt += "Reason:\t" + sMessage + "\n" 
        sPrompt += "URL:\t" + sURL + "\n" 
                
        //test to see if this is the development site 
      	if (location.href.indexOf('byteinteractive.com') > 0) 
                window.alert(sPrompt); 
                
        return true; 
 } 

//===============================================================================================================================================================
//=	FUNCTION: 	onLoad()
//=	PARAMETERS:	none
//=	RETURNS:	true
//=	PURPOSE:	Event handler for onload of all pages
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 29th, 2000
//===============================================================================================================================================================
function onLoad()
{ 
	cacheImages();	//function to cache all rollover images
	//window.status = 'Welcome To ';
	return true;
}

//===============================================================================================================================================================
//=	FUNCTION: 	onResize()
//=	PARAMETERS:	none
//=	RETURNS:	true
//=	PURPOSE:	Event handler for resize of all pages in IE4+
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 29th, 2000
//===============================================================================================================================================================
function onResize()
{ 
	if (w3c)
		location.reload();
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	cacheImages()
//=	PARAMETERS:	none
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function preloads (caches) all "on" state images.
//=				Call this function from the body onload event.
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function cacheImages()
{
	var i;
	
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_off\.(gif|jpg)/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off.", "_on.");
		}
	}
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	setImage()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function changes the src of oImage to the "on" state
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function setImage(oImage)
{
	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			document.images[i].src.replace("_on.", "_off.");
	}
	
	//now set the image to be in the "on" state		
	oImage.src = oImage.src.replace("_off.", "_on.");
				
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	clearImages()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function resets all images to their "off" state upon the mouseout event
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.", "_off.");
	}
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	openWindow()
//=	PARAMETERS:	url, name, w, h, rs, scr, cen
//=	RETURNS:	null
//=	PURPOSE:	Used for opening a new window with set properties
//=	AUTHOR:		David Alperovich, Byte Interactive <dalperovich@byteinteractive.com>
//= UPDATED:	David Whalen, Byte Interactive <david.whalen@byteinteractive.com>
//=	DATE:		December 11, 2001
//===============================================================================================================================================================
function openWindow(url, name, width, height, resize, scroll, center)
{
	var sParams = '';
	name = (name == null) ? '' : name;

	sParams += 'width=' + width;
	sParams += ',height=' + height;
	sParams += (resize || resize == 'true') ? ',resizable=yes' : ',resizable=no';
	sParams += (scroll || scroll == 'true') ? ',scrollbars=yes' : ',scrollbars=no';
	sParams += (center || center == 'true') ? ',left=' + ((screen.width - width) / 2) : '';
	sParams += (center || center == 'true') ? ',top=' + ((screen.height - height) / 2) : '';

	window.name = 'opener';
	var popupWin = window.open(url, name, sParams);
	popupWin.focus();
	return;
}

//===============================================================================================================================================================
//  FUNCTION:   getDHTMLObj
//  ARGUMENTS:  theStr - String to decode
//  PURPOSE:    Return a DHTML object, based on browser version
//  RETURNS:    Object
//  AUTHOR:     David Whalen <dw@byteinteractive.com>
//  DATE:       October 25, 2001
//===============================================================================================================================================================
function getDHTMLObj(objName)
{
	if (document.getElementById)
		return document.getElementById(objName);
	else if (document.all)
		return document.all[objName];
	else if (document.layers)
		return document.layers[objName];
	else
		return null;
} 

function openHelp()
{
	window.open('/market/recovery_calc_help.aspx','help','scrollbars=yes,status=no,width=450,height=400')
}

function openStudy()
{
	window.open('/study.aspx','study','scrollbars=yes,status=no,width=300,height=200')
}

function openHome()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="770" height="260" id="0_0_home_intro_770x260.swf" align="middle" VIEWASTEXT>');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="0_0_home_intro_770x260.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#ffffff" />');
document.write ('<param name="wmode" value="transparent">');
document.write ('<embed src="0_0_home_intro_770x260.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="770" height="260" name="0_0_home_intro_770x260.swf" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openAbout()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="770" height="260" id="1_0_about_intro_770x260" align="middle" VIEWASTEXT>');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="1_0_about_intro_770x260.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#cccccc" />');
document.write ('<param name="wmode" value="transparent">');
document.write ('<embed src="1_0_about_intro_770x260.swf" quality="high" wmode="transparent" bgcolor="#cccccc" width="770" height="260" name="1_0_about_intro_770x260" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openServices()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="770" height="260" id="2_0_professional_intro_770x260" align="middle" VIEWASTEXT>');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="2_0_professional_intro_770x260.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#cccccc" />');
document.write ('<param name="wmode" value="transparent">');
document.write ('<embed src="2_0_professional_intro_770x260.swf" quality="high" wmode="transparent" bgcolor="#cccccc" width="770" height="260" name="2_0_professional_intro_770x260" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openMarket()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="770" height="260" id="3_0_market_intro_770x260" align="middle" VIEWASTEXT>');document.write ('<param name="allowScriptAccess" value="sameDomain" />');document.write ('<param name="movie" value="3_0_market_intro_770x260.swf" />');document.write ('<param name="quality" value="high" />');document.write ('<param name="bgcolor" value="#cccccc" />');document.write ('<param name="wmode" value="transparent">');document.write ('<embed src="3_0_market_intro_770x260.swf" quality="high" wmode="transparent" bgcolor="#cccccc" width="770" height="260" name="3_0_market_intro_770x260" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.write ('</object>');
}

function openClients()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="770" height="260" id="4_0_satisfied_intro_770x260" align="middle" VIEWASTEXT>');document.write ('<param name="allowScriptAccess" value="sameDomain" />');document.write ('<param name="movie" value="4_0_satisfied_intro_770x260.swf" />');document.write ('<param name="quality" value="high" />');document.write ('<param name="bgcolor" value="#cccccc" />');document.write ('<param name="wmode" value="transparent">');document.write ('<embed src="4_0_satisfied_intro_770x260.swf" quality="high" wmode="transparent" bgcolor="#cccccc" width="770" height="260" name="4_0_satisfied_intro_770x260" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.write ('</object>');
}

function openManagement()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="770" height="650" id="1_2_management_770x600" align="middle" VIEWASTEXT>');document.write ('<param name="allowScriptAccess" value="sameDomain" />');document.write ('<param name="movie" value="1_2_management_770x600.swf" />');document.write ('<param name="quality" value="high" />');document.write ('<param name="bgcolor" value="#ffffff" />');document.write ('<param name="wmode" value="transparent">');document.write ('<embed src="1_2_management_770x600.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="770" height="650" name="1_2_management_770x600" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.write ('</object>');
}

