// generator: o-Design

// design:nav_1 #209
Event.observe(document, '1site1:domloaded', function(){
	$('e_209').select('td.ci_209').each(function(td){
		var a = td.down('a')
		td.observe('mouseover', function(e){
			Event.stop(e)
			td.className = 'cia_209'
			a.className = 'cial_209'
		})
		td.observe('mouseout', function(e){
			Event.stop(e)
			td.className = 'ci_209'
			a.className = 'cil_209'
		})
		td.observe('click', function(){
			if(td.clickIsBubble != true) document.location = a.href.match(/^(http|https):/) ? a.href : document.location.baseHref + a.href
		})
		a.observe('click', function(e){
			td.clickIsBubble = true
		})
	})
})

// design:nav_2 #203
var menuOpened_203 = []
var timeoutId_203 = 0
var currentMenu_203 = 0

function menu_203(id, isActive){
	this.id = id
	this.isActive = isActive
}
function open_203(id, isActive){
	if(id == currentMenu_203) return clearTimeout(timeoutId_203)
	
	reset_203()
	if(!isActive) over_203(id)
	menuOpened_203.push(new menu_203(id, isActive))
	currentMenu_203 = id
	
	if(!$('submenu_203_' + id).getElementsByTagName('TD').length) return
	
	$('submenu_203_' + id).show()
	var pos = $('i203_' + id).cumulativeOffset()
	pos.top += $('i203_' + id).getHeight()
	$('submenu_203_' + id).setStyle({left: pos.left+'px', top: pos.top+'px'})
}
function reset_203(){
	var menu
	while(menuOpened_203.length){
		menu = menuOpened_203.pop()
		hide_203(menu.id, menu.isActive, true)
	}
	if(timeoutId_203) clearTimeout(timeoutId_203)
	currentMenu_203 = 0
}
function hide_203(id, isActive, hideNow){
	if(hideNow){
		$('submenu_203_' + id).hide()
		if(timeoutId_203){
			clearTimeout(timeoutId_203)
			timeoutId_203 = 0
		}
		currentMenu_203 = 0
		if(!isActive) out_203(id)
	}
	else timeoutId_203 = window.setTimeout('hide_203('+id+', '+(isActive ? 'true' : 'false')+', true)', 400)
}
function over_203(id, isSub){
	$('i203_' + id).className = isSub ? 'scia_203' : 'cia_203';
	$('il203_' + id).className = isSub ? 'scial_203' : 'cial_203';
}
function out_203(id, isSub){
	$('i203_' + id).className = isSub ? 'sci_203' : 'ci_203';
	$('il203_' + id).className = isSub ? 'scil_203' : 'cil_203';
}

// design:nav_3 #12

function obj_12(id){
	if(document.all && document.all[id]) return document.all[id];
	else if(document.getElementById) return document.getElementById(id);
	else if(document.layers){
		if(document[id]) return document[id];
		if(document.layers[id]) return document.layers[id];
	}
	return null
}

function over_12(id, isSub){
	button = obj_12('i12_' + id);
	text = obj_12('il12_' + id);
	if(!button || !text) return;
	button.className = isSub ? 'scia_12' : 'cia_12';
	text.className = isSub ? 'scial_12' : 'cial_12';
}

function out_12(id, isSub){
	button = obj_12('i12_' + id);
	text = obj_12('il12_' + id);
	if(!button || !text) return;
	button.className = isSub ? 'sci_12' : 'ci_12';
	text.className = isSub ? 'scil_12' : 'cil_12';
}

function go_12(url){
	document.location = url
}

// root:script #223
Event.observe(window, 'load', function(){
new Ajax.Updater($('feed'), defaultCalendarUrl, {method: 'get'});

var calendar = document.getElementsByClassName('calendar')[0];
var cells = $A(calendar.getElementsByClassName('linked-day'));

	cells.each(function(cell){
		cell = $(cell);
		cell.observe('mouseover', function(){
			cell.addClassName('over');
			cell.firstDescendant().setStyle({color: '#FFF'});
		});
		cell.observe('mouseout', function(){
			cell.removeClassName('over');
			cell.firstDescendant().setStyle({color: '#005687'});
		});
		var url = '/plugins/calender.preview/preview.php?'+cell.firstDescendant().href.split(/\?/)[1];

		if(defaultCalendarUrl == url){
			cell.addClassName('active');
		}

		var toggleState = function(evt){
			Event.stop(evt);
			var e = Event.element(evt);

			$A(calendar.getElementsByClassName('active')).each(function(item){
				item.removeClassName('active');
			});
			if(e.tagName == 'A') e = e.parentNode;
			e.addClassName('active');
			new Ajax.Updater($('feed'), url, {method: 'get'});
		}
		cell.firstDescendant().observe('click', toggleState);
		cell.observe('click', toggleState);
	});

});

