window.onload = function () {
/*	
	$('level_2_politismos').style.display = 'none';
	$('level_2_athlitismos').style.display = 'none';
	$('level_2_dhmos').style.display = 'none';
	$('level_2_sightseeing').style.display = 'none';
	$('level_2_info').style.display = 'none';
*/
//	$('left_menu').style.display = 'none';

//	applyWeb2Navigation();

	// Highlight current page
	divs = document.getElementsByTagName('a');

	for (i in divs)
	{
		if (typeof(divs[i]) == 'function') continue;

		if (!divs[i].className || (divs[i].className != 'menu_level_2' && divs[i].className != 'menu_level_1')) continue;

		if (!window.location.href.indexOf(divs[i].href) || divs[i].href == window.location.href + '?s=general')
		{
			divs[i].style.color = '#319330';
			divs[i].style.cursor = 'default';
			
			if (divs[i].className == 'menu_level_2')
			{
				divs[i].style.background = '#fff url(images/green-bullet.png) 3px 0.7em no-repeat';
			}

			divs[i].onclick = function () { return false };

		}
	}


		
}

menuRegistry = {};

function pageFetched(response)
{
	new Effect.Fade('MainDiv', { 
			afterFinish: function () { 
				$('MainDiv').innerHTML = response.responseText; 
				new Effect.Appear('MainDiv', { duration: 0.3 }); 
			} ,
			duration: 0.3
	});

	$('loading_hidder').style.display = 'none';
	$('loading_animation').style.display = 'none';

}

function requestPage()
{
	$('loading_hidder').style.display = 'block';
	$('loading_animation').style.display = 'block';
	
	new Ajax.Request(this.href, {method:'post', postBody:'ajax=true', onSuccess: pageFetched, onFailure: function () { window.location.href = this.href }});

	return false;
}

function applyWeb2Navigation()
{
	divs = document.getElementsByTagName('a');

	for (i in divs)
	{
		if (typeof(divs[i]) == 'function') continue;

		if (!divs[i].className || divs[i].className != 'menu_level_2') continue;

		divs[i].onclick = requestPage;
	}
}

function showDate()
{
	weekdays = new Array("Κυριακή",
		 "Δευτέρα",
		 "Τρίτη",
		 "Τετάρτη",
		 "Πέμπτη",
		 "Παρασκευή",
		 "Σάββατο",
		 "Κυριακή"
	);

	monthNames = new Array(
	"Ιανουαρίου",
	 "Φεβρουαρίου",
	 "Μαρτίου",
	 "Απριλίου",
	 "Μαΐου",
	 "Ιουνίου",
	 "Ιουλίου",
	 "Αυγούστου",
	 "Σεπτεμβρίου",
	 "Οκτωβρίου",
	 "Νοεμβρίου",
	 "Δεκεμβρίου"
	);

	now = new Date;

	var month = now.getMonth();
	var dayM = now.getDate();
	var year = now.getFullYear();

	var dayW = now.getDay();

	$('currentDate').innerHTML = weekdays[dayW] + ', ' + dayM + ' ' + monthNames[month] + ' ' + year;
}

function showHideMenu(id)
{
	for (i in menuRegistry)
	{
		if (menuRegistry[i] == true && $(i) && i != id)
		{
			Effect.BlindUp(i);
			menuRegistry[i] = false;
		}
	}

	element = $(id);
	options = {};
	Element.visible(element) ? hideElement(element, options) : showElement(element, options)

	return false;
}
/*
function showHideMenu(id)
{
	for (i in menuRegistry)
	{
		if (menuRegistry[i] == true && $(i) && i != id)
		{
			Effect.BlindUp(i);
			menuRegistry[i] = false;
//			$(id).style.backgroundColor = '#e3eab8';
		}
	}

	if (menuRegistry[id])
	{
//		$(id).style.display = 'block';
		Effect.BlindUp(id, {afterFinish: function () { $(id).style.display = 'none'; }, queue: 'end'});
		menuRegistry[id] = false;
	}
	else
	{
//		$(id).style.display = 'none';
		Effect.BlindDown(id, {afterFinish: function () { $(id).style.display = 'block'; }, queue: 'end'});
		menuRegistry[id] = true;
		$(id).style.backgroundColor = '#abbc47';
	}
	return false;
}
*/
function showElement(element, options) {
	menuRegistry[element.id] = true;

	if($(element) && !Element.visible(element)) {
		options = options || {}
			new Effect.BlindDown(element, {
				afterFinish: function() {
					Element.undoClipping(element)
					$(element).style.width = "auto"
					$(element).style.height = "auto"
					if(options.afterFinish) options.afterFinish()
				}
			})
	}
}

function hideElement(element, options) {
	menuRegistry[element.id] = false;

	if($(element) && Element.visible(element)) {
		options = options || {}
			new Effect.BlindUp(element, {
				afterFinish: function() {
					Element.undoClipping(element)
					Element.hide(element)
					if(options.afterFinish) options.afterFinish()
					}
				})
			}
}

function checkContactForm()
{
	name = document.getElementById('name');
	email = document.getElementById('email');
	text = document.getElementById('text');

	name.style.backgroundColor = '#FFF';
	email.style.backgroundColor = '#FFF';
	text.style.backgroundColor = '#FFF';

	if (name.value == '')
	{
		name.style.backgroundColor = '#FDD';
		name.focus();
		return false;
	}

	try {
		if (email.value == '' || !email.value.match('^.+@.+[\.].+$'))
		{
			email.style.backgroundColor = '#FDD';
			email.focus();
			return false;
		}
	}
	catch(e)
	{
	}

	if (text.value == '')
	{
		text.style.backgroundColor = '#FDD';
		text.focus();
		return false;
	}

}