
if(location.href.indexOf('www.')>-1)location.href="http://slayeroffice.com";
//if(!document.getElementById) alert("This site is designed to work with IE5+ and Gecko/Mozilla based browsers. I encourage you to visit the site in one of them.");

var listNames = new Array("arcade","tools","code");
quote = new Array();
quote[0] = 'all the lamest stuff ever in one place.'; 
quote[1] = 'quality web garbage since 1873.'; 
quote[2] = 'pure crap.'; 
quote[3] = 'better than a root canal.'; 
quote[4] = "pants? what pants?";
quote[5] = "quick! be funny!";
quote[6] = "web experiments gone horribly awry.";
quote[7] = "more coffee please.";
quote[8] = "alpha filter abuse at its finest."
quote[9] = "lvl 54 sk lfg";
quote[10] = "making browsers do things they shouldn't.";
quote[11] = "i love arrays";
quote[12] = "practical application? of course not.";
quote[13] = "beer++;";

var openMenu="";
gecko = navigator.userAgent.toLowerCase();
gecko = gecko.indexOf('gecko');

function initPage() {
	if(!document.getElementById)return;
	buildLinksArray();
	checkForParam();
	//writeNews();
	stupidQuote();
	//initCommentsArray();
	quote[quote.length] = linkArray.length + " bits of stuff and counting.";
	document.getElementById("mContainer").style.height = (document.getElementById("leftNavContainer").offsetHeight+100) + "px";
	document.getElementById("leftNav").style.height = document.getElementById("leftNavContainer").offsetHeight + "px";
	//document.getElementById("dailyLinks").style.height = document.getElementById("leftNavContainer").offsetHeight + "px";
}

linkArray = new Array();

function ocw() {
	openWin("http://slayeroffice.com/comment.html",400,250);
}

function buildLinksArray() {
	for(i=0;i<document.links.length;i++) {
		if(document.links[i].className == "subNavLink")linkArray[linkArray.length] = document.links[i].href;
	}
}

function checkForParam() {
	paramString = document.location.href;
	if(paramString.indexOf('?')>-1) {
		param = paramString.substring(paramString.indexOf('?')+3,paramString.length);
		for(i=0;i<linkArray.length;i++) {
			if(linkArray[i].indexOf(param)!=-1) {
				if(gecko==-1) {	
					document.contentServer.document.location.href = linkArray[i];
				} else {
					document.getElementById("contentServer").src = linkArray[i];
				}
			break;
			}
		}
	}
}

function sendContent() {
	if(document.layers && !document.getElementById)return false;
	if(parent.document.location.href == document.location.href) {
		//location.href="http://slayeroffice.com/index.php?c=" + location.href;
		return;
	} else {
		parent.serveContent();
	}
}

function serveContent() {
	//if(gecko!=-1) {
	if(!document.all  || navigator.userAgent.indexOf("Opera")>-1) {
		contentBlock = document.getElementById("contentServer").contentDocument.getElementById("contentDiv").innerHTML;
	} else {
		contentBlock = document.contentServer.document.getElementById("contentDiv").innerHTML;
	}
	document.getElementById("content").className = "news";
	document.getElementById("content").innerHTML = contentBlock;
	window.scrollTo(0,0);
	//showComments();
}


function showComments() {
	document.getElementById("mComments").innerHTML = "";
	commentIndex = getCommentIndex();
	if(commentIndex == 0)return;
	if(comments[commentIndex[0]][commentIndex[1]] && comments[commentIndex[0]][commentIndex[1]].length) {
		mHTML = "<b>Comments:</b><p>";
		for(i=0;i<comments[commentIndex[0]][commentIndex[1]].length;i++) {
			mDate = comments[commentIndex[0]][commentIndex[1]][i][1];
			mComm = comments[commentIndex[0]][commentIndex[1]][i][0];
			mName = comments[commentIndex[0]][commentIndex[1]][i][2];
			mHTML+= "<b>" + mDate + "</b> - " + mComm + "<br>" + mName + "<p>";
		}
		document.getElementById("mComments").innerHTML = mHTML;
	return;
	} 
	document.getElementById("mComments").innerHTML = "<b>No comments</b>. Click the comment button above to add one.";
}

function el(objID) {
	if(openMenu != objID) {
		closeLists();
		openMenu = objID;
		document.getElementById(objID).style.display="block";
		document.title = "slayer.office | " + objID
	} else {
		closeLists();
		openMenu="objID";
		document.getElementById(objID).style.display="none";
		document.title = "slayer.office";
	}
}

function closeLists() {
	for(i=0;i<listNames.length;i++)document.getElementById(listNames[i]).style.display="none";
}

function writeNews() {	
	//closeLists();
	document.getElementById("mComments").innerHTML = "";
	mDoc = document.getElementById('content');
	mHTML = "";
	for(i=(news.length-1);i>=(news.length-10);i--){
		mHTML+= news[i];
	}	
	mDoc.className = "content";
	mDoc.innerHTML = mHTML;
}

function writeAllNews() {
	w = document.all?495:515;
	openWin("",w,300);	
	mHTML="<html><head><link rel='stylesheet' type='text/css'  href='scripts/styles_v4.1.css'><title>slayer.office.archived_news</title></head><body>";	
	for(i=0;i<news.length;i++){
		mHTML += news[i];
	}
	mHTML+="</body></html>";
	w.focus();
	w.document.write(mHTML);
}

function openWin(url,wdth,hght) {
	t = (screen.width-wdth)/2;
	l = (screen.height-hght)/2;
	w=window.open(url,'cWin','nostatus,resizable=no,scrollbars=1,width='  + wdth + ',height=' + hght + ',top=' + t + ',left=' + l);
}

function ssc(contentID) {
	document.getElementById("content").innerHTML = document.getElementById(contentID).innerHTML;
}

function stupidQuote() {	
	document.getElementById('mQuote').innerHTML = quote[Math.floor(Math.random() * quote.length)];
}

function getCommentIndex() {
	url = document.all?document.contentServer.document.location.href:document.getElementById("contentServer").contentDocument.location.href;
	if(url.indexOf("http")==-1 || url.indexOf("contact.html")!= -1 || url.indexOf("links")!=-1 || url.indexOf("about.html")!=-1)return 0;
	url = url.replace(/http:\/\/slayeroffice.com\/content\//,"");
	url = url.split("/");
	url[1] = url[1].replace(/\.html/,"");
	return url;
}

function swapStyle(styleSheetURL) {
	document.getElementsByTagName("link")[0].href ="http://slayeroffice.com/scripts/" + styleSheetURL;
	window.scrollTo(0,0);
}

function openCommentWindow(newsID) {
	url = "/scripts/comment_scripts/comments.php?id=" + newsID;
	lft = (screen.width - 580)/2;
	tp = (screen.height - 400)/2;
	popWin = window.open(url,"popWin","width=580,height=400,scrollbars=yes,top=" + tp + ",left=" + lft);
}

function noColor() {
	for(i=0;i<document.getElementsByTagName("*").length;i++) {
		document.getElementsByTagName("*")[i].style.backgroundColor = "#FFFFFF";
		document.getElementsByTagName("*")[i].style.color = "#000000";
		document.getElementsByTagName("*")[i].style.borderColor = "#000000";
		document.getElementsByTagName("*")[i].style.backgroundImage = "url('')";
	}
	//document.images[0].style.display="none";
	//document.images[1].border=1;
}
