/*
EVERYTHING.JS
created by Brent Martin
modified for use in NHGA Web Site 11/21/00

Couple things were changed in this version...
	1) consolidated everything related to scaling images into the placeImage() function - it really did not need to be anyplace else
	2) had to get rid of the year in the showDate() function.  Turns out IE changed how it handles dates between versions (big suprise).  Due to how the .getYeat() function was written, it was intended to work properly starting with the year 2000 - before that, you had to add 1900.  Microsoft missed that point in their implimentation with IE5, so you still have to add 1900, but with Netscape, you just use the date returned.  So, to get it right for both, you have to detect the browser...forget it - too much trouble!
	3) removed functions that related to cookies since this site is not using them at all.
	4) moved the date functions to a seperate file since I did not use them in all the places that I use the image work


VALIDATED 3/29/02
*/


/* GETS BROWSER INFORMATION */
function getBrowser()
{
	bName = navigator.appName;
    bVer = parseInt(navigator.appVersion);
	bAgent = navigator.appAgent;

     if (bName == "Netscape")
         switch (bVer)
         {
             case 4:     brwsr = "n4"; break;
             case 3:     brwsr = "n3"; break;
             case 2:     brwsr = "n2"; break;
             default:    brwsr = "n1"; break;
         }
     else
     if (bName == "Microsoft Internet Explorer")
         switch (bVer)
         {
             case 4:     brwsr = "e4"; break;
             case 3:     brwsr = "e3"; break;
             default:    brwsr = "u1"; break;
         }
     else
	 	// other than Netscape or MSIE
         brwsr = "u1";

	return(brwsr);
}

function getFrameWidth(orig_width, location)
{
/* determine browser type to know what function to use:
	IE is simplely screen.width * .15
	NN is window.innerWidth + 15      */
	var browser;
	var framewidth;

	browser = "e4"; // just for an initial value
	browser = getBrowser();
	/*
	if (browser.indexOf("n") != -1)
	// netscape browser
		framewidth = Math.floor(window.innerWidth + 15);
	else // MS IE
		framewidth = Math.floor(screen.width * .15);
	*/
	// something is wrong with the window.innerWidth calc, default to this for now
	if ( screen.width > 1024)
	// then we have enough room already and don't need to adjust
		return(orig_width);

	if (location == 1)
	// then it's in the main frame and we don't want to adjust it tooooo much - rather than a 80% reduction, we need to
	// work with the 80% area left for that frame
		return(orig_width * .7);

	if (browser.indexOf("n") != -1)
	// netscape browser
		framewidth = Math.floor((screen.width * .17) - 23);
	else // MS IE
		framewidth = Math.floor((screen.width * .165) - 28);
	//framewidth = Math.floor(screen.width * .175)
	return (framewidth);
}

function setImageHeight(initial_width, new_width, initial_height)
{
	var ratio;
	var new_height;
	ratio = new_width / initial_width;
	new_height = Math.floor(initial_height * ratio);
	return(new_height);
}

	function change2(index, imgSrc, userMessage)
	{
		window.status = userMessage;
		document.images[index].src = nav_image[imgSrc].src;
	}

function placeImage(name, orig_wid, orig_high, location)
{
/* define imaging variables */
	var iwid;		// calculated image width
	var ihigh;	// calculated image height
	var frameWid;	// users frameWidth for navigation frame

	/* now, determine what frame space we have to work with
		and set image height and width */
	frameWid = getFrameWidth(orig_wid, location);

	iwid = frameWid; //adjustments have already been made

	/* setImageHeight needs original width, new width and original height */
	ihigh = setImageHeight(orig_wid, iwid, orig_high); // (initial_width, new_width, initial_height)

	/* ********************************************************* */
	/* we now have all the information we need to place an image */
	/* ********************************************************* */
	
	if (location == 3)
		document.write("<div align='center'><img src=" + name + " width= " + orig_wid + " height= " + orig_high + " border='0' vspace='0' hspace='0'></div>");
	else 	document.write("<div align='center'><img src=" + name + " width= " + iwid + " height= " + ihigh + " border='0' vspace='0' hspace='0'></div>");

}


function rotatingImage()
{
/* define imaging variables */
	var iwidth;		// calculated image width
	var iheight;	// calculated image height
	var iname;		// image name

	// check time value and use mod to determine which image to use
	// just intended to be a random looking image routine...
	//1017360074766
	//1000000000000
	
	today = new Date();
	timenow = today.getTime();
	timedigit = timenow   % 1000000000000;
	timedigit = timedigit % 100000000000;
	timedigit = timedigit % 10000000000;
	timedigit = timedigit % 1000000000;
	timedigit = timedigit % 100000000;
	timedigit = timedigit % 10000000;
	timedigit = timedigit % 1000000;
	timedigit = timedigit % 100000;
	timedigit = timedigit % 10000;
	timedigit = timedigit % 1000;
	timedigit = timedigit % 100;
	timedigit = timedigit % 10;

	switch (timedigit){
		case 0: placeImage('/siteimages/2003photos/players/images/DSC03638014b.jpg', (550*.50), (471*.50), 1);
				document.write("<BR><FONT size='-3'><B>Golfing with Friends!</B></FONT>");
			break;
		case 1: placeImage('/siteimages/2001photos/images/fogies.jpg', (245*.65), (350*.65), 1);
				document.write("<BR><FONT size='-3'><B>Do you remember what we do now?</B></FONT>");
			break;
		case 2:	placeImage('/siteimages/2003photos/banquet/images/BLM335b.jpg', (437*.65), (363*.65), 1);
				document.write("<BR><FONT size='-3'><B>Our Raffle Helpers in 2003!</B></FONT>");
			break;
		case 3:	placeImage('/siteimages/2001photos/images/shotoftheday.jpg', (350*.65), (268*.65), 1);
				document.write("<BR><FONT size='-3'><B>Our Raffle Helpers in 2001!</B></FONT>");
			break;
		case 4: placeImage('/siteimages/2001photos/images/johnnytv.jpg', (350*.65), (289*.65), 1);
				document.write("<BR><FONT size='-3'><B>I won a TV!</B></FONT>");
			break;
		case 5: placeImage('/siteimages/2001photos/images/samtowel.jpg', (217*.65), (350*.65), 1);
				document.write("<BR><FONT size='-3'><B>Who won this towel?</B></FONT>");
			break;
		case 6: placeImage('/siteimages/2003photos/banquet/images/BLM513b.jpg', (315*.65), (357*.65), 1);
				document.write("<BR><FONT size='-3'><B>Smile! You Won!</B></FONT>");
			break;
		case 7: placeImage('/siteimages/2003photos/banquet/images/BLM26b.jpg', (394*.65), (500*.65), 1);
				document.write("<BR><FONT size='-3'><B>Driver, &nbsp; Miss Daisy?</B></FONT>");
			break;
		case 8: placeImage('/siteimages/2001photos/images/bday2.jpg', (350*.65), (222*.65), 1);
				document.write("<BR><FONT size='-3'><B>Who cares what I won!</B></FONT>");
			break;
		default : placeImage('/siteimages/2003photos/banquet/images/BLM535b.jpg', (393*.55), (535*.55), 1);
				document.write("<BR><FONT size='-3'><B>Did you get enough raffle tickets?</B></FONT>");
			break;
		} // end of switch
}