
function printPage()
{
	if (jQuery("h1").text() == "Opgave gerealiseerde mediations") {
		window.print();
	}
	else {
		var disp_setting="toolbar=yes,location=no,directories=no,menubar=yes,";
		disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25";
		var docprint = window.open("","",disp_setting);
		
		docprint.document.open();
		docprint.document.write('<html><head><title>NMI-Nederlands Mediation Instituut - print pagina</title>');
		docprint.document.write('<link rel="stylesheet" href="http://www.nmi-mediation.nl.test.exed.nl/style/styles-print.css" type="text/css" />');
		docprint.document.write('</head><body onload="self.print();">');
		docprint.document.write(document.getElementById("print_content").innerHTML);		
		docprint.document.write('</body></html>');
		docprint.document.close();
		docprint.focus();
	}
}

function menudrop(waarde)
{

	var x = document.getElementById(waarde).style.display;
	
	if(x == 'none')
	{
		document.getElementById(waarde).style.display='block';
	}
	else
	{
		document.getElementById(waarde).style.display='none';
	}
}


function stuurDoor(stdiv)
{
	$('dest_email').className = '';
	$('dest_name').className = '';
	$('src_email').className = '';
	$('src_name').className = '';

	var url = '/ajax/ajax.php';
	var pars = 'action=stuurDoor&url=' + stdiv + '&' + $('drstFrm').serialize()
	var myAjax = new Ajax.Request(url,
	{
		method: 'post',
		postBody: pars,
		onComplete: function(t)
		{
			var arrResponse = t.responseText.evalJSON();
			if(arrResponse.status == 'false')
			{
				alert(arrResponse.message);
				switch(arrResponse.sec)
				{
					case "empty_fields":
						for(var i=0;i<arrResponse.velden.length;i++)
						{
							$(arrResponse.velden[i]).className = 'errorInput';
						}
						break;

					case "dest_email_wrong":
						$('dest_email').className = 'errorInput';
						$('dest_email').focus();
						break;

					case "src_email_wrong":
						$('src_email').className = 'errorInput';
						$('src_email').focus();
						break;
				}
			}
			else if (arrResponse.status == 'true')
			{
				alert('Uw mail is verzonden');
				new Effect.toggle('stuurdoor','appear',{duration: 1});
				$('dest_email').value = '';
				$('dest_name').value = '';
			}
		}
	} );
	

}

function stuurDoorEN(stdiv)
{
	$('dest_email').className = '';
	$('dest_name').className = '';
	$('src_email').className = '';
	$('src_name').className = '';

	var url = '/ajax/ajax.php';
	var pars = 'action=stuurDoorEN&url=' + stdiv + '&' + $('drstFrm').serialize()
	var myAjax = new Ajax.Request(url,
	{
		method: 'post',
		postBody: pars,
		onComplete: function(t)
		{
			var arrResponse = t.responseText.evalJSON();
			if(arrResponse.status == 'false')
			{
				alert(arrResponse.message);
				switch(arrResponse.sec)
				{
					case "empty_fields":
						for(var i=0;i<arrResponse.velden.length;i++)
						{
							$(arrResponse.velden[i]).className = 'errorInput';
						}
						break;

					case "dest_email_wrong":
						$('dest_email').className = 'errorInput';
						$('dest_email').focus();
						break;

					case "src_email_wrong":
						$('src_email').className = 'errorInput';
						$('src_email').focus();
						break;
				}
			}
			else if (arrResponse.status == 'true')
			{
				alert('Your email has been send');
				new Effect.toggle('stuurdoor','appear',{duration: 1});
				$('dest_email').value = '';
				$('dest_name').value = '';
			}
		}
	} );
}

function getParentByTagName(obj, tagname)
{
	if (obj.tagName == tagname) 
	{
		return obj;
	} 
	else if (obj.parentElement) 
	{
		return getParentByTagName(obj.parentElement, tagname);
	} 
	else 
	{
		return false;
	}
}

function insertRow(obj)
{
	var template = document.getElementById('template');
	var tbody = getParentByTagName(obj, 'TBODY');
	
	var clone = template.cloneNode(true);
	clone.style.display = 'block';
	tbody.appendChild(clone);
}

function show_werkloc(varr)
{
	var tr = getParentByTagName(varr, 'TR');
	if(varr.value=="`mediatorb`.`werklocatie`")
	{
		tr.childNodes[1].style.display = 'none';
		tr.childNodes[2].style.display = 'inline';
	}
	else {
		tr.childNodes[1].style.display = 'inline';
		tr.childNodes[2].style.display = 'none';
	}
}

function show_test(ar)
{
  if(ar == 1)
  {
    document.getElementById('test').style.display='inline';
    document.getElementById('special').style.display='none';
    document.getElementById('beroep').style.display='none';
    document.getElementById('taal').style.display='none';
    document.getElementById('provincie').style.display='none';
    document.getElementById('template').style.display='none';
  }
  else 
  {
    document.getElementById('test').style.display='none';
    document.getElementById('special').style.display='inline';
    document.getElementById('beroep').style.display='inline';
    document.getElementById('taal').style.display='inline';
    document.getElementById('provincie').style.display='inline';
    document.getElementById('template').style.display='block';
  }
}

function set_alph()
{
    if(window.location.href.indexOf('&alph=1') < 0)
    {
		var a = window.location.href;
    }
    else 
    {
		var a = str_replace('&alph=1','',window.location.href);
    }
    document.all.alph.href = a+"&alph=1";
    document.all.alphb.href = a;
  }
  
  function str_replace(from, to, str) 
  {
    var i = str.indexOf(from);
    if (i == -1) 
    {
    	return str;
    } 
    else 
    {
		return str.substring(0, i) + to + str_replace(from, to, str.substring(i + from.length, str.length));
    }
}