// This javascript file contains global utility functions
	
	// This function appends an event handler to any object
	// obj is any DOM object, 
	// evType can be load unload click mouseover ect., 
	// fn is the name of the function you want to call when the event is fired
	function addEvent(obj, evType, fn){ 
		if (obj.addEventListener){ 
			obj.addEventListener(evType, fn, false); 
			return true; 
		} else if (obj.attachEvent){ 
			var r = obj.attachEvent("on"+evType, fn); 
			return r; 
		} else { 
			return false; 
		} 
	}
	
	// This function turns Google tracking on for external links
	function gTrack(url){
		if(document.location.href.indexOf("www.firstam.com")!=-1)
			pageTracker._trackPageview(url);
	}
	
	// This function handles the click of a list item on list pages
	var eLink=false;
	function handleListEvent(e,url,urlTarget){
		if(e.type=="click" && eLink==false){
			if(urlTarget=="popup"){
				OpenWindow(url,'750','500');
			}else if(urlTarget=="_blank"){
				OpenWindow(url,'750','500','scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes');
			}else{
				document.location.href=url;
			}
		}else if(e.type=="mouseover"){
			eLink=true;
		}else if (e.type=="mouseout"){
			eLink=false;
		}
	}
	
	// Mousovers Functions
	function mouseover(id) {
		var el = getElem(id);
		el.style.backgroundColor = '#e4eaf0';
	}
	
	function mouseout(id) {
		var el = getElem(id);
		el.style.backgroundColor = '#ffffff';
	}
	
	function getElem(id) {
		return document.getElementById(id);
	}
	
	function OpenWindow( url, width, height, wOptions, name ) {
		if ( ! width ) width = 640;
		if ( ! height ) height = 420;
		if ( ! wOptions ) wOptions = "scrollbars=no,menubar=no,toolbar=no,location=no,status=no,resizable=yes";
		if ( ! name ) name = "outsideSiteWindow";
		var newWin = window.open( url, name, "width=" + width + ",height=" + height + "," + wOptions );
		newWin.focus();
		
		// Track the Click
		gTrack(url);
	}
	function wopen(url, name, w, h){ // Open window in the page center after getting the screen resolution.
		// Factors for window decoration space.	
		w += 32;
		h += 96;
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h) / 2;
		
		var win = window.open(url,name,'width=' + w + ', height=' + h + ', left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=yes, toolbar=yes, scrollbars=yes, resizable=yes');
		win.focus();
		
		// Track the Click
		gTrack(url);
	}
	
	// MM functions
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}
	
	function MM_goToURL() { //v3.0
	  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}
	function MM_goToURL() { //v3.0
	  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}