var agent=navigator.userAgent;
var brwsName=(agent.indexOf('Opera')>-1) ? 'Opera' : navigator.appName;
var brwsVer;
var idx = agent.indexOf('MSIE');
if (idx > -1) 
{
	brwsVer = agent.substring(idx+5);
	idx = brwsVer.indexOf(';');
	brwsVer = brwsVer.substring(0,idx);
}
idx = agent.indexOf('Opera');
if (idx > -1)	
{
	brwsVer = agent.substring(idx+6);
	idx = brwsVer.indexOf(' ');
	brwsVer = brwsVer.substring(0, idx);
}
if (brwsName == "Netscape") 
{
	brwsVer = agent.substring(8);
	idx = brwsVer.indexOf(' ');
	brwsVer = brwsVer.substring(0, idx);
}
if (brwsName == "Netscape" && parseInt(navigator.appVersion) >= 5) 
{
	idx = agent.lastIndexOf('/');
	brwsVer = agent.substring(idx + 1);
}

/* Adjust navigation panel width based on browser width */
var navWidth = 0
if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	navWidth = window.innerWidth;
} else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    navWidth = document.documentElement.clientWidth;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
	navWidth = document.body.clientWidth;
}
var imgSuffix = (navWidth<810) ? '75' : (navWidth<1034) ? '100' : (navWidth<1290) ? '150' : (navWidth<1610) ?'200' : '250';

function launchRecentPhoto(width, height) { // Works with any photo
    var x = 0;
    var y = 0;
	var param1 = "screenX=";
	var param2 = ",screenY=";
    if (brwsVer>=4)  {
        if(width > screen.availWidth - 12) {
            width = screen.availWidth - 12; 
		}
        if(height > screen.availHeight - 48) {
            height = screen.availHeight - 48; 
		}
        x = (screen.availWidth - 12 - width) / 2;
        y = (screen.availHeight - 48 - height) / 3; 
	}
	if (navigator.appName == "Microsoft Internet Explorer") {
		// IE replaces screenX with left and screenY with top
		param1 = "left=";
		param2 = ",top=";
	}
    var params =  "status=0,scrollbars=1,resizable=1," + param1 + x + param2 + y + ",width=" + width + ",height=" + height + ")";
	var url = "/recentphoto.shtml";
	if (document.location.hostname=='rkndxpsr400')
		url = "/~ryankarl"+url;
    var windowvar = window.open(url, "recent", params);
	return false;
}

function SetCookie(sName, sValue)
{
	date = new Date();
	date.setUTCFullYear(date.getUTCFullYear() + 1);
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString() + "; path=/;";
}

function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	// a name/value pair (a crumb) is separated by an equal sign
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
	  return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
 }

function DelCookie(sName)
{
	document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT; path=/;";
}

function incFont()
{
	SetCookie("Font", "lg");
	window.document.location.reload();
}

function decFont()
{
	SetCookie("Font", "sm");
	window.document.location.reload();
}

function adTextOn()
{
	var num;
	if (document.layers || (document.all && !document.getElementById)) 
	{ /*ns4, ie4, others*/
		num = ad.offsetParent.offsetParent.offsetParent.offsetTop + ad.offsetParent.offsetParent.offsetTop + ad.offsetTop + ad.offsetHeight;
		adtext.style.top = num.toString() + "px";
		num = ad.offsetParent.offsetParent.offsetParent.offsetLeft + ad.offsetParent.offsetParent.offsetLeft + ad.offsetParent.offsetLeft + ad.offsetLeft;
		adtext.style.left = num.toString() + "px";
		num = ad.offsetWidth;
		adtext.style.width = num.toString() + "px";
		adtext.style.height = "auto";
		adtext.style.display = "";
	}
	else if (document.getElementById && document.body.style)
	{ /*DOM2 compliant*/
		var adEl = document.getElementById("ad");
		var txEl = document.getElementById("adtext");
		num = document.body.offsetTop + adEl.offsetParent.offsetParent.offsetTop + adEl.offsetHeight;
		txEl.style.top = num.toString() + "px";
		num = document.body.offsetLeft + adEl.offsetParent.offsetParent.offsetLeft + adEl.offsetParent.offsetLeft + adEl.offsetLeft;
		txEl.style.left = num.toString() + "px";
		num = adEl.offsetWidth;
		txEl.style.width = num.toString() + "px";
		txEl.style.height = "auto";
		txEl.style.display = "";
	}
}	

function adTextOff()
{
	if (document.layers || (document.all && !document.getElementById)) 
	{ /*ns4, ie4, others*/
		adtext.style.display = "none";
	}
	else if (document.getElementById && document.body.style)
	{ /*DOM2 compliant*/
		var txEl = document.getElementById("adtext");
		txEl.style.display = "none";
	}
}

function adTextToggle()
{
	if (document.layers || (document.all && !document.getElementById))
	{	/*ns4, ie4, others*/
		if(adtext.sytle.display=="none")
			adTextOn();
		else
			adTextOff();
	}
	else if (document.getElementById && document.body.style)
	{ /*DOM2 compliant*/
		var txEl = document.getElementById("adtext");
		if(txEl.style.display=="none")
			adTextOn();
		else
			adTextOff();
	}
}
