var old_id;
var old_color;
var parent_id;
var change_color = "aqua";
var pname = window.location.pathname;

window.onload = function(){
	AccessDataWrite();
	PathName(pname);

	var evt1 = document.getElementById("tab1");
	var evt2 = document.getElementById("tab2");
	var evt3 = document.getElementById("tab3");
	var evt4 = document.getElementById("tab4");
	var evt5 = document.getElementById("tab5");
	var evt6 = document.getElementById("tab6");
	var evt7 = document.getElementById("tab7");

	if(evt1.addEventListener){
		evt1.addEventListener("mouseover",tabcolor1,false);
		evt2.addEventListener("mouseover",tabcolor2,false);
		evt3.addEventListener("mouseover",tabcolor3,false);
		evt4.addEventListener("mouseover",tabcolor4,false);
		evt5.addEventListener("mouseover",tabcolor5,false);
		evt6.addEventListener("mouseover",tabcolor6,false);
		evt7.addEventListener("mouseover",tabcolor7,false);

		evt1.addEventListener("mouseout",tabclear1,false);
		evt2.addEventListener("mouseout",tabclear2,false);
		evt3.addEventListener("mouseout",tabclear3,false);
		evt4.addEventListener("mouseout",tabclear4,false);
		evt5.addEventListener("mouseout",tabclear5,false);
		evt6.addEventListener("mouseout",tabclear6,false);
		evt7.addEventListener("mouseout",tabclear7,false);
	}else if(evt1.attachEvent){
		evt1.attachEvent('onmouseover',tabcolor1);
		evt2.attachEvent('onmouseover',tabcolor2);
		evt3.attachEvent('onmouseover',tabcolor3);
		evt4.attachEvent('onmouseover',tabcolor4);
		evt5.attachEvent("onmouseover",tabcolor5);
		evt6.attachEvent("onmouseover",tabcolor6);
		evt7.attachEvent("onmouseover",tabcolor7);

		evt1.attachEvent("onmouseout",tabclear1);
		evt2.attachEvent("onmouseout",tabclear2);
		evt3.attachEvent("onmouseout",tabclear3);
		evt4.attachEvent("onmouseout",tabclear4);
		evt5.attachEvent("onmouseout",tabclear5);
		evt6.attachEvent("onmouseout",tabclear6);
		evt7.attachEvent("onmouseout",tabclear7);
	}
	
	headaddress();
	CursorEvent();
	FontEvent();
}
function tabcolor1(){ tabcolor('tab1'); }
function tabcolor2(){ tabcolor('tab2'); }
function tabcolor3(){ tabcolor('tab3'); }
function tabcolor4(){ tabcolor('tab4'); }
function tabcolor5(){ tabcolor('tab5'); }
function tabcolor6(){ tabcolor('tab6'); }
function tabcolor7(){ tabcolor('tab7'); }

function tabclear1(){ tabclear('tab1'); }
function tabclear2(){ tabclear('tab2'); }
function tabclear3(){ tabclear('tab3'); }
function tabclear4(){ tabclear('tab4'); }
function tabclear5(){ tabclear('tab5'); }
function tabclear6(){ tabclear('tab6'); }
function tabclear7(){ tabclear('tab7'); }

function tabcolor(id){
	if(id == parent_id){return;}
	old_color = document.all.item(id).style.color;

	if(old_id){
		document.all.item(old_id).style.color = old_color;
	}
	document.all.item(id).style.color = change_color;
	old_id = id;
}
function tabclear(id){
	if(id == parent_id){return;}
	if(old_id){
		document.all.item(old_id).style.color = old_color;
	}
}

function PathName(pname){
	if(pname.indexOf("firmoverview") != -1){
		ParentTab("tab2");
	}else if(pname.indexOf("practiceareas") != -1){
		ParentTab("tab3");
	}else if(pname.indexOf("discovery") != -1){
		ParentTab("tab4");
	}else if(pname.indexOf("attorneyprofile") != -1){
		ParentTab("tab5");
	}else if(pname.indexOf("news") != -1){
		ParentTab("tab6");
	}else if(pname.indexOf("contact") != -1){
		ParentTab("tab7");
	}else{
		ParentTab("tab1");
	}
}
function ParentTab(id){
	parent_id = id;
	document.all.item(id).style.color = change_color;
}

