var xV2;
var xV3;
var xV4;
var nV;
var wHeight;
function begin(){
	xV2=document.getElementById("menu").offsetTop;
	xV3=document.getElementById("menu").offsetTop+42;
	xV4=document.getElementById("headlines").offsetHeight-xV2+36;
	(window.innerHeight) ? wHeight=window.innerHeight : wHeight=document.body.clientHeight;
	if (wHeight>document.getElementById("menu").offsetHeight) {
		stayHome();
	}
	tsize();
}
function stayHome() {
	(!document.body.scrollTop) ? nV=document.documentElement.scrollTop : nV=document.body.scrollTop;
	if (nV>=xV3) { 
		document.getElementById("menu").style.position="fixed";
		document.getElementById("menu").style.top="-43px";
	}
	else {
		document.getElementById("menu").style.position="absolute"; 
		document.getElementById("menu").style.top=xV2+"px";
	}
	if (xV4>100 && nV>=xV4) {
		document.getElementById("menu").style.position="absolute";
		document.getElementById("menu").style.top=xV4-43+"px";
	}
	setTimeout("stayHome()",50);
}

function changecopy(towhat) {
	for (var i=1;i<=20;i++) {
		if (document.getElementById("story"+i)) { document.getElementById("story"+i).className=towhat }
	}
	for (var i=1;i<=20;i++) {
		if (document.getElementById("story"+i+"short")) { document.getElementById("story"+i+"short").className=towhat }
	}
	createCookie("textsizecookie",towhat,14);
}

function openup() {
	var whichone=window.location;
	document.which.one.value=whichone;
	whichone=document.which.one.value;
	var point=whichone.lastIndexOf("?");
	str=whichone.substring(point+1,whichone.length);
	showup(str);
}
function openuparch() {
	hideall();
}
function showup(str) {
	hideall();
	document.getElementById(str+"full").style.display="block";
	document.getElementById(str+"short").style.display="none";
}
function hideall() {
	for (var i=1;i<=20;i++) {
		if (document.getElementById("story"+i+"full")) { document.getElementById("story"+i+"full").style.display="none" }
	}
	for (var i=1;i<=20;i++) {
		if (document.getElementById("story"+i+"short")) { document.getElementById("story"+i+"short").style.display="block" }
	}
}

function letter() {
	alert("Your Letter to the Editor must include your name, address and phone number in order to be published. Letters to the Editor are printed as submitted, warts and all.");
}
function stinger() {
	alert("What are your pet peeves? What big or little thing is getting on your last nerve? Let us air your grievance. It's anonymous.");
}
function adsub() {
	window.open("adsubmission.html","adsubw","width=600,height=650,screenX=100,left=100,screenY=100,top=100,status=no,menubar=no");
}
function advertise() {
	alert("To advertise with Greene Publishing, please call (850) 973-4141.");
}

function loadframe(framename,framepage) {
	parent[framename].location=framepage;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

function tsize() {
	var aaa=readCookie("textsizecookie");
	if (aaa) { changecopy(aaa) }
	else { changecopy("copys") }
}

function seesearch() {
	document.getElementById("links").style.display="none";
	document.getElementById("search").style.display="block";
}

function placerss() {
	var tiwidth=document.getElementById("ttt").offsetWidth-358;
	document.getElementById("ti").style.width=tiwidth+"px";
}