function changeTabs(tab) {
	/* define the parent tab and parent body */
	if (tab=='basicSearch'||tab=='advancedSearch'){
		var body = dojo.byId('search-body');
		var tabList = dojo.byId('search-tabs');
		createCookie('searchBarCookie',tab,7);
	} else {
		var tabList = dojo.byId('ep-tabs');
		var body = dojo.byId('ep-body');
		createCookie('tabsCookie', tab, 7);
	}
	
	/* remove current tabs */
	var tabListElement = dojo.dom.getFirstChildElement(tabList);
	while ( tabListElement != null ) {
		dojo.html.removeClass(tabListElement, 'current');
		tabListElement = dojo.dom.getNextSiblingElement(tabListElement);
	}
	dojo.html.addClass(tab + '-tab', 'current');
	
	/* hide all body text */
	var bodyElement = dojo.dom.getFirstChildElement(body);
	while ( bodyElement != null ) {
		dojo.html.hide(bodyElement);
		bodyElement = dojo.dom.getNextSiblingElement(bodyElement);
	}
	dojo.html.show(tab + '-body');
}

function changeRadioButtons(name){
	var body = dojo.byId('ep-body');
	
	/* hide all body text */
	var bodyElement = dojo.dom.getFirstChildElement(body);
	while ( bodyElement != null ) {
		dojo.html.hide(bodyElement);
		bodyElement = dojo.dom.getNextSiblingElement(bodyElement);
	}
	dojo.html.show(name + '-body');
}

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 var 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;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}