// General use code.
// Copyright (C) 2000-2001 by Gregg Giles.
//
// This code is written in JavaScript.




// ***********************************************************************************
// Global definitions. Do no modify these values.
// ***********************************************************************************

var DATE_TODAY = '';						// initialize current date string
var DIR_CONTACT = '';						// initialize the contact dir value
var DIR_LEGAL = '';							// init the legal dir value
var DIR_LINKS = '';							// initialize the links dir value
var DIR_MAPS = '';							// initialize the maps dir value
var DIR_ROOT = '';							// initialize root directory value
var DIR_TECHSUPPORT = '';					// initialize technical support dir value
var PATH_STYLE_SHEET = '';				// initialize style sheet path value



// ***********************************************************************************
// Determine following variables - do NOT move these
// ***********************************************************************************

DIR_ROOT = setCurrentDirectory();				// set the root directory to allow JavaScript relative path referencing
DIR_CONTACT = DIR_ROOT + 'contact/';			// set the contact directory
DIR_TECHSUPPORT = DIR_ROOT + 'technical_support/';	// set the technical support directory
DIR_LEGAL = DIR_ROOT + 'legal/';				// set the legal directory
DIR_LINKS = DIR_ROOT + 'links/';				// set the links directory
DIR_MAPS = DIR_ROOT + 'maps/';				// set the maps directory
PATH_STYLE_SHEET = DIR_ROOT + 'styles.css';	// set the style sheet path
PATH_BANNER_MAIN = DIR_ROOT + 'images/slm_950x100.gif'; 	// banner image path and name
DATE_TODAY = getCurrentDate();				// get the current date






// ***********************************************************************************
// Check browser ID info and return version info
// ***********************************************************************************

function determineBrowserVersion(browserVersion) {
	var browser_version;
	var spacePos;

	spacePos = browserVersion.indexOf(' ', 0);
	browser_version = browserVersion.substring(0, spacePos);
	return browser_version;
};	// end function





// ***********************************************************************************
// Detect the browser and display appropriate messages
// ***********************************************************************************

function detectBrowser() {

	// Internet Explorer messaging
	if (navigator.appName == "Microsoft Internet Explorer") {
		//alert("Internet Explorer " + determineBrowserVersion(navigator.appVersion) + "\n");
		if (determineBrowserVersion(navigator.appVersion) <= 4.0) {
			//alert("New IE!\n");
			// There's really nothing to say here - if it's older than MSIE 4.0, it doesn't support JavaScript, so this
			// stuff couldn't be called anyway. This code is being left here as a stub for the future, because you know
			// it's going to be needed eventually...
		}	// end if
		else {
			//alert("New IE!\n");
		};	// end else
	};	// end if


	// Netscape messaging
	if (navigator.appName == "Netscape") {
		//alert("Netscape Navigator " + determineBrowserVersion(navigator.appVersion) + "\n");
		if (determineBrowserVersion(navigator.appVersion) <= 4.72) {
			alert("A NEW VERSION OF NETSCAPE IS AVAILABLE!\n\n" +
				"Your version of Netscape doesn't properly support Cascading Style Sheets (CSS) and will\n" +
				"cause the layout of this site to look garbled. It is strongly recommended that you upgrade \n" +
				"to Netscape 6 PR1 now to view it properly.\n\n" +
				"If you don't upgrade, you can somewhat help the site appearance by disabling CSS under the \n" +
				"Edit>Preferences>Advanced menu, but this will only be of minor help. It is strongly \n" +
				"recommended that you upgrade to Netscape 6 PR1 right away.\n" );
		}	// end if
		else {
			//alert("New NN!\n");
		};	// end else
	};	// end if

}; // end function





// ***********************************************************************************
// Return an HTML string containing reference to a variably-sized spacer pixel
// Parameters:
// 	horiz_pixels: horizontal pixel size
// 	vert_pixels: vertical pixel size
// 	isbreak: 1 = adds <br> after spacer, 0 = no <br> after spacer
// ***********************************************************************************

function insertSpacer(horiz_pixels, vert_pixels, isbreak) {
	var spacerString = '';

	spacerString += '<img src=\"path\" width=\"'+ horiz_pixels +'\" height=\"'+ vert_pixels +'\" border=\"0\">';
	if (isbreak == 1) {
		spacerString += '<br>';
	};	// end if
	return spacerString;
};	// end function





// ***********************************************************************************
//  Display item image and a descriptive string on its own
// ***********************************************************************************

