//v1.6, fsp v1.0
//active links are not clickable
var disable_active_link = false;
//enable or disable rollovers on active active states
var enable_active_rollover =  false;

//enable or disable rollovers on active links related by scope with active states
var rollover_active_scope = false;

/*active states, i.e all buttons that have corresponding (...)-a.*
e.g. if all (n-main-)(...).* have active states: ['n-main-']
only n-main-atty.gif and all (n-feat-)(...).* have active state: ['n-main-atty','n-feat']
none have active states: ['#']*/
var arr_active = ['#'];

//class applied to active text links
var active_class = 'active';

//[['link','scope','scope',(...)],(...)]
var arr_scopes=[
['/Attorneys.shtml','Attorneys.shtml'],
['/','/Home.shtml']
];

//use class "h_exclude" to avoid class "active" from being applied to any link
//use class "h_always_exclude" if the link or rollover is always an exception
//[['path to exclude from highlighting','exception','exception',(...)],(...)]
var enable_exception=false;
var arr_scope_exceptions=[];

var at = document.getElementsByTagName('a'), it = document.getElementsByTagName('img'),i=0;
var uc = '~~~~';
//re = new RegExp(/^.+\('([^']+)'.+'\/(.+\/)+(.+)',.\)$/m);
re = new RegExp(/^.+\('([^']+)'.+?'\/([^.]+\/)+(.+?)',/m);

fp = document.location + uc;
rp = fp.replace(/^http:\/\/[^\/]+(\/.*)$/,'$1');
dn = fp.replace(rp,'')+'/';
rf = rp.replace(/^(\/(.+\/)*).+$/,'$1');
fn = rp.replace(rf,'');

fp = fp.replace(uc,'');
rp = rp.replace(uc,'');
fn = fn.replace(uc,'');
//alert(fp + ' -3- ' + rp + ' - ' + fn);

//Make '/' something unique
rp=(rp=='/')?uc:rp;
for(i=0;i<arr_scopes.length;i++){
	for(j=0;j<arr_scopes[i].length;j++){
		arr_scopes[i][j] = (arr_scopes[i][j]=='/')?uc:arr_scopes[i][j];
	}
}

for(i=0;i<at.length;i++){	
	at_hr = at[i].getAttribute('href');	
	

	
	if(at_hr!=null){
		//IE: at_hr==dn, Firefox: at_hr=='/'
		at_hr=(at_hr==dn||at_hr=='/')?uc:at_hr;
		bs = scopes(at_hr);
		//alert(rp + ' - ' + at_hr + ' - ' + bs);
		if((at_hr.indexOf(rp)>-1&&at_hr.indexOf('#')==-1&&at_hr.indexOf('?')==-1||bs)){			


				if(at[i].className=='h_always_exclude')
					break;
			//at[i].className=(at[i].className!='last')?active_class:active_last_class;
			//alert(at_hr);
			//alert(at[i].className + ' - ' + at[i].className.indexOf('h_no_highlight'))
			//if(!(at[i].className.indexOf('h_not_parent')>-1&&at_hr.indexOf(rp)==-1)&&!(at[i].className.indexOf('h_no_highlight')>-1))
			if(!(at[i].className=='h_exclude'&&at_hr.indexOf(rp)==-1))
				at[i].className = (at[i].className!='')?at[i].className + ' ' + active_class:active_class;			

			
			
			
			if(!bs&&disable_active_link)
				at[i].removeAttribute('href');
			
			if(at[i].getAttribute('onmouseover')!=null){
				mo = at[i].getAttribute('onmouseover')+'';
				m = re.exec(mo);
	
				for(j=0;j<it.length;j++){
					if(it[j].getAttribute('name')==m[1]||it[j].getAttribute('id')==m[1]){
						as=m[3];
						for(k=0;k<arr_active.length;k++){
							if(m[3].indexOf(arr_active[k])>-1){
								as=m[3].replace('-o.','-a.');
								if(!bs||!rollover_active_scope)
									at[i].setAttribute('onmouseover',mo.replace('-o.','-a.'));
								break;
							}
						}					
						//alert(bs);
						
						it[j].src = '/design/images/' + as;
					}
	
				}		
			}

//support Matt's script
			for(j=0;j<at[i].childNodes.length;j++){
				cn = at[i].childNodes[j];
				if(cn.nodeName.toLowerCase()=='img'){
alert('hight')
					if(cn.className.match(/[^\-]\bover\b[^\-]|^over$/i)){
						cn.src = cn.src.replace(/^(.+)\.(.{3})$/,'$1-o.$2');
												
						//handle active states
						for(k=0;k<arr_active.length;k++){
							if(cn.src.indexOf(arr_active[k])>-1){
								cn.src = cn.src.replace('-o.','-a.');
								break;	
							}
						}

						cn.className='';
						if(!bs&&!enable_active_rollover&&cn.src.indexOf('-a.')>-1){
							cn.className=' over activeimg';							
						}
					}
				}
			}			

		}
	}
}


function scopes(hr){	
	var i=0,j=0;
	//alert('*' + hr + '* - *' + dn + '*');
	mod_fp=(fn=='')?uc:fp;

	//Take care of exceptions first
	if(enable_exception){
		for(i=0;i<arr_scope_exceptions.length;i++){
			if(hr.indexOf(arr_scope_exceptions[i][0])>-1){			
				for(j=1;j<arr_scope_exceptions[i].length;j++){				
					if(mod_fp.indexOf(arr_scope_exceptions[i][j])>-1)
						return false;
				}
			}
		}
	}
	for(i=0;i<arr_scopes.length;i++){
		//Do scopes of current link fit the current file path? 
			
		if(hr.indexOf(arr_scopes[i][0])>-1){
			for(j=1;j<arr_scopes[i].length;j++){
				//alert(fp + ' - ' + arr_scopes[i][j] + ' - ' + i);
				
				if(mod_fp.indexOf(arr_scopes[i][j])>-1){
					return true;
				}
			}
		}
		
	}
	
	
	return false;
}