function rand(limit) {
	var temp = Math.round(Math.random()*(limit-1));
//	if (temp < 10)
//		temp = "0" + temp;
	return temp;
}


function showTitle() {
	document.write("<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>");
		document.write("<tr>");
			document.write("<td height='100%' align='left' valign='bottom'>");
				document.write("<div class='textw'>");
					document.write("<a href='index.html' target='_top'><img src='images/td_logo.gif' border='0'></a>");
				document.write("</div>");
			document.write("</td>");
			document.write("<td width='300' height='100%' align='right' valign='top'>");
				document.write("<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>");
			 		document.write("<tr>");
						document.write("<td height='20' align='right' valign='top'>");
							document.write("<div class='topmenu'>");
								document.write("<a href='index.html' target='_top'><font color='#FFFFFF'>Home</font></a> | ");
								document.write("<a href='http://www.teardown.se/forum' target='page'><font color='#FFFFFF'>Forum</font></a> | ");
								document.write("<a href='mailto:teardown@hotmail.com'><font color='#FFFFFF'>Contact (@)</font></a>&nbsp;");
							document.write("</div>");
						document.write("</td>");
					document.write("</tr>");
			 		document.write("<tr>");
						document.write("<td align='right' valign='bottom'>");
							document.write("<img src='images/preview" + rand(6) + ".gif'>");
						document.write("</td>");
					document.write("</tr>");
				document.write("</table>");
			document.write("</td>");
		document.write("</tr>");
	document.write("</table>");
}


function newsList(selection, counter) {
	for (var a = 0; a < news_counter; a++)
	{
		if (news[a][0] == selection || selection == "")
		{
			document.write("<div class='smallw'><center>");
			
			// Logo
			if (selection == "")
			{
				if (news[a][0] == "AlienAssault")
					document.write("<a href='alienassault.html'><img src='games/alienassault/www/images/logo_small.gif' border='0'></a>");
				else if (news[a][0] == "SnowRescue")
					document.write("<a href='snowrescue.html'><img src='games/snowrescue/www/images/logo_small.gif' border='0'></a>");
				else if (news[a][0] == "OfficeNinjas")
					document.write("<a href='officeninjas.html'><img src='games/officeninjas/www/images/logo_small.gif' border='0'></a>");
				else
					document.write("<a href='portfolio.html'><img src='images/td_logo_small.gif' border='0'></a>");

				// White line
				document.write("<img src='images/blankpixel.gif' width='2'><br>");
				document.write("<img src='images/whitepixel.gif' width='200' height='1'><br>");
				document.write("<img src='images/blankpixel.gif' width='2'><br>");
			}

			// Title
			document.write("<b><i>" + news[a][4] + "</i></b><br>");
			
			// Date
			if (news[a][3] == 1 || news[a][3] == 21 || news[a][3] == 31)
				document.write(news[a][3] + "st ");
			else if (news[a][3] == 2 || news[a][3] == 22)
				document.write(news[a][3] + "nd ");
			else
				document.write(news[a][3] + "th ");

			if (news[a][2] == 1)
				document.write("Jan");
			else if (news[a][2] == 2)
				document.write("Feb");
			else if (news[a][2] == 3)
				document.write("Mar");
			else if (news[a][2] == 4)
				document.write("Apr");
			else if (news[a][2] == 5)
				document.write("May");
			else if (news[a][2] == 6)
				document.write("Jun");
			else if (news[a][2] == 7)
				document.write("Jul");
			else if (news[a][2] == 8)
				document.write("Aug");
			else if (news[a][2] == 9)
				document.write("Sep");
			else if (news[a][2] == 10)
				document.write("Oct");
			else if (news[a][2] == 11)
				document.write("Nov");
			else if (news[a][2] == 12)
				document.write("Dec");

			document.write(", " + news[a][1] + "</div>");
			
			document.write("<img src='images/blankpixel.gif' width='2'><br>");

			// Text
			document.write("<div class='smallw'>" + news[a][5] + "</div>");

			document.write("<br><br>");

			counter--;

			if (counter == 0)
				break;
		}
	} 
}


