/*
var onImg = new Array();
var offImg = new Array();

var imageDir = documentRoot + "graphics/";
var imageNames = new Array('nav_newproducts','nav_daisy','nav_powerline','nav_powerlinesl','nav_winchester','nav_avanti','nav_precisionmax','nav_collectibles','nav_logomerch');
if (document.images) {
  for (var i = 0; i < imageNames.length; i++) {
    refName = imageNames[i];
    imgName = imageDir + refName + "_off.gif";
	imgHLName = imageDir + refName + "_on.gif";
	onImg[refName] = new Image();
	offImg[refName] = new Image();
	onImg[refName].src = imgHLName;
	offImg[refName].src = imgName;
  };
};

// Swap images on based on a name array
function imageOn(name) {
   if (document.images) {
    document.images[name].src = onImg[name].src
   };
};

// Swap images off based on a name array
function imageOff(name) {
   if (document.images) {
    document.images[name].src = offImg[name].src
   };
};
*/

//Functinons for New Products page DHTML
/*
var allGuns = new Array( '2004_1000sb', '2004_1000sc', '2004_840bgrizzly', '2004_840bgrizzlyk', '2004_backyard', '2004_pl2856', '2004_pl617x', '2004_pl856k', '2004_pl8856', '2004_pltp953', '2004_redryder' );
var allAccessories = new Array(  '2004_plthenatural', '2004_sb6shooter', '2004_sbtargetholders', '2004_sbtargets' );

var allGuns = new Array( '2004_pl8856', '2004_pl856k', '2004_pl880k', '2004_840bgrizzly', '2004_redryder', '2004_840bgrizzlyk', '2004_pltp953', '2004_1000sc', '2004_1000sb', '2004_pl617x' );
var allAccessories = new Array( '2004_sb6shooter', '2004_sbtargetholders', '2004_plthenatural', '2004_sbtargets' );
*/
var daisyguns = new Array( '2005_nodaisy' );
var plguns = new Array( '2005_pl_kit_953', '2005_pl_r_901' ); // , '2005_pl_p_008'
var slingshots = new Array( '2005_nodaisy' ); // '2005_pl_sl_erg'
var winchester = new Array( '2005_nowinchester' );
var accessories = new Array( '2005_lasersight' ); // '2005_glasses'


function showNewProduct (whichProduct)
	{
	el = 'product_' + whichProduct;
	document.getElementById(el).style.display = 'block';
	}

function hideNewProduct (whichProduct)
	{
	el = 'product_' + whichProduct;
	//alert (el);
	document.getElementById(el).style.display = 'none';
	}


function showAllNewProducts (productType)
	{
	switch (productType)
		{
		case 'daisyguns' :
			hideAllNewProducts ();
			for ( var i = 0; (i <= (daisyguns.length - 1)); i++) 
				{
				showNewProduct (daisyguns[(i)]);
				}
			break;
			
		case 'plguns' :
			hideAllNewProducts ();
			for ( var i = 0; (i <= (plguns.length - 1)); i++) 
				{
				showNewProduct (plguns[(i)]);
				}
			break;
			
		case 'slingshots' :
			hideAllNewProducts ();
			for ( var i = 0; (i <= (slingshots.length - 1)); i++) 
				{
				showNewProduct (slingshots[(i)]);
				}
			break;
			
		case 'winchester' :
			hideAllNewProducts ();
			for ( var i = 0; (i <= (winchester.length - 1)); i++) 
				{
				showNewProduct (winchester[(i)]);
				}
			break;
			
		case 'accessories' :
			hideAllNewProducts ();
			for ( var i = 0; (i <= (accessories.length - 1)); i++) 
				{
				showNewProduct (accessories[(i)]);
				}
			break;

		default :
			for ( var i = 0; (i <= (daisyguns.length - 1)); i++) 
				{
				showNewProduct (daisyguns[(i)]);
				}
			for ( var i = 0; (i <= (plguns.length - 1)); i++) 
				{
				showNewProduct (plguns[(i)]);
				}
			for ( var i = 0; (i <= (slingshots.length - 1)); i++) 
				{
				showNewProduct (slingshots[(i)]);
				}
			for ( var i = 0; (i <= (winchester.length - 1)); i++) 
				{
				showNewProduct (winchester[(i)]);
				}
			for ( var i = 0; (i <= (accessories.length - 1)); i++) 
				{
				showNewProduct (accessories[(i)]);
				}
			break;
			
		}
	}

