// Browser & Platform Variables
var platform = navigator.platform.substr(0,3);
var browser = navigator.appName;
var shortVersion = navigator.appVersion.substr(0,1);
var longVersion = navigator.appVersion;

// Variables needed for Rollovers
var finished = 'no';
var over = 'no';
var whichOne = ' ';
var whichNews = '1';
var styleSheetElement;
var oldElement;


// Function to Assign the relative path to images and links
if (whichLevel == 0) {
	var path = '';
} else {
	var path = '../';
}


// Function to Print out Menu Selectors for Pages With Menus for All Browsers but Netscape4.x
function menuSelector() {
	if ((browser != 'Netscape') || (shortVersion >= 5)) {
		document.write('<style type="text/css">\n');
		for (var i = 0; i < navMenus.length; i++) {
			for (var j = 0; j < 3; j++) {
				if (j==1) {
					document.write('{');
				}
				if(j == 0)  {
					document.write('#' + navMenus[i][0][0] + 'Menu ');
				} else if (j == 1) {
					document.write('top : ' +navMenus[i][0][1] + '; ');
				} else if (j == 2) {
					document.write('left : ' +navMenus[i][0][2] + '; ');
				}
			}
			document.write('visibility:hidden; z-index : 2; position : absolute;\n');
			document.write('}\n\n');
		}
		document.write('</style>\n\n');	
		return true;
	}
}


// Function to Print out Font Class Styles For All Browsers

function fontStyles() {
	document.write('<style type="text/css">\n')
	for (var i = 0; i < pageStyles.length; i++) {
		for (var j = 0; j < eval('pageStyles[' + i + '].length;'); j++) {
			if(pageStyles[i][j]) {
				if(j==0) {
					document.write('.' + pageStyles[i][j] + ' { ');
				} else if (j==1) {
					document.write('color : ' + pageStyles[i][j] + '; ');
				} else if(j==2) {
					var fontSize = pageStyles[i][j];
					newSize =Number(fontSize);
					if (platform == 'Mac') {
						if (((browser == 'Microsoft Internet Explorer') && (longVersion != '4.0 (compatible; MSIE 5.0; Macintosh; I; PPC)')) || ((browser == 'Netscape') && (shortVersion < 5))) {
							newSize = newSize + 3;
						}
					}
					document.write('font : ' + newSize + 'pt');
				} else if(j==3) {
					document.write('/' + pageStyles[i][j] + '');
				} else if(j==4) {
					document.write(' ' + pageStyles[i][j] + '');
				} else if(j==5) {
					document.write('; text-decoration : ' + pageStyles[i][j] + '; ');
				} else if(j==6) {
					document.write('font-weight : ' + pageStyles[i][j] + '; ');
				} else if(j==7) {
					document.write('background-color : ' + pageStyles[i][j] + '; ');
				}
			}
		}
		document.write('}\n\n');
	}
	document.write('</style>\n\n');
	return true;	
}




menuSelector();
fontStyles();




if (document.images) {

donateOn = new Image();
donateOn.src = "images/sn_donate_on.gif";
donateOff = new Image();
donateOff.src = "images/sn_donate_off.gif";

volunteerOn = new Image();
volunteerOn.src = "images/sn_volunteer_on.gif";
volunteerOff = new Image();
volunteerOff.src = "images/sn_volunteer_off.gif";

food_driveOn = new Image();
food_driveOn.src = "images/sn_food_drive_on.gif";
food_driveOff = new Image();
food_driveOff.src = "images/sn_food_drive_off.gif";

take_actionOn = new Image();
take_actionOn.src = "images/sn_take_action_on.gif";
take_actionOff = new Image();
take_actionOff.src = "images/sn_take_action_off.gif";

contactOn = new Image();
contactOn.src = "images/sn_contact_us_on.gif";
contactOff = new Image();
contactOff.src = "images/sn_contact_us_off.gif";

homeOn = new Image();
homeOn.src = "images/sn_home_on.gif";
homeOff = new Image();
homeOff.src = "images/sn_home_off.gif";

how_to_helpOn = new Image();
how_to_helpOn.src = "images/tn_how_to_help_on.gif";
how_to_helpOff = new Image();
how_to_helpOff.src = "images/tn_how_to_help_off.gif";

need_helpOn = new Image();
need_helpOn.src = "images/tn_need_help_on.gif";
need_helpOff = new Image();
need_helpOff.src = "images/tn_need_help_off.gif";

newsOn = new Image();
newsOn.src = "images/tn_news_on.gif";
newsOff = new Image();
newsOff.src = "images/tn_news_off.gif";

about_hungerOn = new Image();
about_hungerOn.src = "images/tn_about_hunger_on.gif";
about_hungerOff = new Image();
about_hungerOff.src = "images/tn_about_hunger_off.gif";

about_usOn = new Image();
about_usOn.src = "images/tn_about_us_on.gif";
about_usOff = new Image();
about_usOff.src = "images/tn_about_us_off.gif";

faqOn = new Image();
faqOn.src = "images/tn_faq_on.gif";
faqOff = new Image();
faqOff.src = "images/tn_faq_off.gif";

homeOn = new Image();
homeOn.src = "images/tn_home_on.gif";
homeOff = new Image();
homeOff.src = "images/tn_home_off.gif";



} else {

alert('oops');

}

