/**
* Controleer op leeg rvg nummer
*/
function checkRVG(rvg)
{
	if (rvg.value.length == 0)
	{
		alert('Vul een RVG nummer in.');
		rvg.focus();
		
		return;
	}
}

/**
* Controleer leeftijd
*/
function checkLeeftijd(leeftijd)
{
	var reg = new RegExp("^[0-9]+$");
	var msg = "Ongeldige leeftijd.";
	
	if (!reg.test(leeftijd.value))
	{
		alert(msg);
		leeftijd.focus();
		
		return;
	}
}

/**
* Controleer postcode
*/
function checkPostcode(el)
{
	var reg = new RegExp("^[0-9]{4}[A-Za-z]{2}$");
	
	if (!reg.test(el.value))
	{
		alert('Ongeldige postcode.');
		el.focus();
		
		return
	}
}

/**
* Get #param from url
*/
function getParam()
{
	var url = window.location.href;
	var pos = url.indexOf('#');
	
	if (pos != -1)
	{
		return param = url.substring(pos + 1, url.length);
	}
	
	return null;
}

/**
*
*/
function getCookieVal(name)
{
	var reg = new RegExp(name + "=([^;]+)");
    var value = reg.exec(document.cookie);
	
    return (value != null) ? unescape(value[1]) : null;
}

/**
* Toon naam: Diskus/Aerosol
*/
function toonNaam()
{
    var type = getCookieVal('type_seretide');
    var naam = document.getElementById('type_naam');
    
    naam.innerHTML = type;
}

/**
* Toon foto van Diskus/Aerosol
*/
function toonFoto()
{
    var type = getCookieVal('type_seretide');
    var img = document.getElementById('type_image');
    
    img.src = "../images/foto/" + type + ".jpg";
}

/**
* Toon inhalatie instructie
*/
function toonAnimatie()
{
    var type = getCookieVal('type_seretide');
    
    
    if (type == null)
    {
        url = "../animatie/keuze.html";
    }
    else
    {
	    url = (type == "Diskus") ? "../animatie/animatie_diskus.html" : "../animatie/animatie_aerosol.html";
    }
	
	popup(url, 490, 320);
}

/**
*
*/
function checkAnimatie()
{
    var type = getCookieVal('type_seretide');
    
    if (type != null)
    {
        document.getElementById('animatie').style.display = 'block';
        
        toonFoto();
        toonNaam();
    }
}

/**
* Toon animatie op de homepagina
*/
function getType()
{
	var type = getCookieVal('type_seretide');
    
    if (type != null)
    {
        document.getElementById('animatie').style.display = 'block';
        
    	var typenr = getCookieVal('typenr_seretide');
    	var naam = document.getElementById('type_naam');
    	var inhaleren = document.getElementById('type_inhaleren');
    	var img = document.getElementById('type_image');
    	var animatie = document.getElementById('type_animatie');
    	
    	naam.innerHTML = type;
    	inhaleren.innerHTML = type;
    	animatie.innerHTML = type;
    	img.src = "../images/achtergrond/" + type + ".jpg";
    }
}

function checkVragenlijst()
{
	var frm = document.getElementById('vragenlijst');
    
	for (var i=0; i<frm.elements.length; ++i)
	{    
		// Type Seretide opslaan in cookie
		if (frm.elements[i].name == "type" && frm.elements[i].checked)
		{
			var pos = frm.elements[i].value.indexOf(' ');
			
			document.cookie = 'type_seretide=' + frm.elements[i].value.substring(0, pos);
			document.cookie = 'typenr_seretide=' + frm.elements[i].value.substring(pos + 1, frm.elements[i].value.length);
		}
	}
}

/**
* Pop-up scherm
*/
function popup(url, width, height)
{
    var w = width;
	var h = height;
	var x = (parseInt(screen.width) - w) / 2;
	var y = (parseInt(screen.height) - h) / 2;
  
    window.open(url, 'animatie', 'width=' + w + ', height=' + h + ', left=' + x + ', top=' + y + ',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
}