// created by Nathan Wulf (jitspoe)
// jitspoeATyahooDOTcom
// please contact for permission if you wish to use any of this code

function ps() {
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	isOpera = (navigator.userAgent.indexOf('Opera')!=-1)?true:false;
	NS47 = (navigator.userAgent.indexOf('Mozilla/4.7')!=-1)?true:false;
	IE4 = (navigator.appVersion.indexOf("MSIE 4.")!=-1) ? true : false;
	IE5 = (navigator.appVersion.indexOf("MSIE 5.")!=-1) ? true : false;
	IE55= (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? true : false;
	IE6 = (navigator.appVersion.indexOf("MSIE 6.")!=-1) ? true : false;
	IEx = (navigator.appVersion.indexOf("MSIE ")!=-1 && !isOpera) ? true : false;
	iePNG = false;

	// Does the browser support transparent .png?
	if (IE4 || ((IE5 || IE6) && !isMac && !isOpera) || NS47) {
		iext = ".gif";
		transPNG = false;
		css_prefix = "gif_";
	} else {
		iext = ".png";
		transPNG = true;
		css_prefix = "";
	}

	// IE is a stupid, nonstandard piece of garbage... but we'll let them see pretty gfx anyway
	if (IEx && !IE4 && (!IE5 || IE55)) {
		iePNG = true;
		transPNG = true;
		iext = ".png";
		css_prefix = "ie_"
	}

	// Make table images load before background:
	if(transPNG) {
		var imagenames = new Array('/i/n.png', '/i/nb.gif', '/i/nlu.gif', '/i/nr.gif', '/i/nt.png', '/i/ntl2.gif', '/i/ntl.png', '/i/ntm.png', '/i/ntr2.gif', '/i/ntr.png', '/i/shadow.png', '/i/menubg.gif');
	} else {
		var imagenames = new Array('/i/nb.gif', '/i/nlu.gif', '/i/nr.gif', '/i/nt.gif', '/i/ntl2.gif', '/i/ntl.gif', '/i/ntm.gif', '/i/ntr2.gif', '/i/ntr.gif', '/i/shadow.gif', '/i/menubg.gif');
	}
	var preloadimages = new Array();
	if(document.images) {
		for (var i = 0; i < imagenames.length; i++) {
			preloadimages[i] = new Image();
			preloadimages[i].src = imagenames[i];
		}
	}
	
	

	// start of page:
	document.write('<table align="center" cellpadding=0 cellspacing=0 border=0 width="100%" height="100%"> \
	<tr> \
		<td> \
		<table cellpadding=0 cellspacing=0 border=0 width="100%"> \
		<tr> \
		<td align=left valign=bottom width=463 height=60 bgcolor="#2E344B"><img src="/i/dplogo3a.gif" width=463 height=60></td> \
		<td align=right bgcolor="#2E344B" width="100%">');
}

function pa() {
	document.write('</td> \
		</tr> \
		<tr><td align=left valign=top bgcolor="#46526C" background="/i/menubg.gif" colspan=2><img src="/i/dplogo3b.gif" width=463 height=22></td></tr> \
		</table></td> \
	</tr> \
	<tr> \
		<td bgcolor="#46526C" align=center valign=top>');

	// menu:
	document.write('<font size=3 class="mm"><a href="http://digitalpaint.org/news.php" class="mm">&nbsp;News </a>|<a href="http://dplogin.com/" class="mm"> DPLogin </a>|<a href="http://digitalpaint.org/screens.html" class="mm"> Screenshots </a>|<a href="http://digitalpaint.org/files/" class="mm"> Files/Downloads </a>|<a href="http://digitalpaint.org/docs.html" class="mm"> Docs/FAQ </a>|<a href="http://digitalpaint.org/contact.html" class="mm"> Contact </a>|<a href="http://dplogin.com/forums/index.php" class="mm"> Forum </a>|<a href="http://digitalpaint.org/irc/index.html" class="mm"> Chat (IRC) </a>|<a href="http://dplogin.com/dplogin/featurevote/" class="mm"> Feature Vote </a>|<a href="http://digitalpaint.org/links.html" class="mm"> Links&nbsp;</a></font> \
	</td></tr><tr><td height="100%"> \
	<table align="center" cellpadding=0 cellspacing=0 border=0 width="100%" height="100%" class="pagebg"><tr><td> \
	<table align="center" cellpadding=0 cellspacing=0 border=0 width="100%" height="100%" class="pbsshotbg"><tr><td> \
	<table align="center" cellpadding=0 cellspacing=0 border=0 width="100%" height="100%" class="pbguy"><tr><td height=16 width="100%" background="/i/shadow' + iext + '" class=' + css_prefix + 'shadow ></td></tr><tr><td><center>');
}


function ts1() {
	document.write('<br><table border=0 cellpadding=0 cellspacing=0 width="80%"><tr><td><img src="/i/ntl2.gif" width=1 height=25></td><td><table cellpadding=0 cellspacing=0 border=0 width="100%"><tr><td><img src="/i/');
	if(iePNG) {
		document.write('blank.gif" class="ie_ntl');
	} else {
		document.write('ntl' + iext);
	}
	document.write('" width=22 height=25></td><td nowrap=nowrap valign=middle background=/i/ntm' + iext + ' class="' + css_prefix + 'ntm"><font face="tahoma,arial" color="#A8B8C6" size=2><b>&#183;:[ ');
}
function ts2() {
	document.write(' ]:. </b></font></td><td><img src="/i/');
	if (iePNG) {
		document.write('blank.gif" class="ie_nt"');
	} else {
		document.write('nt' + iext + '"');
	}
	document.write(' width=224 height=25></td><td width="100%" background=/i/');
	if (iePNG) {
		document.write('blank.gif class="ie_ntr"');
	} else {
		document.write('ntr' + iext);
	}
	document.write('></td></tr></table></td><td><img src="/i/ntr2.gif" width=1 height=25></td></tr><tr><td valign=top bgcolor=black><img src="/i/nlu.gif" width=1 height=61></td><td width="100%">\
		<div class="n_container">\
		<table border=0 width="100%" cellpadding=16 cellspacing=0');
	if (!iePNG) {
		document.write(' class="' + css_prefix + 'n"');
	}
	document.write('><tr><td><font face="tahoma,arial" size=2>');
}

function ts(title) {
	ts1();
	document.write(title);
	ts2();
}

function tn1() {
	document.write('<b><font color=black>|</font><font size=3>| <font color=white>');
}

function tn2() {
	document.write('</font> |</font><font color=black>|</font></b>');
}

function tn3() {
	document.write('<center><table width="90%" border=0 cellpadding=8><tr><td><font size=2>');
}

function tn4() {
	document.write('<div align=right><font color=white>&#171; ');
}

function tn5() {
	document.write(' &#187;</font></div>');
}

function tn4a(sig) {
	tn4();
	if(sig == "jitspoe") {
		sig = "<a href=http://www.jitspoe.com/ target=_new>jitspoe</a>";
	} else if (sig == "calrathan") {
		sig = "<a href=mailto:" + "calrathan" + "@planetquake.com>Calrathan</a>";
	} else if (sig == "smokeya") {
		sig = "SmokeYa";
	} else if (sig == "nutiket") {
		sig = "Nutiket";
	} else if (sig == "warzone" || sig == "fryth") {
		sig = "<a href=http://fryth.com/ target=_new>Fryth</a>";
	}
	document.write(sig);
	tn5();
}

function tn6() {
	document.write('</font></td></tr></table></center>');
}

function tn(headline, content, sig) {
	if(headline != "") {
		tn1(); document.write(headline); tn2();
	}
	tn3(); document.write(content);

	if(sig && sig != "") {
		tn4a(sig);
	} else {
		document.write('<br>&nbsp;');
	}
	tn6();
}

function te() {
	document.write('</font></td></tr></table>');
	if (iePNG) {
		document.write('<div class="' + css_prefix + 'n"></div>');
	}
	document.write('</div></td><td valign=bottom bgcolor=black><img src="/i/nr.gif" width=1 height=63></td></tr><tr><td bgcolor=black></td><td align=right bgcolor=black><img src="/i/nb.gif" height=1 width=202></td><td bgcolor="#A8B8C6"></td></tr></table>');
}

function c(text) {
	document.write(text);
}

function fs() {
	document.write('<center><table border=0 cellspacing=0 cellpadding=6 width=90%><tr align=left valign=middle><td align=right><font size=3><font color=white><b>Filename</font> [</b></font></td><td><font size=3 color=white><b>Size</b></font></td><td><font size=3><b>] <font color=white>Description</b></font></font></td></tr>');
}

function fc(filename, size, name, description) {
	document.write('<tr valign=top><td align=right nowrap=nowrap><a href="http://www.fileplanet.com/dl.aspx?/planetquake/digitalpaint/'+filename+'"><font size=2>'+filename+'</a> <font color=black>|</font> [</font></td><td align=center><font size=2 color="#A8B8C6">'+size+'</font></td><td><font size=2>] <font color=black>|</font> <font color=white>'+name+'</font> -- '+description+'</font></td></tr>');
}

function fe() {
	document.write('</table></center><br>');
}

var ssCount = 0;
var ssSpan = new Array(10);
var ssBigSpan = new Array(10);
var ssThumbHTML = new Array(10); // need to figure out how to dynamically size this later

function ss() {
	document.write('<center><p id="sshotarea'+ssCount+'">');
	ssSpan[ssCount] = document.createElement("span");
	ssBigSpan[ssCount] = document.createElement("span");
	ssThumbHTML[ssCount] = "";
}

function sc(sname, sext, swidth, sheight) {
	//ssThumbHTML[ssCount] += '<a href="JavaScript:sclick(\''+sname+'\', \''+sext+'\', '+swidth+', '+sheight+', '+ssCount+')" class="sshot"><img src=/images/screenshots/'+sname+'_small.'+sext+' width=160 height=120 border=1></a> ';
	ssThumbHTML[ssCount] += '<a href="/images/screenshots/'+sname+'.'+sext+'" class="sshot"><img src=/images/screenshots/'+sname+'_small.'+sext+' width=160 height=120 border=1></a> ';
}

function se() {
	document.write('</p></center>');
	var ssP = document.getElementById("sshotarea"+ssCount);
	ssSpan[ssCount].innerHTML = ssThumbHTML[ssCount];
	ssP.appendChild(ssSpan[ssCount]);
	ssP.appendChild(ssBigSpan[ssCount]);
	ssCount++;
}

function sclick(sname, sext, swidth, sheight, count) {
	if(sname == "thumbs") {
		ssSpan[count].innerHTML = ssThumbHTML[count];
		ssBigSpan[count].innerHTML = '';
	} else {
		ssSpan[count].innerHTML = '<a href="JavaScript:sclick(\'thumbs\',\'\',0,0,'+count+')" class="sshot"><img src=/images/screenshots/'+sname+'_small.'+sext+' width='+swidth+' height='+sheight+' id="bigss'+count+'" border=1></a>';
		var bigSS = document.getElementById("bigss"+count);
		var bigSSTop = GetTop(bigSS);
		var bigSSLeft = GetLeft(bigSS);
		ssBigSpan[count].innerHTML = '<a href="JavaScript:sclick(\'thumbs\',\'\',0,0,'+count+')" class="sshot"><img src=/images/screenshots/'+sname+'.'+sext+' width='+swidth+' height='+sheight+' id="bigssHighRes'+count+'" border=1 style="position:absolute; left:'+bigSSLeft+'; top:'+bigSSTop+';"></a>';
	}
}

function pe(usestats) {
	document.write('<br><font size=-2 face="tahoma,arial">&copy; 1998-2010 Digital Paint<br>&nbsp;');
	if(usestats) {
		document.write('<br><A href="http://sourceforge.net/projects/paintball2"><IMG src="http://sourceforge.net/sflogo.php?group_id=89601&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></A><br><a target="_blank" href="http://v1.nedstatbasic.net/stats?AAWSawZNDNHgfTt31+FQ7sNcnkcw"><img src="http://m1.nedstatbasic.net/n?id=AAWSawZNDNHgfTt31+FQ7sNcnkcw" border="0" width="22" height="22"></a><br>&nbsp;');
	}
	if(!transPNG) {
		document.write('<br><font color=red>It appears as though your browser does not support transparent PNG\'s.<br>To view this page to its full potential, you should use a browser such as <a href=http://www.mozilla.org target=_new>Mozilla</a>, <a href=http://www.opera.com target=_new>Opera</a>, or <a href=http://www.mozilla.org/projects/firebird/ target=_new>Mozilla Firebird</a>.<br>&nbsp;');
	}
	document.write('</font></center></td></tr></table></td></tr></table></td></tr></table></td></tr></table>');
}


// code from: http://www.webreference.com/dhtml/diner/realpos1/8.html
function GetLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nLeftPos += eParElement.offsetLeft;
        eParElement = eParElement.offsetParent;
    }
    return nLeftPos;
}


function GetTop(eElement)
{
    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}
