var currentTime = new Date();
var year = currentTime.getFullYear();

function getCurrentYear()
{
	document.write(year);	
}

function get_updir (uplevel) {
var updir = '';

  if (uplevel == "0") updir='';
  if (uplevel == "1") updir='../';
  if (uplevel == "2") updir='../../';
  if (uplevel == "3") updir='../../../';
  if (uplevel == "4") updir='../../../';
  return (updir);	

}

// use index for photo number - index 0=default  banner should be 960 x 120 px
// 0=file   1=category(people/cows/crops/land/equip/misc    2=caption
var BannerPhoto = new Array(

["h_berries.jpg",                     "n",           "Berries"],   // 0
["h_berries2.jpg",                     "n",           "Berries"],   // 0
["h_lettuce.jpg",                     "n",           "Lettuce"],
["h_cucumbers.jpg",                    "n",           "Cucumbers"],
["h_CEPrimrose1.jpg",                 "n",           "C E Primrose"],   
["h_kale.jpg",                        "n",           "kale"],   
["h_onion.jpg",                       "n",           "onion"], 
["h_sage.jpg",                       "n",             "sage"], 
["h_strawberries.jpg",               "n",             "strawberries"],
["h_pepper&strawberries.jpg",           "n",             "pepper & strawberries"],
["h_collard.jpg",                     "n",             "collard"], 
["h_lettuceRows.jpg",                 "n",           "LettuceRows"],
["h_blackberries.jpg",                 "n",           "blackberryfield"],
["h_SandhillsStation.jpg",                 "n",           "field"]


);

function get_header_num() {
   var idx = Math.floor(Math.random() * BannerPhoto.length);
   return(idx); 
}
   
   
function get_category (cat) {
	   
   var i=0;
   var idx = get_header_num();
   if (BannerPhoto[idx][1] == cat) {
		return(idx);
   	}

	while (i < BannerPhoto.length) {
	// start with the first photo;
	 	idx++;
		if (idx == BannerPhoto.length) {
			idx=0;
		}
		if (BannerPhoto[idx][1] == cat) {
			return(idx);
		}
		i++;
	}
	   // did not find anything return the original
    return(idx);
}


function put_header_photo(level, photo, cat){
	
var updir = get_updir (level);

    var idx=0;
    // pass in the photo index or random and an option category
	if (photo == "r") {// test for random header   //
			idx = get_header_num();
	}
	
	
	document.write('<h1 style="background:url('+updir+'00Images/placeholder.jpg)">');
	document.write('<img src="'+updir+'00Images/'+BannerPhoto[idx][0]+'" alt="" width="960" height="160" usemap="#map" />');
	document.write('<map name="map" id="map">');
    document.write('<area shape="rect" coords="0,0,222,150" href="' + updir + 'index.php" />');
	document.write('<area shape="rect" coords="222,108,380,149" href="' + updir + 'index.php" />');
    document.write('<area shape="rect" coords="672,0,961,133" href="http://www.cals.ncsu.edu/hort_sci/" /></map></h1>');  

	
}



// utility header for ncsu 
function put_header(level, photo_idx)
{
		//search_form(level);

var updir = get_updir (level);

	document.write(' <div id="header">'  );
document.write('<iframe name="ncsu_branding_bar" id="ncsu_branding_bar" frameborder="0" src="http://www.ncsu.edu/brand/utility-bar/iframe/index.php?color=black&amp;inurl=&amp;center=yes" scrolling="no">  Your browser does not support inline frames or is currently configured  not to display inline frames.<br /> Visit <a href="http://ncsu.edu/">http://www.ncsu.edu</a>.</iframe> ');	

	document.write('<table class="menubar">');
	document.write('<tr style="background:url(' + updir + '00Images/nav.jpg);height:15px"><td colspan="3"></td></tr>');
	document.write('</table>' );
	document.write('<div id="identity">');
	put_header_photo(level, photo_idx);
	document.write(' <div id="awmAnchor-menu" class="menubar"></div>'  );
	document.write(' </div></div>'  );
}

// no counter !!! 
function put_footer(level) {
	if (level==undefined) level='1';
	var updir = get_updir (level);
	document.write('<div id="footer-content" style="clear:both">');
	document.write(' <table class="footerTable">  ');
	document.write(' <tr style="background:url(' + updir + '00Images/nav.jpg);height:15px"><td colspan="5"></td></tr> ');
	document.write('  <tr><td colspan="5" style="height:2px"></td></tr>');
	document.write('  <tr><td width="5px"></td><td align="left">&copy;'+year+' North Carolina State University. All rights reserved.</td><td align="center"><a href="' + updir + 'contacts/index.html">Contacts</a> | <a href="' + updir + 'comments.html">Comments</a> | <a href="' + updir + 'sitemap.html">Sitemap</a></td><td align="right">Site by <a href="http://www.agrenaissance.com">AgRenaissance Software LLC</a></td><td width="5px"></td></tr>');
	
	document.write('  </table>');
	document.write('</div>');
}


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16535067-1']);
  _gaq.push(['_trackPageview']);

function trackGA()
{	
	
    if (document.domain.indexOf("agwebsite") != -1)
	{
		//called from www.agwebsitedev.com 
		//document.write ('domain name is ' + document.domain);
	}
	else
	{
		trackGA_ww();
	}

}

function trackGA_ww()
{	
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}





//function trackGA()
//{	
//	(function() {
 //   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  //  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 //   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 // })();
//}


function put_footer_with_tracking(level){
	put_footer(level);
	//track();
	//track_page();
}

function put_footer_with_tracking1(level){
	put_footer(level);
	//track();
	//track_page();
}



//0=id 1=name 2=email w/o domain 3=phone 4=fax 5=thumbnail photo 6=larger photo
var ContactInfo = new Array(
							
["batts ", "Roger Batts",      "roger_batts",   "919.515.1668", "919.513.7226", "", "" ],  
["name ", "First Last",      "unknown",   "919.###-####", "919.###-####", "", "" ]  

);


/* quick links are only for members, after you login, you can see the quick link panel */
function memberQuickLinks(level)
{
	// check if member, if not return 
	var updir = get_updir (level);
	
    document.write('	<div class="ql"> | ');
    document.write('	  <a href="' + updir + 'blog/wp-login.php">member login</a> | ');
	document.write('	  <a href="' + updir + '#">member tools</a> | ');
	document.write('	  <a href="' + updir + '#">Logout</a> |');
    document.write('	 </div> ');
	
}


function showDiv(div)
{
	document.getElementById(div).style.display = 'inline';
}

function hideDiv(div)
{
	document.getElementById(div).style.display = 'none';
}



