var mPrefix = "Bij '";
var mPrefix2 = "Bij '";
var mSuffix = "' heeft u nog geen informatie ingevoerd. Wilt u zo vriendelijk zijn dit alsnog te doen?";
var mSuffix2 = "' is de informatie foutief ingevuld. Wilt u zo vriendelijk zijn dit te corrigeren?";
var anders  = "off"
var anders2 = "off";		
var preFix = 'Wizard__ctl0_';

function OpenWindow(action) {
	var wf = "";	
	wf = wf + "width=375";
	wf = wf + ",height=300";
	wf = wf + ",resizable=no";
	wf = wf + ",scrollbars=no";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	newwindow = window.open(action, 'helper', wf);
	if (window.focus) {newwindow.focus()}
}

function ValidateAndSubmit(step)
{
	if (step == 1) return checkStep1();
	if (step == 2) return checkStep2();
	if (step == 3) return checkStep3();
}

//Check funties voor de verschillende stappen.
function checkStep1()
{
    if (GetElement('v_straat').value.toLowerCase().indexOf("momentje") >= 0) GetElement('v_straat').value = "";
    if (GetElement('r_straat').value.toLowerCase().indexOf("momentje") >= 0) GetElement('r_straat').value = "";
    if (GetElement('p_straat').value.toLowerCase().indexOf("momentje") >= 0) GetElement('p_straat').value = "";
    if (GetElement('p_plaats').value.toLowerCase().indexOf("momentje") >= 0) GetElement('p_plaats').value = "";
    if (GetElement('r_plaats').value.toLowerCase().indexOf("momentje") >= 0) GetElement('r_plaats').value = "";
    if (GetElement('v_plaats').value.toLowerCase().indexOf("momentje") >= 0) GetElement('v_plaats').value = "";    
    
	if (checkBoxChecked(preFix + 'aanhef',"Man/Vrouw", 1) &&
		checkString(GetElement('achternaam'),"Achternaam") &&
		checkString(GetElement('voorletters'),"Voorletters") &&
		checkString(GetElement('organisatie'),"organisatie") &&
		// Prive gegevens
		checkString(GetElement('r_straat'),"Adres") &&
		checkString(GetElement('r_huisnummer'),"Huisnummer") &&
		checkZipCode(GetElement('r_postcode'),"Postcode") &&
		checkString(GetElement('r_plaats'),"Plaats") &&
		// Zakelijke gegevens
		checkString(GetElement('v_straat'), "Vestigingsadres") &&
		checkEmail(GetElement('v_email'),"E-mailadres zakelijk") &&
		checkString(GetElement('v_huisnummer'), "Huisnummer van vestigingsadres") &&
		checkZipCode(GetElement('v_postcode'), "Postcode van vestigingsadres") &&
		checkString(GetElement('v_plaats'),"Plaats van vestigingsadres")&&
		checkPhone(GetElement('v_telefoon'),"Telefoon") &&
		indienPost())
	{
		return true;
	}
	else{return false;}
}

function checkStep2()
{
	if (checkBranche() &&
		checkVakgebied() &&
		checkEzineEmail())
	{
		return true;
	}	
	else{return false;}
}

function checkStep3()
{
		if (checkString(GetElement('rekeningnummer'),"Rekeningnummer")&&
		checkString(GetElement('tnv'),"Ten name van")&&
		checkString(GetElement('tnv_plaats'),"Plaats")&&
		checkBoxChecked(preFix + 'reknummeris', "Rekeningnummer is..", 1))
		{
			return true;
		}
		else{return false;}		
}

function indienPost()
{
	if (!isEmpty(GetElement('p_straat').value))
	{
		return checkString(GetElement('p_straat'), "Postadres") &&
			checkString(GetElement('p_huisnummer'), "Huisnummer van postadres") &&
			checkZipCode(GetElement('p_postcode'), "Postcode van postadres") &&
			checkString(GetElement('p_plaats'), "Plaats van postadres");
	}
	else{return true;}
}

function toonPostAdres(id)
{
	a = document.getElementById(id);
	if(a.style.display == "none")
	{		
		a.style.display = "";
		GetElement('postadres_gevuld').value = "1";
	}
	else
	{
		if(isEmpty(GetElement('p_straat').value))
		{
			a.style.display = "none";			
			GetElement('postadres_gevuld').value = "0";
		}
	}
}

function GetElement(id)
{
	return document.getElementById(preFix + id);
}

function printForm(postback)
{
	a = document.getElementById("printInfoEen");
	b = document.getElementById("printInfoTwee");			
	c = document.getElementById("bulletInfo");
	d = document.getElementById("handtekening");
	e = document.getElementById("navBar");
	f = document.getElementById("header");
										
	a.style.display = "none";
	b.style.display = "none";
	e.style.display = "none";
	f.style.display = "none";
							
	c.style.display = "";
	d.style.display = "";						
	window.print();
	printed = true;
	f.style.display = "";
	if(printed && postback){__doPostBack('Wizard$btnNext','');}
}


// Anders velden tonen
function showFunctieCodeVeld(list, id)
{
	var row = document.getElementById(id);
	if (row != null)
	{
		if(list.options[list.selectedIndex].innerText.toLowerCase() == 'overig'){row.style.display = ""; anders = "on";}
		else{row.style.display = "none";}
	}
	
	if(list.options[list.selectedIndex].innerText.indexOf("*") > 0 )
	{
		var popup = window.open("algemeen_popup.html","popup","left=100,top=100,width=375,height=200,status=no,statusbar=no");
		popup.focus();
	}
}
	
function showBrancheCodeVeld(list, id)
{
	var row = document.getElementById(id);
	if (row != null)
	{
		if(list.options[list.selectedIndex].innerText.toLowerCase() == 'overig'){row.style.display = ""; anders2 = "on";}
		else{row.style.display = "none";}
	}
}	

// Check helpers
function checkVakgebied()
{
	if(anders == "on")
	{
		if (checkString(GetElement('functieCode_anders'),"Functie"))
		{
			return true;
		}
		else{return false;}
	}
	else
	{
		if (checkString(GetElement('vakgebied'),"Vakgebied") &&
			checkString(GetElement('functieCode'),"Functie"))
		{
			return true;
		}
		else{return false;}			
	}
}

function checkBranche()
{
	if(anders2 == "on")
	{
		if (checkString(GetElement('brancheCode_anders'), "Branche"))
		{
			return true;
		}
		else{return false;}
	}
	else
	{
		//alert(GetElement('branchegroep').options[GetElement('branchegroep').selectedIndex].innerText);
		if (checkString(GetElement('branchegroep'), "Branche") &&
			checkString(GetElement('brancheCode'), "Subbranche"))
		{
			return true;
		}
		else{return false;}			
	}
}		