// function that turns on the main nav graphics as well as the menus
function menuOn(pic) {
	if (finished == 'yes') {
		over = 'yes';
		if ((browser == 'Netscape') && (shortVersion < 5)) {
			if (whichOne != ' ')  {
				eval('document.' + whichOne + 'Menu.visibility = "hidden"');	
				if (whichLevel == 1) {
					document.images[whichOne].src = eval('sec' + whichOne + 'Off.src');		
				} else {
					document.images[whichOne].src = eval(whichOne + 'Off.src');		
				}	
			}
			eval('document.' + pic + 'Menu.visibility = "visible"');
			if (whichLevel == 1) {
				document.images[pic].src = eval('sec' + pic + 'On.src');
			} else {
				document.images[pic].src = eval(pic + 'On.src');
			whichOne = pic;	
			}		
		}
		else {
			
			if(document.images) {
				if (whichOne != ' ') {
					if (whichLevel == '1') {
						eval('document.images[whichOne].src = sec' + whichOne + 'Off.src');
					} else {
						eval('document.images[whichOne].src = ' + whichOne + 'Off.src');
					}
					whichOne = whichOne + 'Menu';
					oldElement = document.getElementById(whichOne);
					oldElement.style.visibility = "hidden";
					
				}
				layerName = pic + 'Menu';
				styleSheetElement = document.getElementById(layerName);
							
				styleSheetElement.style.visibility = "visible";
				if (whichLevel == 1)  {
					eval('document.images[pic].src = sec' + pic + 'On.src');
				} else {
					eval('document.images[pic].src = ' + pic + 'On.src');
				}
				whichOne = layerName;		
			}
		}
	}
}


// Timer function that is run to give the user time to get to the menu from the button
function overChecker(pic) {
	if ((over == 'yes') && (finished == 'yes')) {
		whichOne = pic;
		over = 'no';
		setTimeout("menuOff()", 100);
	}
}

// function that turns off the main nav graphics as well as the menus
function menuOff() 
{
	if (document.images) {
		if (over == 'no')  {	
			if ((browser == 'Netscape') && (shortVersion < 5)) {
				if (whichLevel == 1) {
					document.images[whichOne].src = eval('sec' + whichOne + 'Off.src');		
				} else {
					document.images[whichOne].src = eval(whichOne + 'Off.src');		
				}
				eval('document.' + whichOne + 'Menu.visibility = "hidden"');	
			}
			else {
				styleSheetElement.style.visibility = "hidden";
				if (whichLevel == 1) {
					eval('document.images[whichOne].src = sec' + whichOne + 'Off.src');
				} else {
					eval('document.images[whichOne].src = ' + whichOne + 'Off.src');
				}
			}
		}	
	}
}



// Image replace On Function	
function on(pic) {
	if (document.images) { 
		if ((browser == 'Netscape') && (shortVersion < 5)) 
		{
			document.images[pic].src = eval(pic + 'On.src');
		}
		else
		{
			eval('document.images[pic].src = ' + pic + 'On.src');
		}
	}
}
        

// Image replace Off Function	
function off(pic) {     
	if(document.images) {
		if ((browser == 'Netscape') && (shortVersion < 5)) 
		{
			document.images[pic].src = eval(pic + 'Off.src');
		}
		else
		{
			eval('document.images[pic].src = ' + pic + 'Off.src');
		}
	}	
}

// Pop-up window function
function windowOpener(url, picWidth, picHeight, scrolling) {
	demoWindow=eval("window.open(url,'newWin','menubar=no,resizable=no,scrollbars="+scrolling+",toolbar=no,height="+picHeight+",width="+picWidth+"')");
}

// Page Changer function
function pageChanger(location) {
	window.opener.location= location;
	window.close();
}
		