var CurrentDisplayIndex=0;

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);	

}


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-111111111-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_nrcca();
	}

}

function trackGA_nrcca()
{	
    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 hideAllAnswers ()
{
	hideDiv('a1');
	hideDiv('a2');
	hideDiv('a3');
	hideDiv('a4');
	hideDiv('a5');
	hideDiv('a6');
	hideDiv('a7');
	hideDiv('a8');
	
}

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

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

function checkSubmit(e)
{
   if(e && e.keyCode == 13)
   {
      document.forms[0].submit();
   }
}

function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     
     return (key != 13);
}


function hide(id) {
   document.getElementById(id).style.display = 'none';
}

function show(id) {
   document.getElementById(id).style.display = 'block';
}

function displaySpotlightNext(curr,displayMax)
{
	if (CurrentDisplayIndex==0) {CurrentDisplayIndex=curr;}
	currTag = 'ssl' + CurrentDisplayIndex;
	hide(currTag);
	if (CurrentDisplayIndex >= displayMax) 
	{
		CurrentDisplayIndex = 1;
	}
	else
	{
		CurrentDisplayIndex++;
	}
	currTag = 'ssl' + CurrentDisplayIndex;
	show(currTag);
}

function displaySpotlightPrev(curr,displayMax)
{
	if (CurrentDisplayIndex==0) {CurrentDisplayIndex=curr;}
	currTag = 'ssl' + CurrentDisplayIndex;
	hide(currTag);
	if (CurrentDisplayIndex <= 1) 
	{
		CurrentDisplayIndex = displayMax;
	}
	else
	{
		CurrentDisplayIndex--;
	}
	currTag = 'ssl' + CurrentDisplayIndex;
	show(currTag);
}

function displaySpotlight(display,displayMax)
{
	var currTag = "";
	for (var i=1; i<=displayMax; i++)
	{	
    	currTag = 'ssl' + i;
		hide(currTag);
	}
	currTag = 'ssl' + display;
	show(currTag);
}


	
function showCents(val){
	var num = new Number(val);
	return num.toFixed(2);
}

function roundVal(val){
	var dec = 2;
	var result = Math.round(val*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}


function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   	function calcCost()
	{
		with (document.purchase)
		{
			amount.value = showCents(amount.value);	
		}
	}


// use these functions to check if at least 1 check box is clicked 
function checkForm(form) { var itemsChecked = checkArray(form, "experience[]"); alert("You selected " + itemsChecked.length + " items"); if(itemsChecked.length > 0) { alert("The items selected were:\n\t" + itemsChecked); } return false; } 

function checkArray(form, arrayName)
{ var retval = new Array(); for(var i=0; i < form.elements.length; i++) { var el = form.elements[i]; if(el.type == "checkbox" && el.name == arrayName && el.checked) { retval.push(el.value); } } return retval; }  

function selectImage(index)
{ 
		var photos = new Array (
		["istockphoto_10224572-happy-farmer.jpg"],   /* default */
		["istockphoto_10224572-happy-farmer.jpg"],     
		["istockphoto_3105864-grain-field.jpg"],     
		["istockphoto_3369208-cow-in-rural-setting.jpg"],
		["istockphoto_13910750-friendly-farmer.jpg"],
		["istockphoto_6775024-field-of-healthly-corn.jpg"],
		["istockphoto_1625345-assorted-produce.jpg"],
		["istockphoto_664508-agriculture-alfalfa-hay.jpg"],
		["istockphoto_1550659-vegetable-roots-rainbow-of-colors.jpg"],
		["istockphoto_13167239-green-barns-on-dairy-farm.jpg"]
		);		
	document.getElementById("topImage").src="images/"+photos[index];
}


