pages = Array();
pages[0] = 'anchor';
pages[1] = 'bio';
pages[2] = 'links';

quotes = Array();
quotes[0] = '99% dictonairy free!';
quotes[1] = 'Soy is Murder!';
quotes[2] = 'Soy is People!';
quotes[3] = 'Everyone is entitled to my opinion';
quotes[4] = 'Outranking better sites on Google since 2006';

quote = quotes[Math.round(Math.random()*(quotes.length))];
var timer = null;
var loca = '';
frameWidth=0;
frameHeight=0;

function center() {
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	scrollHeight = document.body.scrollTop;

	id = "menu";
	x = null;
	if (document.getElementById)
	{
		x = document.getElementById(id);
	}

	x.style.left = (frameWidth/2 - 170)+ "px";
	x.style.top = (frameHeight/2 - 170 + scrollHeight)+ "px";
	
}

function set(state) {
	t = document.getElementById('menu');
	t.style.visibility = state;
	if(state=="hidden") {
		document.getElementById('show').style.visibility="visible";
		document.getElementById('hide').style.visibility="hidden";
	}
	else {
		center();
		document.getElementById('show').style.visibility="hidden";
		document.getElementById('hide').style.visibility="visible";
	}
}

function pos(index) {
loca = pages[index];
for(i=0;i<3;i++) {
	t = document.getElementById(pages[i]);
	if(i==index) {
		t.style.display = "block";
		document.body.scrollTop = 0;
	}
	else {
		t.style.display = "none";
	}
}
set("hidden");
}

function tout() {
	//alert('timed');
	l=document.location+"";
	l=l.split('#');
	if(loca!=l[1]) {
		//alert(loca+'!='+document.location+"");
		clearTimeout(timer);
		timer = null;
		setPage(document.location);
	}
	loca = l[1];
	timer = setTimeout("tout()",650);
}

function setPage(loc) {
	loc = loc+'';
	url = loc.split('#');
	if(url.length>1) {
		loca = url[1];
		if(url[1]=='links') pos(2);
		else if(url[1]=='bio') pos(1);
		else if(url[1]=='anchor') pos(0);
	}
	
	if(timer==null) {
		timer = setTimeout("tout()",650);
	}
}

function showEdit(refy,ind) {
	editme = document.getElementById('editme');
	if(editme.style.display=='block') {
		editme.style.display = 'none';
	}
	else {
		editme.style.top = fPY(refy)-24;
		editme.style.display = 'block';
		document.update.body.value = body[ind].replace("\n","");
		document.update.title.value = title[ind];
		document.update.prikey.value = prikey[ind];
		document.update.username.value = getCookie('username');
		document.update.pass.value = getCookie('pass');
	}
}