function hideAllNewProducts (productType)
	{
	switch (productType)
		{
		case 'daisyguns' :
			for ( var i = 0; (i <= (daisyguns.length - 1)); i++) 
				{
				hideNewProduct (daisyguns[(i)]);
				}
			break;
			
		case 'plguns' :
			for ( var i = 0; (i <= (plguns.length - 1)); i++) 
				{
				hideNewProduct (plguns[(i)]);
				}
			break;
			
		case 'slingshots' :
			for ( var i = 0; (i <= (slingshots.length - 1)); i++) 
				{
				hideNewProduct (slingshots[(i)]);
				}
			break;
			
		case 'winchester' :
			for ( var i = 0; (i <= (winchester.length - 1)); i++) 
				{
				hideNewProduct (winchester[(i)]);
				}
			break;
			
		case 'accessories' :
			for ( var i = 0; (i <= (accessories.length - 1)); i++) 
				{
				hideNewProduct (accessories[(i)]);
				}
			break;
			
		default :
			for ( var i = 0; (i <= (daisyguns.length - 1)); i++) 
				{
				hideNewProduct (daisyguns[(i)]);
				}
			for ( var i = 0; (i <= (plguns.length - 1)); i++) 
				{
				hideNewProduct (plguns[(i)]);
				}
			for ( var i = 0; (i <= (slingshots.length - 1)); i++) 
				{
				hideNewProduct (slingshots[(i)]);
				}
			for ( var i = 0; (i <= (winchester.length - 1)); i++) 
				{
				hideNewProduct (winchester[(i)]);
				}
			for ( var i = 0; (i <= (accessories.length - 1)); i++) 
				{
				hideNewProduct (accessories[(i)]);
				}
			break;
			
		}
	}


function scrollToProducts ()
	{
	window.scrollTo(0, 550 );
	}



/*
 * Function for talking to Flash on Home Page movies
 * Flash movie "listener" for _level0:command variable
 */
function sendFlash (whichMovie, a)
	{
	if ('main' == whichMovie)
		{
		document.main.setVariable('command', a);
		}
	else if ('overlay' == whichMovie)
		{
		document.overlay.setVariable('command', a);
		}
	else if ('all' == whichMovie)
		{
		document.main.setVariable('command', a);
		document.overlay.setVariable('command', a);
		}
	}

/*
 * Functions for Flash to talk to JavaScript through fscommands
 */
var htmlLoaded = 0;
var movie1Loaded = 0;
var movie2Loaded = 0;

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1; // Handle all the the FSCommand messages in a Flash movie

// functions from Flash Movie1
function main_DoFSCommand(command, args)
	{
  var movie1Obj = InternetExplorer ? main : document.main;

	switch (command)
		{
		case "browserAlert" :
			alert (args);
			break;

		case "checkHtmlLoaded" :
			sendFlash ('main', 'htmlLoaded');
			break;

		case"reportMovieLoaded" :
			sendFlash ('overlay', 'otherMovieLoaded');
			movie1Loaded = 1;
			break;

		case "checkOtherMovieLoaded" :
			if (1 == movie2Loaded)
				{
				sendFlash ('main', 'otherMovieLoaded')
				}
			else
				{
				return;
				}
			break;

		} // end switch
	} // end function

// functions from Flash Movie2
function overlay_DoFSCommand(command, args)
	{
  var movie1Obj = InternetExplorer ? overlay : document.overlay;

	switch (command)
		{
		case "browserAlert" :
			alert (args);
			break;

		case "checkHtmlLoaded" :
			sendFlash ('overlay', 'htmlLoaded');
			break;

		case"reportMovieLoaded" :
			sendFlash ('main', 'otherMovieLoaded');
			movie2Loaded = 1;
			break;

		case "checkOtherMovieLoaded" :
			if (1 == movie1Loaded)
				{
				sendFlash ('overlay', 'otherMovieLoaded')
				}
			else
				{
				return;
				}
			break;

		} // end switch
	} // end function

