//add event generic function
function addEvent(elm, evType, fn, useCapture)
	{
			if(elm.addEventListener)
			{
				elm.addEventListener(evType, fn, useCapture);
				return true;
			}
			else if (elm.attachEvent)
			{
				var r = elm.attachEvent('on' + evType, fn);
				return r;
			}
			else
			{
				elm['on' + evType] = fn;
			}
	}
//Pop up window scripts
var newWindow = null;

function popUpWin(url, type, strWidth, strHeight){
        closeWin();
        if (type == "fullScreen"){
                strWidth = screen.availWidth - 10;
                strHeight = screen.availHeight - 160;
        }
        var tools="";
        if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=20,left=0, status=1, statusbar=1"; 
        if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+ strHeight+",left=0,top=20, status=1, statusbar=1"; 
        if (type == "noscroll") tools = "toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+ strHeight+",left=0,top=20, status=1, statusbar=1"; 		
        newWindow = window.open(url, 'newWin', tools);
        newWindow.focus();
}

function closeWin(){
        if (newWindow != null){
                if(!newWindow.closed)
                        newWindow.close();
        }
}

// end of intermediaries - what we do page functions


//---------------------------------------------------------------------------
addEvent(window, 'load', doJQueryFunctions, false);
function doJQueryFunctions()
{

	/*
	while I hate browser sniffing, Safari 2 does 
	not have full jQuery support, so we need to 
	disable some effects
	*/
	var unsupported_safari = (((navigator.userAgent.indexOf("Version/3")==-1)&&(navigator.userAgent.indexOf("Version/4")==-1))&&($.browser.safari));
	
	/* footer show/hide stuff */
	function footerExpandCollapse()
	{
		if(!unsupported_safari){
		
		//hide 'Explore Nationwide' for all pages
		$("#footer .footer-inner, #footer-homepage.collapse .footer-inner").hide();
		//hide 'Explore our products' but *only* on the home page
		$("#footer .footer-inner").hide();
		
		$("#footer h4 a").click(function(e){
				$("#footer .footer-inner").slideToggle('slow');
				return false;
			});
		$("#footer-homepage h4 a").click(function(e){
				$("#footer-homepage .footer-inner").slideToggle('slow');
				return false;
			});
		}
	}
	footerExpandCollapse();

	function highlightLinks(){
		$("body").append("<div id=\"highlightlink\"></div>")
		$("#highlightlink").css({
			"border-bottom":"5px solid yellow",
			"position":"absolute"
		});
		$("a:has(b)").each(function(){
			$(this).mousedown(function(){
				$("#highlightlink").css({        
					"display":"none" 
				});
			}).focus(function(){
				$("#highlightlink").stop(true,false).animate({        
					opacity: 1      
				},0).css({
					"width":$(this).find("b").width(),
					"height":$(this).find("b").height(),
					"left":$(this).find("b").offset().left,
					"top":$(this).find("b").offset().top
				}).animate({        
					opacity: 0      
				}, 3000 );	
			});	
		})
	}
	highlightLinks()
}