function fPX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function fPY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function hideEdit(refy) {
	editme = document.getElementById('editme');
	editme.style.display = 'none';
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

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 imgExpand(img,xx,yy) {
	im = document.getElementById('imglrg');
	di = document.getElementById('imgdiv');
	im.src = img.src;
	im.width=xx;
	im.height=yy;
	ny = fPY(img)-65;
	//if(document.body.clientHeight+document.body.scrollTop<ny+yy)
	//	ny -= (ny+yy) - document.body.clientHeight + document.body.scrollTop + 10;
		//alert(document.body.clientHeight+","+document.body.scrollTop+","+ny+","+yy);
	//if(ny<10) ny=10;
	
	di.style.top=ny;
	nx=fPX(img)-185;
	if(document.body.clientWidth<nx+xx)
		nx -= (nx+xx) - document.body.clientWidth + 10;
	if(nx<10) nx=10;
	di.style.left=nx;
	im.title=img.title;
	di.style.display = "block";
}

function printme() {
	var y=p.length-1;
for(i=0;i<20;i++) {
if(d[i]!='') {
pp = p[y]+"";
ti = new Array();
if((pp.substring(0,8))>rr[i]) {
document.write("<TR><TD class=b colspan=4 align=center height=98>");
while(y>-1 && (pp.substring(0,8))>rr[i]) {
	ti = pp.split('@');
	if(ti.length<2) t[1]='    ';
	ti[1] +="";
	document.write("<img title=\""+ti[1].substring(0,ti[1].length-4)+"\" onMouseOver=imgExpand(this,640,480) src=\"up/"+pp+"\" class=t>\n");
	y--;
	pp = p[y]+"";
}
document.write("</TD></TR>");
}

document.write("<tr><TD class=le rowspan=2>"+d[i]+"<BR><img src=p/");
var da = d[i].indexOf('Jun');
if(da!=-1) document.write("theforceofme1");
else if(d[i].indexOf('Aug')!=-1) document.write("me_pic2");
else document.write("me_pic1");

document.write(".jpg class=m onClick=showEdit(this,"+i+")><br>"+t[i]+"</TD>\n"+
"<td class=h height=25><img border=0 src=p/t_left.gif align=left>&nbsp;"+title[i]+":\\<img border=0 src=p/blink_cursor.gif width=12 height=19 align=bottom></td><td><img border=0 src=p/t_right.gif></TD></tr>\n<TR><TD colspan=2 valign=top>"+body[i]+"</TD></TR>"+
"<tr><TD colspan=3 align=center height=28><img border=0 src=p/hr.gif width=100% height=20></TD></tr>\n");

}
}
}

//PENGUIN ANIM CODE
ps = new Array();
pics = new Array();
pics[3] = "p/pd.gif";
pics[2] = "p/pm.gif";
pics[1] = "p/pu.gif";
penguin_num=0;
ctr=0;
width=(123*.4)|0;
height=(85*.4)|0;

function rand (n)
{
  return ( Math.floor(Math.random()*n+1));
}

function int(n)
{
	return n|0;
}

function anim()
{
	ctr++;
	if(ctr==32) ctr=0;
	for(i=0;i<penguin_num;i++)
	{
		ps[i].left = ps[i].left - 4*(5-ps[i].speed) - 10;
		if(ps[i].left>-100) {
			ps[i].obj.style.left=ps[i].left+"px";
			if(ctr%ps[i].speed==0) {
				ps[i].frame=ps[i].frame+ps[i].framenext;
				if(ps[i].frame==0) {
					ps[i].frame=2;
					ps[i].framenext=1;
				}
				else if(ps[i].frame==4) {
					ps[i].frame=2;
					ps[i].framenext=-1;
				}
				ps[i].obj.src=pics[ps[i].frame];
			}
		}
		else {
			s(i);
		}
	}
	//alert(ps[0].left);
	setTimeout('anim()',200);
}

function s(i) {
		center();
		scale=(rand(7)+3)/10.0;
		ps[i].frame=rand(3);
		ps[i].left=rand(frameWidth-175);
		ps[i].top=rand(frameHeight)+100+scrollHeight;
		
		ps[i].obj.style.height=int(height*scale);
		ps[i].obj.style.width=int(width*scale);
		ps[i].obj.style.left=ps[i].left;
		ps[i].obj.style.top=ps[i].top;
		
		//ps[i].obj = document.getElementById("penguin"+i);
		ps[i].speed=rand(4);
		ps[i].framenext=1-Math.round(Math.random())*2;
}

function setup() {
	penguin_num=rand(10)+5;
	if(frameWidth==0) frameWidth=700;
	if(frameHeight==0) frameHeight=700;
		
	for(i=0;i<penguin_num;i++) {
		//document.write('<img id="penguin'+ i +'" src="" style="position:absolute;z-index:-'+ (rand(10)) +';top:-150px;left:-150px;width:5px;height:5px;">');
	
		ps[i] = new Object();
		ps[i].obj = document.getElementById("penguin"+i);
		s(i);
	}
	setTimeout('anim()',500);
}