// JavaScript Document

function autoverhuur() {
	if($('nogeenauto').style.display == 'none') {
		$('nogeenauto').show();	
	} else {
		$('nogeenauto').hide();	
	}
}

function resize() {
	if(document.body.clientWidth < 960) {
		document.getElementById('wrapper').style.width = '960px';
	}
	else {
		document.getElementById('wrapper').style.width = document.body.clientWidth + 'px';
	}
}

function rollover(id, image) {
	document.getElementById(id).src = 'images/template/tabs/' + image;
}

function display(id, method) {
	if(method == 'show') {
		$(id).style.display = 'block';
	}
	else {
		$(id).style.display = 'none';
	}
}

function switchLang(arg) {
	if(arg == 'show') {
		Effect.Fade('language_show', {duration: 0.2,
					//Effect.BlindUp(id,{duration: 0.5, afterFinish: function(){ action = true; }});
			afterFinish: function() {
				Effect.Appear('language_hide',{delay: 0.0});
			}
		});
	}
	else if(arg == 'hide') {
		Effect.Fade('language_hide', {
			afterFinish: function() {
				Effect.Appear('language_show');
			}
		});
	}
}

function checkNum(id, value, maximaal) {
	if(value.length > maximaal.length) {
		$(id).value = 1;
	}
	else if(value > maximaal) {
		$(id).value = maximaal;
	}
	else if(value < 1) {
		$(id).value = 1;
	}
}

function updateVal(id, maximaal, method) {
	switch(method) {
		case 'up' :
			$(id).value = parseInt($(id).value) + 1;
			checkNum(id, $(id).value, maximaal);
		break;
		case 'down' :
			$(id).value = parseInt($(id).value) - 1;
			checkNum(id, $(id).value, maximaal);
		break;
	}
}

var tmpMonth = '';
var tmpYear	 = '';

var showMethod = 'hide';
function showKalender(method) {
	switch(showMethod) {
		case 'hide' :
			$('kalender2').style.display = 'none';
		break;
		default :
		case 'show' :
			if($('aankomstdatum').value == 'Maak uw keuze') {
				url = 'includes/kalender_request.php?m=' + (tmpMonth != '' ? tmpMonth : '') + '&y=' + (tmpYear != '' ? tmpYear : '');
			}
			else {
				url = 'includes/kalender_request.php?d=' + $('aankomstdatum').value.substr(3,2) + '&m=' + (tmpMonth != '' ? tmpMonth : $('aankomstdatum').value.substr(6,2)) + '&y=' + (tmpYear != '' ? tmpYear : $('aankomstdatum').value.substr(9,4));
			}
			new Ajax.Request(url, { method: 'get',
				onSuccess: function(r) {
					$('kalender2').innerHTML = r.responseText;
				} 
			});
			$('kalender2').style.display = 'block';
		break;
	}
	showMethod = method;
}

function newKalender(month, year) {
	tmpMonth = month;
	tmpYear = year;
	new Ajax.Request('includes/kalender_request.php?m=' + month + '&y=' + year, { method: 'get',
		onSuccess: function(r) {
			$('kalender2').innerHTML = r.responseText;
		} 
	});
}

function setKalender(value) {
	$('aankomstdatum').value = value;
}

var sMail = '';

function mail(id) {

	if($(id).style.display == 'none') {
		if(sMail != '') {
			$(sMail).style.display = 'none';
			$(sMail + '_link').style.textDecoration  = 'underline';	
		}
		$(id).style.display = 'block';
		$(id + '_link').style.textDecoration  = 'none';
		sIFR.replace(engel, {
		selector: 'h1.extra'
		,css: [
		  '.sIFR-root { font-weight: normal; font-size: 28px; color: #002140; margin-left: 5px; }'
		],
		wmode: 'transparent'
		});
		sMail = id
	}
	else {
		$(id).style.display = 'none';
		$(id + '_link').style.textDecoration  = 'underline';
	}

}

// FAQ
var open_slide = "";
var action = true;

function tip(id, arg) {
	if(action == true)
	{
		action = false;
		if($(id).style.display == 'block')
		{
			Effect.BlindUp(id,{duration: 0.5, afterFinish: function(){ action = true; }});
			open_slide = "";
		}
		else
		{
			if(open_slide != id)
			{
				if(open_slide == "")
				{
					Effect.BlindDown(id,{duration: 0.5, afterFinish: function(){ action = true; }});
					open_slide = id;
				}
				else
				{
					Effect.BlindUp(open_slide,{duration: 0.5});
					Effect.BlindDown(id,{delay: 0.5, duration: 0.5, afterFinish: function(){ action = true; }});
					open_slide = id;
				}
			}
			else
			{
				Effect.BlindUp(open_slide,{duration: 0.5, afterFinish: function(){ action = true; }});
				open_slide = "";
			}
		}
	}
}
