var preloadFlag = false;
function preloadImages() {
	/*if (document.images) {
		nav_season_over = newImage("/images/nav-season-over.png");
		nav_plan_over = newImage("/images/nav-plan-over.png");
		nav_media_over = newImage("/images/nav-media-over.png");
		nav_wildlife_over = newImage("/images/nav-wildlife-over.png");
		nav_about_over = newImage("/images/nav-about-over.png");
		preloadFlag = true;
	}*/
}


/**** wayfinder functions *****/
    function toggleWayfinder()
    {
      var waySplash = document.getElementById('overlaySplash');
      var wayInner = document.getElementById('overlaySplashinner');
      document.body.appendChild(waySplash);
      document.body.appendChild(wayInner);
      if (waySplash.style.display == "inline")
      {
        waySplash.style.visibility='hidden';
        wayInner.style.visibility='hidden';
        waySplash.style.display='none';
        wayInner.style.display='none';
      }
      else
      {
        waySplash.style.visibility='visible';
        wayInner.style.visibility='visible';
        waySplash.style.display='inline';
        wayInner.style.display='inline';
      }

    }

// Cookie Handling

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


// Overlay Splash

function showSplash(suffix) 
{
    document.getElementById('overlaySplash' + suffix).style.visibility='visible';
    document.getElementById('overlaySplashinner' + suffix).style.visibility='visible';
	if (document.getElementById('Form' + suffix)) {
		document.getElementById('Form' + suffix).style.visibility='visible';
		document.getElementById('Form' + suffix).style.height=null;		
		document.getElementById('Form' + suffix).style.display='block';
	}
	if (document.getElementById('Response' + suffix)) {
		document.getElementById('Response' + suffix).style.visibility='hidden';
		document.getElementById('Response' + suffix).style.height=0;			
		document.getElementById('Response' + suffix).style.display='none';
	}	
    document.getElementById('overlaySplash' + suffix).style.display='block';
    document.getElementById('overlaySplashinner' + suffix).style.display='block';
}

function hideSplash(suffix) 
{
    document.getElementById('overlaySplash' + suffix).style.visibility='hidden';
    document.getElementById('overlaySplashinner' + suffix).style.visibility='hidden';
	if (document.getElementById('Form' + suffix)) {
		document.getElementById('Form' + suffix).style.visibility='hidden';
		document.getElementById('Form' + suffix).style.height=null;			
		document.getElementById('Form' + suffix).style.display='none';
	}
	if (document.getElementById('Response' + suffix)) {
		document.getElementById('Response' + suffix).style.visibility='hidden';
		document.getElementById('Response' + suffix).style.height=0;		
		document.getElementById('Response' + suffix).style.display='none';
	}	
    document.getElementById('overlaySplash' + suffix).style.display='none';
    document.getElementById('overlaySplashinner' + suffix).style.display='none';
}


// Survey Cookie 

var noDaysCookieLasts = 999; // number of days the survey cookie should last

function checkSurveyShow() {
	var page = window.location;
	if (page == 'http://bronxzoo.beaconfire.us/' || page == 'http://bronxzoo-staging.wcs.org/' || page == 'http://bronxzoo-staging.wcs.org' || page == 'http://www.bronxzoo.com/' || page == 'http://www.bronxzoo.org/' || page == 'http://www.bronxzoo.com' || page == 'http://www.bronxzoo.org') {
		var show = readCookie('surveyShow');
		if (show == null) {
			show='y';
			createCookie('surveyShow', show, noDaysCookieLasts);
			showSplash('UserSurvey') ;		
		}
		else if (show == 'n') {
		}
		else {
		  showSplash('UserSurvey') ;		
	   }
	}
}

function setSurveyShow(value) {
	createCookie('surveyShow', value, noDaysCookieLasts);	
}

/*Add any window.onload functions here*/
window.onload = function(e) {
  //preloadImages();	
  //checkSurveyShow(); 
}
    