function displayItemImage(item_image_path, item_description) {
	var itemImageClass = 'image-nomargin-border2px';								// CSS class used to format item image
	var itemImageDescriptionClass = 'text-center-10pt';				// item image description CSS
	var pageBgColor = COLOR_BLACK;								// page background color
	var pathPageBgImage = '';		// page background image (path relative to file that includes this one)
	var screenOutput = '';						// string containing html screen display code

	// Build output display string
	screenOutput +=
		'<html><head>'+
		'<link rel=stylesheet type="text\/css" href=\"'+ PATH_STYLE_SHEET  +'\">'+
		'<\/head>'+
		'<body bgcolor=\"'+ pageBgColor +'\" background=\"'+ pathPageBgImage +'\"'+
		'leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">' +
		'<base target=\"main\">'+
		// Table
		'<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\">' +
		'<tr height=\"10\"><td>'+
		// Display image
		'<center><img CLASS=\"'+ itemImageClass +'\" src=\"'+ item_image_path +'\"  hspace=10><br>'+
		// Display description
		insertSpacer(1, 25, 1) +
		'<DIV CLASS=\"'+ itemImageDescriptionClass +'\">'+ item_description +'<\/DIV>'+
		'<\/center></td></tr>'+
		// Close the table
		'<\/table>'+
		'<\/body><\/html>';

	// write the document to the frame and close it
	top.main.document.write(screenOutput);
	top.main.document.close();

};	// end function



// ***********************************************************************************
// Set the current directory to allow JavaScript relative path referencing
// ***********************************************************************************

function setCurrentDirectory() {
	var current_dir;
	var slash_position;

	current_dir = location.href;						// get the current path
	slash_position = current_dir.lastIndexOf('/');			// find the last slash in the string
	current_dir = current_dir.substring(0, slash_position+1);	// set the current directory to include entire URL up to and including final slash

	return current_dir;
};	// end function





// ***********************************************************************************
// Get today's date
// ***********************************************************************************

function getCurrentDate() {
	var dayName = new Array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
	var monthName = new Array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
		'October', 'November', 'December');
	var now = new Date;

	var current_day = dayName[now.getDay()];
	var current_month = monthName[now.getMonth()];
	var current_date = now.getDate();
	var current_year = now.getFullYear();

	var date_string = '';

//	september 17
//	september 17, 1969
//	wednesday, september 17, 1969
//	wednesday, september 17, 1969
//	09/17/1969
//	09/17/69
//	17 september 1969

	// form the string
	date_string = current_day +', '+ current_month +' '+ current_date +', '+ current_year;
	return date_string;

	//alert(current_day + current_month + current_date + current_year);
};	// end function



// ***********************************************************************************
// Display page header
// ***********************************************************************************

function displayHeader() {
	var screenOutput = '';									// string containing html screen display code
	// Build output display string
	screenOutput +=
				'<img src=\"images\/spacer.gif\" width=\"1\" height=\"5\" border=\"0\"><br>'+

				'<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">' +
					// banner image
					'<tr>'+
						'<td valign=\"top\">'+
							'<DIV CLASS=\"welcome\">Come Visit My Universe...<\/div>'+
							'<img src=\"'+ PATH_BANNER_MAIN +'\" ALT=\"Security Leak Magazine\" border=\"0\"><br>'+
						'<\/td>'+
					'<\/tr>'+

					// Display some additional stuff
					'<tr>'+
						'<td align=\"center\">'+
							'<DIV CLASS=\"date\">'+
							// display date
							'Today is '+ DATE_TODAY +'<br><\/DIV>'+
							'<img src=\"images\/spacer.gif\" width=\"1\" height=\"5\" border=\"0\"><br>'+
							// display quote
//							'<DIV CLASS=\"quote\">'+
//							'\"'+ randomQuote()+ '\"'+
//							'<\/DIV>'+
							'<hr noshade size=\"2\" color=\"#171F8B\">'+
						'<\/td>'+
					'<\/tr>'+
				// Close the table
				'<\/table>'+

				'<img src=\"images\/spacer.gif\" width=\"1\" height=\"10\" border=\"0\"><br>';

	// write the document to the frame and close it
	top.main.document.write(screenOutput);
	top.main.document.close();

};	// end function



// ***********************************************************************************
// Generate random quote
// ***********************************************************************************

function randomQuote() {
	var quote = 'Quote error... please notify the webmaster.';

	allQuotes = new Array(
		'Be sure to wear your fragging shoes before you go outside today.',
		'Don\'t forget to reload.',
		'In the event of a flashbang, the last thing you will feel is your brain compressing.',
		'Let me count the .357 magnum ways that I love thee.',
		'.22, .38, .44, 5.56, 7.62... whatever, it all works for me.',
		'Caution: A MAC-10 will not improve your survival rate.',
		'Bad: Stop, look, listen, shoot. Good: shoot, shoot, shoot, run.',
		'I\'m not wearing any pants.',
		'When a man approaches you with a gun bigger than yours, the correct answer is \'Yes, <u>SIR<\/u>!\'',
		'Oh great! First I get shot, now I\'m bleeding...',
		'What you need is a good ass-kicking.',
		'Have you fragged your best friend today?',
		'You really better let out all that SW-OfficeAnger.unr before somebody gets hurt.',
		'Splork the livender bastagon.',
		'Two nothin\'s is nothin\'. Two half-nothin\'s is a whole nothin\'. That\'s mathematics son. You can argue with me but you can\'t argue with figures!',
		'Just sit back and relax, everything\'s going to be just fine...',
		'Aren\'t you forgetting something?',
		'I thought more about this front-end last night than you EVER will!',
		'Wherever you go, there you are.',
		'I have a very cunning plan.',
		'Shoot first. Ask questions later.',
		'To avoid a trap, you must first know of it\'s existence.',
		'Yup, life moves pretty fast. If you don\'t stop to look around once in a while, you could miss it!',
		'Everybody looks tough holding a machine gun.',
		'Boy, I say boy, I keep pitchin\' \'em and you keep missin\' \'em!',
		'Sam, you\'re my friend, aren\'t you? Well do me a favor... until this is all over with, just stay away from me...'
		);

	quote = Math.floor ((Math.random() * allQuotes.length));

	return(allQuotes[quote]);
};	// end function



