
function popup(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); } 


function readCookie(searchString) {

	var cookies = document.cookie.split(';');

	for (var i=0;i<cookies.length;i++)
		if (cookies[i].indexOf(searchString + '=') == 0 || cookies[i].indexOf(' ' + searchString + '=') == 0)
			return cookies[i].substring(cookies[i].indexOf('=')+1);
}




function initializePage() {

	
	if (document.cookie == '') {
	
		date = new Date();
		date.setDate(date.getDate()+730)
				
		document.cookie = 'textsize=small; expires=Fri, 31 Dec 2115 23:59:59 GMT; path=/';

		
	}
	else 
	{
	
		cookieValue = readCookie('textsize');
				
		if (cookieValue != 'small' && document.getElementById('textsize')) {
	
			var textsizeLinks = document.getElementById('textsize').getElementsByTagName('a');
			
			for (var i=0;i<textsizeLinks.length;i++)
			    textsizeLinks[i].className = '';
				
		
			if (cookieValue == 'medium')
			{
				document.getElementById('maincontent').style.fontSize = '1.1em';
				document.getElementById('medium').className = 'selected';
			}
			else if (cookieValue == 'large')
			{
				document.getElementById('maincontent').style.fontSize = '1.2em';
				document.getElementById('large').className = 'selected';
			}
		
		}
	}
  
	// Add event handlers for text size buttons
	
	if (document.getElementById('textsize')) {
		var textsizeLinks = document.getElementById('textsize').getElementsByTagName('a');
		for (var i=0;i<textsizeLinks.length;i++)
		{
		    textsizeLinks[i].onclick = changeSize;
		}
	
	}
	
	// Add event handlers for page tools buttons
	
	if (document.getElementById('pagetools')) {
	
		var pagetoolsLinks = document.getElementById('pagetools').getElementsByTagName('a');
		
		pagetoolsLinks[0].onclick = function () {location.href='mailto:?SUBJECT=Link%20to%20Website%20of%20Silk,%20Adler%20%26%20Colvin%20(http://www.silklaw.com)&BODY=Below%20is%20a%20link%20to%20the%20website%20of%20Silk,%20Adler%20%26%20Colvin.%0D%0A%0D%0ATo%20view%20the%20page,%20visit:%20'+escape(location.href)+'%0D%0A%0D%0A------------------------------------------------------%0D%0ASilk,%20Adler%20%26%20Colvin%27s%20lawyers,%20paralegals,%20and%20support%20staff%20serve%20the%20legal%0D%0Aneeds%20of%20the%20nonprofit%20sector.%20They%20serve%20grant-makers,%20nonprofit%20service%0D%0Aproviders,%20individual%20and%20corporate%20donors,%20nonprofit%20advocacy%20groups,%20and%20much%20more.'; return false;};
		pagetoolsLinks[1].onclick = function () {print(); return false;};
		pagetoolsLinks[2].onclick = addbookmark;
		
		pagetoolsLinks[0].onmouseover = function () { document.getElementById('pttext').innerHTML = 'Email Page'};
		pagetoolsLinks[1].onmouseover = function () { document.getElementById('pttext').innerHTML = 'Print Page'};
		pagetoolsLinks[2].onmouseover = function () { document.getElementById('pttext').innerHTML = 'Bookmark Page'};
		
		pagetoolsLinks[0].onmouseout = function () { document.getElementById('pttext').innerHTML = ''};
		pagetoolsLinks[1].onmouseout = function () { document.getElementById('pttext').innerHTML = ''};
		pagetoolsLinks[2].onmouseout = function () { document.getElementById('pttext').innerHTML = ''};
	}
	
	if (document.getElementById('pagetoolsalt')) {
	
		var pagetoolsLinksAlt = document.getElementById('pagetoolsalt').getElementsByTagName('a');
		
		pagetoolsLinksAlt[0].onclick = function () {location.href='mailto:?SUBJECT=Lorem%20Ipsum&BODY='+escape(location.href); return false;};
		pagetoolsLinksAlt[1].onclick = function () {print(); return false;};
		pagetoolsLinksAlt[2].onclick = addbookmark;
	
	}
		
	
	// Prepare external links and disclaimers
	
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "disclaimer")
			anchor.onclick = function () {return confirm('We appreciate your interest in Silk, Adler & Colvin. If you are not a current client of Silk, Adler & Colvin, do not include any confidential or secret information in your email. Silk, Adler & Colvin does not have a duty or a legal obligation to keep confidential any information that you provide to us (in person or electronically) until you become a client of the firm. For your own protection, please do not send any information specific to your legal needs until you obtain approval from a Silk, Adler & Colvin attorney. For more information, please see our Terms of Use. E-mails may be misdirected to our spam filter. If you have not received a response within a reasonable time, please call.');}
	}
	
	
	if (document.all&&document.getElementById&&document.getElementById('dropdown')) 
	{	
		var node = document.getElementById('dropdown');
		
		node.onmouseover=function()	{this.className+=" hover";}
		node.onmouseout=function() {this.className=this.className.replace(" hover", "");}
	}
	if (document.all&&document.getElementById&&document.getElementById('prac_dropdown')) 
	{
		var node = document.getElementById('prac_dropdown');
		
		node.onmouseover=function() {this.className+=" hover";}
		node.onmouseout=function() {this.className=this.className.replace(" hover", "");}
	}
	
	// Prepare javascript links
	
	var javascriptLinks = getElementsByClassName(document, "div", "hoverarea");
	
	for (var i=0;i<javascriptLinks.length;i++)
	{
		javascriptLinks[i].onmouseover = function () {this.style.backgroundColor = '#f1f3f4'; this.style.cursor = 'pointer'; this.className+=" hover";};
		javascriptLinks[i].onmouseout = function () {this.style.backgroundColor = 'transparent'; this.style.cursor = 'default'; this.className=this.className.replace(" hover", "");};
		javascriptLinks[i].onclick = function () {document.location = this.getElementsByTagName('a')[0].href;};
	}
	
	
}
window.onload = initializePage;

function changeSize() {
	var textsizeLinks = document.getElementById('textsize').getElementsByTagName('a');
	
	for (var i=0;i<textsizeLinks.length;i++)
	{
	    textsizeLinks[i].className = '';
	}
	
	this.className = 'selected';
	
	date = new Date();
	date.setDate(date.getDate()+730)
	
	if (this == textsizeLinks[0])
	{
		document.getElementById('maincontent').style.fontSize = '1em';
		document.cookie = 'textsize=small; expires=Fri, 31 Dec 2115 23:59:59 GMT; path=/';
	}
	else if (this == textsizeLinks[1])
	{
		document.getElementById('maincontent').style.fontSize = '1.1em';
		document.cookie = 'textsize=medium; expires=Fri, 31 Dec 2115 23:59:59 GMT; path=/';
	}
	else if (this == textsizeLinks[2])
	{
		document.getElementById('maincontent').style.fontSize = '1.2em';
		document.cookie = 'textsize=large; expires=Fri, 31 Dec 2115 23:59:59 GMT; path=/';
	}
	
	return false;
	
}

function addbookmark()
{ 
	general="First click OK and then hit CTRL+D to bookmark this page.";
	opera="First click OK and then hit CTRL+T to bookmark this page.";
	if ((navigator.userAgent).indexOf("Opera")!=-1)
		alert(opera); 
	else
		alert(general); 
}


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}	
