// /_scripts/global.js
//handle all JS errors with function pointer to onError()
window.onerror = onError;

//===============================================================================================================================================================
//=	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 so give a development error message.
	if ( window.location.href.indexOf('dev.myhealthysavings.com') > 0 )
		window.alert(sPrompt);
		
	return true;
 }

var iCouponTimes = 0;
function promoLoad(layerIndex, sCID)
{
	if (! document.all )
	{
		switch (layerIndex)
		{
			case 0:
				document.promoLayer_1.load("http://offers.brightstreet_DISABLED.com/banners/promo1.cfm?cid=" + sCID, 250);
				break;
			case 1:
				document.promoLayer_2.load("http://offers.brightstreet_DISABLED.com/banners/promo2.cfm?cid=" + sCID, 250);
				break;
				
		}
	}
		
	return;
}


function showDetails (sFamily, sManufacturer, sValue, sPromo )
{
	if ( sPromo != '00000' ) 
	{
		parent.window.location = "http://www.myhealthysavings.com/products/family.asp?family=" + sFamily + "&promoid=" + sPromo + "&value=" + sValue
	}
	else
	{
		switch (sValue)
		{
			case '00none':
				window.open("http://www.myhealthysavings.com/services","new_win");
				break;
			case '01none':
				window.open("http://www.myhealthysavings.com/_errors/petassure.asp","new_win");
				break;
			case '02none':
				window.open("http://www.myhealthysavings.com/services/cards/pharmacy_takira.asp","new_win");
				break;
			default:
				window.open("http://www.myhealthysavings.com","new_win");
		}
	}
}

function addToCart(sFamily, sManufacturer, sValue, sPromo)
{
	top.window.location = "http://www.myhealthysavings.com/products/family.asp?family=" + sFamily + "&promoid=" + sPromo + "&value=" + sValue
}


function OpenWin(theURL) {
    var n = window.open(theURL,"new_win","width=700,height=500,status=no,menubar=no,scrollbars=no,resizable=no")
  }

  
  
var imgHome = new Image();
var imgServices = new Image();
var imgProducts = new Image();
var imgTools = new Image();
var imgMembers = new Image();

imgHome.src = "/images/nav_home.gif";
imgServices.src = "/images/nav_services.gif";
imgProducts.src = "/images/nav_products.gif";
imgTools.src = "/images/nav_tools.gif";
imgMembers.src = "/images/nav_members.gif";

function showDescription(iTab)
{
	switch(iTab)
	{
		case 0:
			document.images.description.src = "/images/nav_home.gif";
			return;
		case 1:
			document.images.description.src = "/images/nav_services.gif";
			return;
		case 2:
			document.images.description.src = "/images/nav_products.gif";
			return;
		case 3:
			document.images.description.src = "/images/nav_tools.gif";
			return;
		case 4:
			document.images.description.src = "/images/nav_members.gif";
			return;
	}
}

function hideDescription(iTab)
{
	document.images.description.src = "/images/aaaaaa.gif";
}
 