function setHtmlLoaded()
	{
	htmlLoaded = 1;
	if ((document.getElementById) && (navigator.appName.indexOf("Microsoft") != -1) && (navigator.appVersion.indexOf("MSIE 5") == -1))
		{
		sendFlash ('main', 'htmlLoaded');
		sendFlash ('overlay', 'htmlLoaded');
		}
	}


function popUp(whatType)
{
	var popUpURL, popupName, popUpParams;
	
	switch (whatType)
	{
	case "aiae_award" :
		popUpURL = documentRoot + '_managepassword.phtml';
		popupName = 'managePassword';
		popUpParams = 'toolbar=1,status=0,scrollbars=1,resizable=0,height=400,width=600';
		break;

	default :
		if (arguments.length >= 1)
		{
			alert (arguments.length);
		}
		else
		{
		return false;
		}
		break;
	}
	window.open(popUpURL, popupName, popUpParams);
}

function returnFalse ()
{
	return false;
}










function affidavitformcheck()
{
	if (document.getElementById)
	{
		if ( document.getElementById('pending_membership') )
		{
			if ( (document.getElementById('pending_membership').value.indexOf('Yes') == -1) && (document.getElementById('pending_membership').value.indexOf('Affidavit') == -1) )
			{
				alert ('You have SELECTED that you DO NOT have an affidavit of age on file. \n \nYou must have an affidavit of age on file BEFORE you place an order. \nIf you already have an affidavit of age on file, please select "Yes-Affidavit currently on file," above.\n');
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}





/****************************
 Global variables for CADDIE sites.
****************************/
if (!documentRoot) var documentRoot = '/';
if (!graphicsRoot) var graphicsRoot = documentRoot + '_graphics/';
if (!linkRoot) var linkRoot = documentRoot + '_link/';
if (!flashRoot) var flashRoot = documentRoot + '_flash/';
if (!calendarRoot) var calendarRoot = documentRoot + '_calendar/';
if (!mailing_listsRoot) var mailing_listsRoot = documentRoot + '_mailing_lists/';

// Optional DeBugging Output, set to 1 or true for output window
if (!dbo) var dbo = 0;




/****************************
 documentOnloadQ()
 
 How it works:
 Create a queue of functions to run once the window has loaded all
 HTML-specified content
 
 Use:
 	function documentOnloadQ()
	{
		functionToExecute();
		anotherFunctionToExecute();
		anotherFunctionTo... and so on...
	}
 	window.onload = documentOnloadQ; 

 Returns: n/a
****************************/
function documentOnloadQ()
{
}
window.onload = documentOnloadQ; 




/****************************
 createDbo()
 
 How it works:
 Creates textarea#debugoutput, appended within <body> based on if (dbo == 1).
 
 Use:
 	var dbo = 1;
 	createDbo()
 	dbo.value += 'This will append a line to the dbo box for all to see\n'

 Returns: n/a
****************************/
if (dbo == 1)
{
	// create textarea.dbo node for placement
	dbo = document.createElement('textarea');
	dbo.id = 'debugoutput';
	dbo.wrap = 'off';
	dbo.style.position = 'fixed';
	dbo.style.left = '10px';
	dbo.style.bottom = '10px';
	dbo.style.height = '100px';
	dbo.style.width = '98%';
	dbo.style.zIndex = '50000';
	dbo.style.backgroundColor = '#eeeeee';
	dbo.style.borderWidth = '1px';
	dbo.style.borderStyle = 'solid';
	dbo.style.borderColor = '#999999';
	dbo.style.padding = '2px';
	dbo.style.overflow = 'auto';
	document.getElementsByTagName('body').item(0).appendChild(dbo);
	document.getElementsByTagName('body').item(0).style.paddingBottom = dbo.style.height;
	dbo = document.getElementById('debugoutput');
	dbo.value += ("dbo created successfully!\n");
}
else if (dbo == 'undefinded')
{
	dbo = new Array();
}






/****************************
 Loaded Announce
****************************/
dbo.value += ("global.js loaded!\n");






