/*
Support files used by the "print page" function
- code to read cookie for font size
- code to create new window and populate
*/


if (window != top) {
	top.location.href = location.href;
}

function changeTitle(title) { document.title = '<%= EBTechClient %>' + title; }


function printPage() { 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
		sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 
   var sWinHTML = document.getElementById('col1').innerHTML; 
   var winprint=window.open("","",sOption); 
		winprint.document.open(); 
		winprint.document.write('<html><script type="text/javascript" src="/lib_print.js"></script><link href="/print.css" rel="Stylesheet"><body><div id=col1><h1 class="small">Community Health Services Department / Child Health & Dental Services Department</h1>');
		winprint.document.write(sWinHTML);
		winprint.document.write('</div></body></html>');
		winprint.document.close(); 
		winprint.focus(); 
}

/* Cookie code */
function setClassStyle(classValue) {
	document.getElementById('col1').style.fontSize = classValue;
	setCookie("fontsize", classValue)
}

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie= name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function initTextSize() {
	document.getElementById('col1').style.fontSize = getCookie('fontsize');
}
if (typeof window.addEventListener != 'undefined') {
   window.addEventListener('load', initTextSize, false);
}else if (typeof window.attachEvent != 'undefined') {
   window.attachEvent('onload', initTextSize);
}


