// JavaScript Document

//PCBG note 24.08.07.  This is to be used in the future if a need arises to insert additional javascript instructions on each page in or supporting the Families Database. 

//JB printer
//window.onbeforeprint = beforePrint;
//window.onafterprint = afterPrint;

function beforePrint()
{
	
	document.cookie = "print=true; path=/";
	parent.window.location.href = parent.document.title + '.htm';
}

bInFrame = top.location.href != window.location.href;

if(bInFrame)
{
	if(document.cookie.indexOf('subscription=1') == -1)
	{
		document.write("<a href=\"javascript:alert(\'Only logged-in Members may print!\')\">Print Page</a>");
	}
	else /*if(navigator.appName != "Netscape")*/
	{
		document.write('<a href="javascript:void(beforePrint())">Print Page</a>');
	}
}
else
{
	if(readCookie('print') == 'true')
	{
		document.cookie = "print=false; path=/";
				
		//Safari
		if(navigator.appName =='Netscape')
		{
			setTimeout("window.print();", 1000);
		}
		else
		{
			window.print();
		}
		//setTimeout("history.go(-1)", 2000);	
		
			setTimeout("window.location.href = 'http://www.stirnet.com/main/index.php?option=com_wrapper&Itemid=79&startUrl=' + window.location.href;	", 2000);
	}
	else if(readCookie('search') == 'true')
	{
		document.cookie = "search=false; path=/";
	}
	else 
	{
		window.location.href = 'http://www.stirnet.com/main/index.php?option=com_wrapper&Itemid=79&startUrl=' + window.location.href;	
	}
	
	
	
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

