
function writeCookie(name, data, noDays){
  var cookieStr = name + "="+ data
  if (writeCookie.arguments.length > 2){
    cookieStr += "; expires=" + getCookieExpireDate(noDays)
    }
  document.cookie = cookieStr
}

function readCookie(cookieName){
   var searchName = cookieName + "="
   var cookies = document.cookie
   var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found
     return ""
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(";", start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
}

function blocking(nr, cookie, vis_state)
{
        if (document.layers)
        {
                current = (document.layers[nr].display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.layers[nr].display = current;
        }
        else if (document.all)
        {
                current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.all[nr].style.display = current;
        }
        else if (document.getElementById)
        {
                display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, display);
                document.getElementById(nr).style.display = display;
        }
}




//// Slideshow section...

// Variables from setup.js: seconds, timerID, exp, pauseIconUrl, playIconUrl

// START/STOP Slideshow
function toggleSlideShow(exp) 
{
	var on = getCookie('slideShowOn');
	if( on!=null )
		dontSlides(exp);
	else
		doSlides(exp);
	
	// For JS keyboard support
	takenAction = false;
}

function setSlideShowStatus(status) 
{
	var url = status ? pauseIconUrl : playIconUrl;
	
	if (document.getElementById)
		document.getElementById("slide_show").src=url;	// IE5+ & Gecko
	else if (document.all)
		document.all["slide_show"].src=url;	// IE4
	else
		document.images["slide_show"].src=url; // Netscape 4
}

//start slideshow
function doSlides(exp) 
{
	setCookie("slideShowOn", "on", exp);
	setSlideShowStatus(true);
	timerID = setTimeout('nextPage()', seconds * 1000);
}

//stop slideshow
function dontSlides(exp) 
{
	deleteCookie("slideShowOn");
	setSlideShowStatus(false);
	clearTimeout(timerID);
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) 
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;

	while (i < clen) 
	{
		var j = i + alen;
		
		if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) 
			break;
	}
	return null;
}

function setCookie(name, value) 
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;

	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

function deleteCookie(name) 
{
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval = getCookie(name);

	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

///// JavaScript Navigation for slide /////

// Variables from setup.js: nextPageUrl, prevPageUrl, indexPageUrl, firstPageUrl, lastPageUrl

function nextPage() 
{
	document.location=nextPageUrl;
	takenAction = false;
}

function prevPage() 
{
	document.location=prevPageUrl;
	takenAction = false;
}

function indexPage() 
{
	document.location=indexPageUrl;
	takenAction = false;
}

function firstPage() 
{
	document.location=firstPageUrl;
	takenAction = false;
}

function lastPage() 
{
	document.location=lastPageUrl;
	takenAction = false;
}

function navSlideShow() 
{
	toggleSlideShow(exp);
}

function navToggleInfo() 
{
	toggleInfo();
}