var opacity_val = 0;
function headaddress(){
	if(opacity_val > 100){ return; }
	opacity_val = opacity_val + 5;
	document.all["headaddress"].filters["alpha"].opacity = opacity_val;
	setTimeout(headaddress,100);
}

var cursor_flg = new Array();
function CursorEvent(){
	var addr = document.getElementById("headaddress");
	if(addr.addEventListener){
		addr.addEventListener("mouseover",CursorChange_headaddress,false);
		if(pname.indexOf("contact") != -1){
			var addr2 = document.getElementById("contactaddress");
			addr2.addEventListener("mouseover",CursorChange_contactaddress,false);
		}
	}else if(addr.attachEvent){
		addr.attachEvent('onmouseover',CursorChange_headaddress);
		if(pname.indexOf("contact") != -1){
			var addr2 = document.getElementById("contactaddress");
			addr2.attachEvent('onmouseover',CursorChange_contactaddress);
		}
	}
}
function CursorChange_headaddress(){ CursorChange('headaddress','cursor_plus.cur','cursor_minus.cur'); }
function CursorChange_contactaddress(){ CursorChange('contactaddress','cursor_plus.cur','cursor_minus.cur'); }
function CursorChange(id,img1,img2){
	if(cursor_flg[id]){
		document.all.item(id).style.cursor = 'url(../image/' + img2 + ')';
	}else{
		document.all.item(id).style.cursor = 'url(../image/' + img1 + ')';
	}
}


function FontEvent(){
	var addr = document.getElementById("headaddress");
	if(addr.addEventListener){
		addr.addEventListener("click",BigFont_headaddress,false);
		if(pname.indexOf("contact") != -1){
			var addr2 = document.getElementById("contactaddress");
			addr2.addEventListener("click",BigFont_contactaddress,false);
		}
	}else if(addr.attachEvent){
		addr.attachEvent('onclick',BigFont_headaddress);
		if(pname.indexOf("contact") != -1){
			var addr2 = document.getElementById("contactaddress");
			addr2.attachEvent('onclick',BigFont_contactaddress);
		}
	}
}
function BigFont_headaddress(){
	BigFont('headaddress',13,10);
	CursorChange_headaddress();
}
function BigFont_contactaddress(){
	BigFont('contactaddress',16,12);
	CursorChange_contactaddress();
}
function BigFont(id,fsize,old_fsize){
	if(cursor_flg[id]){
		cursor_flg[id] = false;
		document.all.item(id).style.fontSize = old_fsize + 'px';
	}else{
		cursor_flg[id] = true;
		document.all.item(id).style.fontSize = fsize + 'px';
	}
}

function AccessDataWrite(){
	if(document.getElementById("accessdata") != null){
		document.getElementById("accessdata").innerHTML = 
		'500 Union Street, Suite 1005 Seattle, Washington 98101 USA<BR>' + 
		'Phone:&nbsp;1.206.265.1225&nbsp;| Fax:&nbsp;1.206.691.3449&nbsp;| <A href="mailto:firm@shatzlaw.com">firm@shatzlaw.com</A>';
	}
	if(document.getElementById("contactaddress") != null){
		document.getElementById("contactaddress").innerHTML = 
		'<B>Shatz Law Group, PLLC</B><BR>' + 
      	'500 Union Street, Suite 1005<BR>' + 
      	'Seattle, WA 98101<BR>' + 
      	'Phone: 1.206.265.1225<BR>' + 
      	'Fax: 1.206.691.3449<BR>' + 
      	'E-mail: <SPAN style="color:blue;"><A href="mailto:firm@shatzlaw.com">firm@shatzlaw.com</A>' + 
      	'<BR><BR><BR>' + 
      	'Map and Directions: <A href="http://www.bing.com/maps/default.aspx?' + 
      	'v=2&cp=47.609850000000016~-122.334609&lvl=16&sty=r&where1=500%20Union%20St%2C%20Seattle%2C%20WA%2098101-4073" target="_blank">Directions</A><BR>';
	}
	if(document.getElementById("contacttel") != null){
		document.getElementById("contacttel").innerHTML = '&nbsp1.206.265.1225&nbsp';
	}
}

