// browser sniffing
var agent 	= navigator.userAgent.toLowerCase ();
var isWinIE = (agent.indexOf ("msie") > -1) && (agent.indexOf ("mac") == -1);

function resizeTopFrame()
{
	try {
		var actualHeight = 0;
		
		// within I2O_MainFrame ?
		if (window.parent.frames["navBar"]!=null)
		{
			var h1 = window.parent.frames["navBar"].document.body.offsetHeight;
			var h2 = window.parent.frames["Large"].document.body.offsetHeight;
			
			// top vs left/right nav ?
			actualHeight = (h1>100) ? Math.max(h1,h2) : h1+h2;
		} else
		{
			actualHeight = document.body.offsetHeight;			
		}		
		onPageLoaded(actualHeight);
	} catch(e) {} //older browsers do not support scrollHeight
}

function shrinkTopFrame()
{
//	if (!isWinIE)
//		onPageLoaded(1); // force the smallest size allowed		
}

function scrollToTop()
{
	try { document.body.scrollTop = 0; } catch(e) {}; 
	try { document.documentElement.scrollTop = 0; } catch(e) {};
	try { window.scrollTo(0,0); } catch(e) {}; 
	try { window.top.I2O_scrollToTop(); } catch(e) {};
}

function onPageLoaded(actualHeight)
{
	try {
		window.top.I2O_pageLoaded(actualHeight); //function may not exist
	} catch(e) {}
}

function onMouseWheel(noScroll)
{
	if (window.event) // ie only
	{
		try {	
			var e = window.event;
			if ( noScroll == true) 
				e.cancelBubble = true; // no page scrolling
			else
				window.top.scrollPage(e.wheelDelta); // function may not exist
		} catch(ex) {}
	}
}

if(document.attachEvent)
	document.attachEvent("onmousewheel", onMouseWheel);


// rollover for buttons
var enable_rollover = false;

var ibacktotop,ibacktotop_o, igob,igob_o, iaddnote,iaddnote_o;
var iadd,iadd_o, iaddlong,iaddlong_o, iremove,iremove_o, iremovelong,iremovelong_o;
var ileft,ileft_o, iright,iright_o;	
var iviewpage,iviewpage_o, iviewprods,iviewprods_o;
var irettopage,irettopage_o, irettosearch,irettosearch_o;	

if (enable_rollover)
{
	// preload rollover images
	ibacktotop	 = new Image();	ibacktotop.src		= "images/site/backtoTop.gif";
	ibacktotop_o = new Image();	ibacktotop_o.src	= "images/site/backtoTop_o.gif";
	
	igob	= new Image();	igob.src	= "images/site/gob.gif";
	igob_o	= new Image();	igob_o.src	= "images/site/gob_o.gif";
	
	iaddnote 	= new Image();	iaddnote.src	= "images/site/addNote.gif";
	iaddnote_o 	= new Image();	iaddnote_o.src	= "images/site/addNote_o.gif";
	 
	iadd	= new Image();	iadd.src	= "images/site/addToList.gif";
	iadd_o	= new Image();	iadd_o.src	= "images/site/addToList_o.gif";
	
	iaddlong	= new Image();	iaddlong.src	= "images/site/addToList_long.gif";
	iaddlong_o	= new Image();	iaddlong_o.src	= "images/site/addToList_long_o.gif";
	
	iremove		= new Image();	iremove.src	= "images/site/onList.gif";
	iremove_o	= new Image();	iremove_o.src	= "images/site/onList_o.gif";
	
	iremovelong		= new Image();	iremovelong.src		= "images/site/onList_long.gif";
	iremovelong_o	= new Image();	iremovelong_o.src	= "images/site/onList_long_o.gif";
	
	ileft	= new Image();	ileft.src	= "images/site/arrowL.gif";
	ileft_o	= new Image();	ileft_o.src	= "images/site/arrowL_o.gif";

	iright		= new Image();	iright.src		= "images/site/arrowR.gif";
	iright_o	= new Image();	iright_o.src	= "images/site/arrowR_o.gif";
	
	iviewpage		= new Image();	iviewpage.src		= "images/site/viewPage.gif";
	iviewpage_o		= new Image();	iviewpage_o.src		= "images/site/viewPage_o.gif";
	
	iviewprods		= new Image();	iviewprods.src		= "images/site/viewProducts.gif";
	iviewprods_o	= new Image();	iviewprods_o.src	= "images/site/viewProducts_o.gif";
	
	irettopage		= new Image();	irettopage.src		= "images/site/returntoPage.gif";
	irettopage_o	= new Image();	irettopage_o.src	= "images/site/returntoPage_o.gif";
	
	irettosearch	= new Image();	irettosearch.src	= "images/site/returntoSearch.gif";
	irettosearch_o	= new Image();	irettosearch_o.src	= "images/site/returntoSearch_o.gif";
}

function setImage( o, img ) {
	if (enable_rollover)
		try { o.src = img.src; } catch(e) {}
}

function openRSSWindow(_target) {
	var _url = "rssWindow.jsp"; 
	if(_target != null) {
		var frame = parent.frames[_target];
		if(frame != null) {
			frame.location = _url;
		}
	}
	else {
		document.location = _url;
	}
}

function showRSSHelp() {
	var w = window.open("rssHelp.jsp", "rssHelp", "toolbar=0,status=0,location=0,menubar=0,scrollbars=1,height=600,width=600");
	if (w!=null)
		w.focus();
}

function openGoogleMap(address)
{
	var width = 550;
    var height = 420;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
    window.open("googlemap.jsp?address=" + address, "googlemap",  windowFeatures);	
}

// send email to a friend
function openEmail(from)
{
	var f = document.getElementById( "emailFrame" ); //dom
	var w = window.frames["emailFrame"]; //window
	if (f!=null && w!=null)
	{
		scrollToTop();
		
		f.style.display = "block";
		
		var loc = w.document.location.href; // as string
		if (loc.indexOf("emailWindow.jsp")<0)
		{
			// both work 
			f.src = "emailWindow.jsp?from="+from;
			//w.document.location = "emailWindow.jsp?from="+from;
		}
		else
			try { w.setFocus(); } catch(e) {}
	}	
}

function closeEmail()
{
	var f = document.getElementById( "emailFrame" );
	if (f!=null)
		f.style.display = "none";
}

