$(function () {
 	initNav();
 	
 	rotateBarker();
	});

function hideNav() {
	$('#gnav-wrap ul').fadeOut('slow');
	}
	
function showNav() {
	$('#gnav-wrap ul').fadeIn('slow');
	}	
	
function initNav() {
	if(typeof section != "undefined") {
		gnavOn = "#nav-" + section + " a";
		if(gnavOn != "#nav- a") { // check that section is defined
			pos = $(gnavOn).css('backgroundPosition');
			if(typeof pos != 'undefined') {
				len = pos.length - 3;
				newpos = pos.substring(0,len) + " -96px";
				$(gnavOn).css('backgroundPosition',newpos);
				}
			}
		}
	
	if(typeof subsection != "undefined") {				
		snavOn = "#snav-" + subsection + " a";
		if(snavOn != "#nav- a") { // check that subsection defined
			pos = $(snavOn).css('backgroundPosition');
			if(typeof pos != 'undefined') {
				len = pos.length - 3;
				newpos = pos.substring(0,len) + " -48px";
				$(snavOn).css('backgroundPosition',newpos);
				}
			}
		}	
	}

function rotateBarker() {
	if($('#barker #headlines').length > 0) {
		$('#headlines').innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 10000,
		type: 'random_start'
		});
		}
	}	
	
	
function showIt(sel) {
	$(sel).fadeIn();
	}		
	
function hideIt(sel) {
	$(sel).fadeOut();
	}
	
function popMailList() {
	$('body').prepend('<div id="maillist-pop"></div>');
	$('#maillist-pop').load("/news/maillistform.php").fadeIn();

	}	
	
function popMailListConfirmation(n) {
if(n=='2')
{
	$('body').prepend('<div id="maillist-confirm-pop"></div>');
	$('#maillist-confirm-pop').load("/news/maillistconfirm.php").fadeIn();
}

if(n=='3')
{
	$('body').prepend('<div id="maillist-complete-pop"></div>');
	$('#maillist-complete-pop').load("/news/maillistcomplete.php").fadeIn();
}

	}	
	
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		}
	return "";
	}		