function infoList() {
	document.write('<div class="mediumw"><b><img src="images/icon_community.gif"> Forum</b><br><img src="images/whitepixel.gif" width="225" height="2"></div>');
	document.write('<a href="forum" target"page"><div class="smallw"><b>Join our forum and take part in the community</b> by giving feedback on our games, getting your questions answered and reading the latest news from the developers...</div></a>');

	document.write('<br>');

	document.write('<div class="mediumw"><b><img src="images/icon_donations.gif"> Donations & Support</b><br><img src="images/whitepixel.gif" width="225" height="2"></div>');
	document.write('<div class="smallw">');
		document.write('<b>Our games are freeware but if you like to feel free to donate money</b> to TearDown if you think the joy of playing our games is worth it.<br>');
		document.write('Send the donation yourself using <a href="http://www.paypal.com" target="new">PayPal</a> to PayPal account <b>teardown@hotmail.com</b>.');
	document.write('</div>');

document.write('<br><table border="0" cellpadding="0" cellspacing="0" align="center"><tr><td align="center"></td></tr><tr><td align="center"><a href="#" onclick="javascript:window.open(\'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside\',\'olcwhatispaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350\');"><img  src="https://www.paypal.com/en_US/i/logo/PayPal_mark_50x34.gif" border="0" alt="Acceptance Mark"></a></td></tr></table>');

document.write('<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post">');
document.write('<input type="hidden" name="cmd" value="_s-xclick">');
document.write('<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHHgYJKoZIhvcNAQcEoIIHDzCCBwsCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBFaeRn8nW1eXnfnhd6XFznGsbRCRkKIsupTdUP5+KOXyMuIskA62oFjIujkjCVL8Uljtu/xWJ6C/VfgQYs9zZbcBAMuNO02b/cgPbOEHXPAsOYYhER7pzPKNOjIjw+KRF+ZGjL+A2v3DR4YA1tilw3it7QKbjR8EWHz5H2Tl94RTELMAkGBSsOAwIaBQAwgZsGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIFbfGBdpmG6mAePVY+zKUsQi4pbIff+gadC8mIketkjHT/Nk3dnFzZ0EBq6c1cGNyk1Jkzgs7E1byVDu4974VWoHMbLCQwOrs7zMQpXq704rrgfGJ2DFyeCqjPvKLGLwPcEIQNr6xtyIVDUaiBmXiOAIYky9goPo45vKq7zfnfnM4vKCC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H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTEwMDUwMzA4MTAwN1owIwYJKoZIhvcNAQkEMRYEFOWYE/XeLObnbew9nZpolJbFnbt6MA0GCSqGSIb3DQEBAQUABIGAKr0h4KFGhnNuzVOHKOVPlncaQJaHeMVXp+knSDc/2APHX/IYeYIngz/9IyGfq4ZNrJaQlH6bMZySVbNNrkv0JyQ8ujitGlHIoxbNyl1c8VzAkUkoJW/eIP1x9CSlmVvQAK1upxQhRSw9KBV5OUW/xyFKqO7/b13my5/jV10DOfU=-----END PKCS7-----">');
document.write('<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">');
document.write('<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">');
document.write('</form></center>');


/*	document.write('<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post">');
	document.write('<input type="hidden" name="cmd" value="_donations">');
	document.write('<input type="hidden" name="business" value="teardown@hotmail.com">');
	document.write('<input type="hidden" name="lc" value="US">');
	document.write('<input type="hidden" name="item_name" value="TearDown">');
	document.write('<input type="hidden" name="currency_code" value="SEK">');
	document.write('<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">');
	document.write('<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">');
	document.write('<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">');
	document.write('</form></center>');*/

	document.write('<div class="mediumw"><b><img src="images/icon_partners.gif"> Partners</b><br><img src="images/whitepixel.gif" width="225" height="2"></div>');
	document.write('<img src="images/blankpixel.gif" width="2" height="2">');
		document.write('<div class="smallw"><center>');
		document.write('<a href="http://www.melmac.se" target="new"><img src="images/melmac_large.gif" border="0" alt="MELMAC.se" title="MELMAC.se hosting"></a>');
		document.write('<br>Web host<br><br>');
		document.write('<a href="http://www.strategyinformer.com" target="new"><img src="images/strategyinformer.gif" border="0" alt="strategyinformer.se" title="Strategyinformer.com"></a>');
		document.write('<br>File host');
		document.write('</div>');
	document.write('</center>');
}
