//====================Preload Navigation====================
var myimages = new Array();
function preloading(){
	for (x=0; x<preloading.arguments.length; x++){
		myimages[x] = new Image();
		myimages[x].src = preloading.arguments[x];
	}
}
preloading("images/nav-home_n.gif",
		   "images/nav-home_x.gif",
		   "images/nav-products_n.gif",
		   "images/nav-products_x.gif",
		   "images/nav-foundations_n.gif",
		   "images/nav-foundations_x.gif",
		   "images/nav-design_n.gif",
		   "images/nav-design_x.gif",
		   "images/nav-video_n.gif",
		   "images/nav-video_x.gif",
		   "images/nav-press_n.gif",
		   "images/nav-press_x.gif",
		   "images/nav-history_n.gif",
		   "images/nav-history_x.gif",
		   "images/nav-customers_n.gif",
		   "images/nav-customers_x.gif",
		   "images/nav-recognition_n.gif",
		   "images/nav-recognition_x.gif",
		   "images/nav-careers_n.gif",
		   "images/nav-careers_x.gif",
		   "images/nav-contact_n.gif",
		   "images/nav-contact_x.gif");


//====================Flash Popup Function====================

/* Notes: if you are editing this and need to change the flash heres whats what.
 * 
 * id = the id of the hidden div that will be displayed when you click the thumb. eg. vis1, vis2... etc.
 * flash = the id of the flash that will be targeted when you click the thumb. eg. flash1, flash2... etc.
 * swf = change this number to anything but 0 to show flash content, else it will display a non breaking space. 
 *			this is to fix IE's problem when you close it keeps playing the video even when you cannot see anything.
 * vis = this changes the style of "display: none;" to "display: block;" to make everything visible.
 * (note: you must name the swf file the same as the div that is displayed. eg: id="vis1" , vis1.swf because it gets its name from the "id" variable.)
 * 
 * call this in the html like this: <a href="javascript:vid('vid1','flash1',1,'block')"> to turn it on.
 * and if you want to shut it off like this: <a href="javascript:vid('vid1','flash1',0,'none')">
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
function vid(id,flash,swf,vis,width,height){
	if(width==undefined) width = '320';
	if(height==undefined) height = '240';
	document.getElementById(id).style.display=vis;
	if (swf == 0){
		document.getElementById(flash).innerHTML="&nbsp;";
	}
	else{
		document.getElementById(flash).innerHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' id='vid' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='vids/"+id+".swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='vids/"+id+".swf' quality='high' wmode='transparent' width='"+width+"' height='"+height+"' name='vid' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	}
}


//====================Image Rollover====================
var ROLLOVER_CLASSNAME = 'rollover';
var OFF_SUFFIX = '_n';
var ON_SUFFIX = '_x';

/**********************************************************
 * Here's the meat of the operation - this function sets 
 * up mouseover functions on all IMG tags with a 
 * classname of ROLLOVER_CLASSNAME.
 *********************************************************/
function enableMenuImageRollovers()
{
	var imgs = getElementsByTagAndClassName('img',ROLLOVER_CLASSNAME);
	
	for(var i = 0; i < imgs.length; i++)
	{
		var img=imgs[i];
		
		//Create a couple of new image objects.
		var imgOn = new Image();
		var imgOff = new Image();
		
		//Set their source (this triggers the browser to load them).
		imgOn.src=img.src.replace(OFF_SUFFIX,ON_SUFFIX);
		imgOff.src=img.src.replace(ON_SUFFIX,OFF_SUFFIX);
		
		//Bind them to the original image.
		img.imgOn = imgOn;
		img.imgOff = imgOff;
		
		//Switch to them on mouseover/mouseout.
		img.onmouseover=function() {
			this.src=this.imgOn.src;
		}
		
		img.onmouseout=function() {
			this.src=this.imgOff.src;
		}
	}

}

/**********************************************************
 * A handy utility function that lets you find elements 
 * with a certain className, which is a common need.
 * This will properly support cases where there are 
 * multiple class names assigned to an object.
 *********************************************************/
function getElementsByTagAndClassName(tagName, className)
{
	var items = new Array();
	var elems = document.getElementsByTagName(tagName);
	for(var i = 0; i < elems.length; i++)
	{
		var elem = elems[i];
		var classNames = elem.className.split(" ");
		for (var j = 0; j < classNames.length; j++)
		{
			if(classNames[j] == className)
			{
				items.push(elem);
			}
		}
	}
	return items;
}


/**********************************************************
 * The 'bootstrapper' that loads the behavior when the 
 * page loads. 
 * This will perform any existing onload functions, 
 * then execute the image rollover setup.
 *********************************************************/

if (window.onload)
{
	//Hang on to any existing onload function.
	var existingOnload = window.onload;
}

window.onload=function(ev){
	//Run any onload that we found.
	if (existingOnload)
	{
		existingOnload(ev);
	}
	
	//Don't bother loading unless getElementsByTagName is supported.
	if (document.getElementsByTagName)
	{
		enableMenuImageRollovers();
	}
};