// ***********************************************************************************
// Display shortcuts
// ***********************************************************************************

function displayShortcuts() {
	var screenOutput = '';									// string containing html screen display code
	var borderColorInvisible = COLOR_BLACK;			// the color of the table border that you don't want to see
	var borderColorVisible = COLOR_RED_BLOOD;					// the color of the table border that you do want to see
	var bulletWidth = 5;									// pixel width of the "bullet" preceeding each shortcut item
	var itemHeight = 20;									// height of each shortcut's box
	var gapHeight = 5;										// pixel gap between shortcut items
	var gapWidth = 10;									// left gap pixel width; seperates table from edge of browser window

	// Build output display string
	screenOutput +=

		'<table class=\"table-shortcuts\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">' +
			// Sections
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td colspan=\"2\">'+
					'<DIV CLASS=\"banner-10pt\">Sections</DIV>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// News
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'main.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'News\'; return true\">News<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Store
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'store/store.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Buy items online from Security Leak Magazine\'; return true\">Security Leak Shop<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// About SLM
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'about/about.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'About the Security Leak Magazine\'; return true\">About SLM<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+


			// Header: Issue Archive
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td colspan=\"2\">'+
					'<DIV CLASS=\"banner-10pt\">Issue Archive</DIV>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue Index
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Index of all issues of Security Leak\'; return true\">Complete Issue Index<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 6
//			'<tr>'+
//				'<td width=\"'+ gapWidth +'\"><\/td>'+
//				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
//				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
//					'<a href=\"'+ DIR_ROOT +'slm/issue_06/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 6\'; return true\">Issue 6<\/a>'+
//				'<\/td>'+
//			'<\/tr>'+
//			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 5
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_05/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 5\'; return true\">Issue 5<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 4
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_04/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 4\'; return true\">Issue 4<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 3
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_03/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 3\'; return true\">Issue 3<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 2
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_02/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 2\'; return true\">Issue 2<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Issue 1
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_ROOT +'slm/issue_01/index.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Issue 1\'; return true\">Issue 1<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Community
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td colspan=\"2\">'+
					'<DIV CLASS=\"banner-10pt\">Community</DIV>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// forum
//			'<tr>'+
//				'<td width=\"'+ gapWidth +'\"><\/td>'+
//				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
//				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
//					'<a href=\"http:\/\/pub39.bravenet.com\/forum\/show.php?usernum=3318714655&cpv=1\" target=\"_top\" ONMOUSEOVER=\"window.status=\'Message boards you can read and post to\'; return true\">Forum<\/a>'+
//				'<\/td>'+
//			'<\/tr>'+
//			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Links
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_LINKS +'links.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Links to cool sites\'; return true\">Links<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+



			// Header: Administrivia
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td colspan=\"2\">'+
					'<DIV CLASS=\"banner-10pt\">Administrivia</DIV>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// contact
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_CONTACT +'contact.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Contact Security Leak\'; return true\">Contact<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Technical Support
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_TECHSUPPORT +'technical_support.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Technical support\'; return true\">Technical Support<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

			// Legal
			'<tr>'+
				'<td width=\"'+ gapWidth +'\"><\/td>'+
				'<td class=\"td-shortcut-bullet\" width=\"'+ bulletWidth +'\" height=\"'+ itemHeight +'\"><\/td>'+
				'<td class=\"td-shortcut\" valign=\"middle\" height=\"'+ itemHeight +'\">'+
					'<a href=\"'+ DIR_LEGAL +'legal_notices.html\" target=\"main\" ONMOUSEOVER=\"window.status=\'Legal notices and other droll pap\'; return true\">Legal Notices<\/a>'+
				'<\/td>'+
			'<\/tr>'+
			'<tr height="'+ gapHeight +'"><td><\/td><\/tr>'+

		// Close the table
		'<\/table>';

	// write the document to the frame and close it
	top.main.document.write(screenOutput);
	top.main.document.close();
};	// end function





// ***********************************************************************************
// Main. This is always executed when the browser loads the index.html file.
// ***********************************************************************************

//detectBrowser();						// check browser version and display messages appropriately