var on = 0;
var linav = 0;

// INDEX NAVIGATION FADE
function indnav(id, state) {
	var fade = new Fx.Tween('indsub' + id, { duration: 200, property: 'opacity' });
	if(state == 1) {
		linav = 1;
		if(on==0) {
			fade.set({'opacity':0});
			$('indsub' + id).style.display="block";
			fade.start(0,1);
		}
		else {
			$('indsub' + id).style.display="block";	
		}
		on = 1;
	}
	else {
		fade.start(1, 0);
		on = 0;
		linav = 0;
	}
}

// HOME PAGE FEATURE SELECT
function featSelect(what, id, divid, num) {
	var fade1 = new Fx.Tween(what + '-div', { duration: 100, property: 'opacity' });
	var fade2 = new Fx.Tween(what + '-img', { duration: 100, property: 'opacity' });
	fade1.start(.5);
	fade2.start(.5);
	for(var i=1; i <=num; i++) {
		$(what + "-" + i).className = "off";
	}
	$(what + "-" + divid).className = "on";
	var theurl = "_inc/_util/feature.php?id=" + id + "&divid=" + divid;
	new Request.HTML({
		url: theurl,
		method: 'get',
		evalScripts: true,
		update: $(what + "-div"),
		onComplete: function() {
			var fade1 = new Fx.Tween(what + '-div', { duration: 300, property: 'opacity' });
			var fade2 = new Fx.Tween(what + '-img', { duration: 300, property: 'opacity' });
			fade1.start(1);
			fade2.start(1);
		}
	}).send();
}

// TOGGLE "MORE" (CALENDAR)
function toggleMore(id, state) {
	//$('more' + id).innerHTML = (state == "full") ? "" : "";
	var fade1 = new Fx.Tween('desc' +id, { duration: 100, property: 'opacity' });
	fade1.start(.3);
	var theurl = "_inc/_util/entry.php?id=" + id + "&action=togglemore&state=" + state;
	new Request.HTML({
		url: theurl,
		method: 'get',
		evalScripts: true,
		update: $("div" + id),
		onComplete: function() {
			$('desc' +id).set({ 'opacity' : .3});
			var fade2 = new Fx.Tween('desc' + id, { duration: 300, property: 'opacity' });
			fade2.start(1);
		}
	}).send();
}

// ADD YEAR OPTION TO SELECT BOX (CALENDAR)
function addOption(txt, val) {
var s = document.getElementById('year');
var o = new Option(txt,val);
s.options[s.options.length]=o;
return true;
}

// SELECT CALENDAR CATEGORY (INDEX PAGE)
function indCatSel(id, cat, num) {
	var fade1 = new Fx.Tween('allcal', { duration: 100, property: 'opacity' });
	fade1.start(.3);
	for(var i=1; i <=num; i++) {
		$("cat" + i).className = "";
	}
	$("cat" + id).className = "on";
	var theurl = "_inc/_pages/home.php?action=getentries&category=" + cat;
	new Request.HTML({
		url: theurl,
		method: 'get',
		evalScripts: true,
		update: $("allcal"),
		onComplete: function() {
			var fade1 = new Fx.Tween('allcal', { duration: 300, property: 'opacity' });
			fade1.start(1);
		}
	}).send();
}

// GET SEARCH RESULTS (DOCTORS & CLINICS)
function getSearchResults(specialty, doctor, clinic) {
	var fade1 = new Fx.Tween('results', { duration: 100, property: 'opacity' });
	fade1.start(.3);
	var theurl = "_inc/_util/dcs.php?specialty=" + specialty + "&doctor=" + doctor + "&clinic=" + clinic;
	new Request.HTML({
		url: theurl,
		method: 'get',
		evalScripts: true,
		update: $("results"),
		onComplete: function() {
			var fade1 = new Fx.Tween('results', { duration: 300, property: 'opacity' });
			fade1.start(1);
		}
	}).send();
}
