
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		document.getElementById(obj+'_img').src = "/images/treeview_plus.png";
		
	}
	else {
		el.style.display = '';
		document.getElementById(obj+'_img').src = "/images/treeview_minus.png";
	}
}

function check_address()
{


	if(document.address.MunicipalityId && document.address.MunicipalityId.options[document.address.MunicipalityId.selectedIndex].value=='')
	{
		document.address.MunicipalityId.style.backgroundColor='#d2e541';
		document.address.MunicipalityId.focus();
	}

	else if(document.address.CompanyMunicipalityId && document.address.CompanyMunicipalityId.options[document.address.CompanyMunicipalityId.selectedIndex].value=='')
	{
		document.address.CompanyMunicipalityId.style.backgroundColor='#d2e541';
		document.address.CompanyMunicipalityId.focus();
	}
	
	else if (document.address.zipcode && document.address.zipcode.value=='')
	{
			document.address.zipcode.style.backgroundColor='#d2e541';
			document.address.zipcode.focus();
	}	
	
	else if (document.address.huisnr && document.address.huisnr.value=='')
	{
			document.address.huisnr.style.backgroundColor='#d2e541';
			document.address.huisnr.focus();
	}	
	
	else if (document.address.straatwoonplaats && document.address.straatwoonplaats.value=='')
	{
			document.address.straatwoonplaats.style.backgroundColor='#d2e541';
			document.address.straatwoonplaats.focus();
	}

	else if (trim(document.address.elements['addressnameNL'].value) == '' && trim(document.address.elements['addressnameFR'].value) == '')
	{
		document.address.elements['addressnameNL'].style.backgroundColor='#d2e541';
		document.address.elements['addressnameNL'].focus();		
		
	}	
	else
	{
		
		if (document.address.elements['addressnameFR'].value=='') 
		{
			document.address.elements['addressnameFR'].value = document.address.elements['addressnameNL'].value;
		}	
		if (document.address.elements['addressemailNL'].value=='') 
		{
			document.address.elements['addressemailNL'].value = document.address.elements['addressemailFR'].value;
		}	
		if (document.address.elements['addressemailFR'].value=='') 
		{
			document.address.elements['addressemailFR'].value = document.address.elements['addressemailNL'].value;
		}	
		if (document.address.elements['addressphoneNL'].value=='') 
		{
			document.address.elements['addressphoneNL'].value = document.address.elements['addressphoneFR'].value;
		}	
		if (document.address.elements['addressphoneFR'].value=='') 
		{
			document.address.elements['addressphoneFR'].value = document.address.elements['addressphoneNL'].value;
		}	
		if (document.address.elements['addressfaxNL'].value=='') 
		{
			document.address.elements['addressfaxNL'].value = document.address.elements['addressfaxFR'].value;
		}	
		if (document.address.elements['addressfaxFR'].value=='') 
		{
			document.address.elements['addressfaxFR'].value = document.address.elements['addressfaxNL'].value;
		}	
		if (document.address.elements['addresswebsiteNL'].value=='') 
		{
			document.address.elements['addresswebsiteNL'].value = document.address.elements['addresswebsiteFR'].value;
		}	
		if (document.address.elements['addresswebsiteFR'].value=='') 
		{
			document.address.elements['addresswebsiteFR'].value = document.address.elements['addresswebsiteNL'].value;
		}			
		
		document.address.submit();
	}
}

function check_profile_upgrade()
{

	if(document.profile.ModusId.selectedIndex==0)
	{
		document.profile.ModusId.style.backgroundColor='#d2e541';
		document.profile.ModusId.focus();
	}
	else
	{
		document.profile.submit();
	}	

}

function check_profile(conditions)
{
	if(document.profile.Email.value=='')
	{
		document.profile.Email.style.backgroundColor='#d2e541';
		document.profile.Email.focus();
	}
	else if(document.profile.Email2.value!=document.profile.Email.value)
	{
		document.profile.Email2.style.backgroundColor='#d2e541';
		document.profile.Email2.focus();
	}
	else if(document.profile.Password.value=='')
	{
		document.profile.Password.style.backgroundColor='#d2e541';
		document.profile.Password.focus();
	}
	else if(document.profile.Password.value!=document.profile.Password2.value)
	{
		document.profile.Password.style.backgroundColor='#d2e541';
		document.profile.Password2.style.backgroundColor='#d2e541';
		document.profile.Password2.focus();
	}
	else if(document.profile.MunicipalityId && document.profile.MunicipalityId.options[document.profile.MunicipalityId.selectedIndex].value=='')
	{
		document.profile.MunicipalityId.style.backgroundColor='#d2e541';
		document.profile.MunicipalityId.focus();
	}
	
	else if (document.profile.CompanyMpcId && document.profile.CompanyMpcId.value=='')
	{
			document.profile.CompanyMpcId.style.backgroundColor='#d2e541';
			document.profile.CompanyMpcId.focus();
	}	
	
	else if (document.profile.MpcId && document.profile.MpcId.value=='')
	{
			document.profile.MpcId.style.backgroundColor='#d2e541';
			document.profile.MpcId.focus();
	}		
	
	else if (document.profile.zipcode && document.profile.zipcode.value=='')
	{
			document.profile.zipcode.style.backgroundColor='#d2e541';
			document.profile.zipcode.focus();
	}	

	else if (document.profile.huisnr && document.profile.huisnr.value=='')
	{
			document.profile.huisnr.style.backgroundColor='#d2e541';
			document.profile.huisnr.focus();
	}
	
	else if (document.profile.straatwoonplaats && document.profile.straatwoonplaats.value=='')
	{
			document.profile.straatwoonplaats.style.backgroundColor='#d2e541';
			document.profile.straatwoonplaats.focus();
	}

	else if (document.profile.CompanyCompanytype2 && document.profile.CompanyCompanytype2.selectedIndex == 0 )
	{
			document.profile.CompanyCompanytype2.style.backgroundColor='#d2e541';
			document.profile.CompanyCompanytype2.focus();
	}		
	
	else if (document.profile.companyzipcode && document.profile.companyzipcode.value=='' && document.getElementById('companympccontainer').style.display != 'none')
	{
			document.profile.companyzipcode.style.backgroundColor='#d2e541';
			document.profile.companyzipcode.focus();
	}	

	else if (document.profile.companyhuisnr && document.profile.companyhuisnr.value=='' && document.getElementById('companympccontainer').style.display != 'none')
	{
			document.profile.companyhuisnr.style.backgroundColor='#d2e541';
			document.profile.companyhuisnr.focus();
	}
	
	else if (document.profile.Companystraatwoonplaats && document.profile.Companystraatwoonplaats.value=='' && document.getElementById('companympccontainer').style.display != 'none')
	{
			document.profile.Companystraatwoonplaats.style.backgroundColor='#d2e541';
			document.profile.Companystraatwoonplaats.focus();
	}	
	else if ( (document.profile.CompanyWebsite) && (document.profile.CompanyWebsite.value=='' || !isUrl(document.profile.CompanyWebsite.value)) && (document.getElementById('companympccontainer').style.display == 'none'))
		{
			document.profile.CompanyWebsite.style.backgroundColor='#d2e541';
			document.profile.CompanyWebsite.focus();
		}

		
	
	
	
	// else if(document.profile.Birthday_Day.selectedIndex==0)
	// {
	//	document.profile.Birthday_Day.style.backgroundColor='#d2e541';
	//	document.profile.Birthday_Day.focus();
	// }
	// else if(document.profile.Birthday_Month.selectedIndex==0)
	// {
	//	document.profile.Birthday_Month.style.backgroundColor='#d2e541';
	//	document.profile.Birthday_Month.focus();
	// }
	// else if(document.profile.Birthday_Year.selectedIndex==0)
	// {
	//	document.profile.Birthday_Year.style.backgroundColor='#d2e541';
	//	document.profile.Birthday_Year.focus();
	// }
	else if(document.profile.CompanyMunicipalityId && document.profile.CompanyMunicipalityId.options[document.profile.CompanyMunicipalityId.selectedIndex].value=='' && document.getElementById('companympccontainer').style.display != 'none')
	{
		document.profile.CompanyMunicipalityId.style.backgroundColor='#d2e541';
		document.profile.CompanyMunicipalityId.focus();
	}
	// else if(document.profile.CompanyVAT.value=='')
	// {
	//	document.profile.CompanyVAT.style.backgroundColor='#d2e541';
	//	document.profile.CompanyVAT.focus();
	// }
	else if((conditions==1)&&(document.profile.elements['conditions'].checked==false))
	{
		document.profile.elements['conditions'].style.backgroundColor='#d2e541';
	}
	else
	{
		document.profile.submit();
	}
}

function check_contact()
{
	if(document.contact.voornaam.value=='')
	{
		document.contact.voornaam.style.backgroundColor='#d2e541';
		document.contact.voornaam.focus();
	}
	else if(document.contact.familienaam.value=='')
	{
		document.contact.familienaam.style.backgroundColor='#d2e541';
		document.contact.familienaam.focus();
	}
	else if(document.contact.telefoon.value=='')
	{
		document.contact.telefoon.style.backgroundColor='#d2e541';
		document.contact.telefoon.focus();
	}
	else if(document.contact.email.value=='')
	{
		document.contact.email.style.backgroundColor='#d2e541';
		document.contact.email.focus();
	}
	else if(document.contact.typevraag.selectedIndex==0)
	{
		document.contact.typevraag.style.backgroundColor='#d2e541';
		document.contact.typevraag.focus();
	}
	else if(document.contact.vraag.value=='')
	{
		document.contact.vraag.style.backgroundColor='#d2e541';
		document.contact.vraag.focus();
	}
	else
	{
		document.contact.submit();
	}
}

function check_user_profile(conditions,hostid)
{

	if (!hostid)
		hostid = 0;
		
	if (hostid != 15 && hostid != 16 && hostid != 18 && hostid != 19)
	{
		if(document.profile.ModusId.selectedIndex==0)
		{
			document.profile.ModusId.style.backgroundColor='#d2e541';
			document.profile.ModusId.focus();
			return false;
		}
		else if(document.profile.Email.value=='')
		{
			document.profile.Email.style.backgroundColor='#d2e541';
			document.profile.Email.focus();
			return false;
		}
		else if(document.profile.Email2.value!=document.profile.Email.value)
		{
			document.profile.Email2.style.backgroundColor='#d2e541';
			document.profile.Email2.focus();
			return false;
		}


	}
	if(document.profile.Name.value=='')
	{
		document.profile.Name.style.backgroundColor='#d2e541';
		document.profile.Name.focus();
	}
	else if(document.profile.Firstname.value=='')
	{
		document.profile.Firstname.style.backgroundColor='#d2e541';
		document.profile.Firstname.focus();
	}
	else if(document.profile.Password.value=='')
	{
		document.profile.Password.style.backgroundColor='#d2e541';
		document.profile.Password.focus();
		return false;
	}
	else if(document.profile.Password.value!=document.profile.Password2.value)
	{
		document.profile.Password.style.backgroundColor='#d2e541';
		document.profile.Password2.style.backgroundColor='#d2e541';
		document.profile.Password2.focus();
		return false;
	}
	
	else if (document.profile.Address && document.profile.Address.value=='')
	{	

		document.profile.Address.style.backgroundColor='#d2e541';
		document.profile.Address.focus();

	}
	else if (document.profile.MunicipalityId && document.profile.MunicipalityId.options[document.profile.MunicipalityId.selectedIndex].value=='')
	{

			document.profile.MunicipalityId.style.backgroundColor='#d2e541';
			document.profile.MunicipalityId.focus();
	}
	
	else if (document.profile.MpcId && document.profile.MpcId.value=='')
	{

			document.profile.MpcId.style.backgroundColor='#d2e541';
			document.profile.MpcId.focus();
	}	
	
	else if (document.profile.zipcode && document.profile.zipcode.value=='')
	{

			document.profile.zipcode.style.backgroundColor='#d2e541';
			document.profile.zipcode.focus();

	}	

	else if (document.profile.huisnr && document.profile.huisnr.value=='')
	{

			document.profile.huisnr.style.backgroundColor='#d2e541';
			document.profile.huisnr.focus();

	}
	
	else if (document.profile.straatwoonplaats && document.profile.straatwoonplaats.value=='')
	{

			document.profile.straatwoonplaats.style.backgroundColor='#d2e541';
			document.profile.straatwoonplaats.focus();

	}	
	/*
	else if(document.profile.Birthday_Day.selectedIndex==0)
	{
		document.profile.Birthday_Day.style.backgroundColor='#d2e541';
		document.profile.Birthday_Day.focus();
	}
	else if(document.profile.Birthday_Month.selectedIndex==0)
	{
		document.profile.Birthday_Month.style.backgroundColor='#d2e541';
		document.profile.Birthday_Month.focus();
	}
	else if(document.profile.Birthday_Year.selectedIndex==0)
	{
		document.profile.Birthday_Year.style.backgroundColor='#d2e541';
		document.profile.Birthday_Year.focus();
	}
	*/
	else if((conditions==1)&&(document.profile.elements['conditions'].checked==false))
	{
		document.profile.elements['conditions'].style.backgroundColor='#d2e541';
	}
	else
	{
		document.profile.submit();
	}
}

function check_discount_step1()
{
	//if(document.discount.elements['Discount'].value=='')
	//{
	//	document.discount.elements['Discount'].style.backgroundColor='#d2e541';
	//	document.discount.elements['Discount'].focus();
	//}
	if((document.discount.elements['DiscountType'].selectedIndex==0)&&(document.discount.elements['Discount'].value>100))
	{
		document.discount.elements['Discount'].style.backgroundColor='#d2e541';
		document.discount.elements['Discount'].focus();
	}
	else if(document.discount.elements['Startdate_Day'].selectedIndex==0)
	{
		document.discount.elements['Startdate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Startdate_Day'].focus();
	}
	else if(document.discount.elements['Startdate_Month'].selectedIndex==0)
	{
		document.discount.elements['Startdate_Month'].style.backgroundColor='#d2e541';
		document.discount.elements['Startdate_Month'].Birthday_Month.focus();
	}
	else if(document.discount.elements['Startdate_Year'].selectedIndex==0)
	{
		document.discount.elements['Startdate_Year'].style.backgroundColor='#d2e541';
		document.discount.elements['Startdate_Year'].focus();
	}
	else if(isDate('discount', 'Startdate_Day', 'Startdate_Month', 'Startdate_Year')==false)
	{
		document.discount.elements['Startdate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Startdate_Day'].focus();
	}
	else if(document.discount.elements['Enddate_Day'].selectedIndex==0)
	{
		document.discount.elements['Enddate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Enddate_Day'].focus();
	}
	else if(document.discount.elements['Enddate_Month'].selectedIndex==0)
	{
		document.discount.elements['Enddate_Month'].style.backgroundColor='#d2e541';
		document.discount.elements['Enddate_Month'].Birthday_Month.focus();
	}
	else if(document.discount.elements['Enddate_Year'].selectedIndex==0)
	{
		document.discount.elements['Enddate_Year'].style.backgroundColor='#d2e541';
		document.discount.elements['Enddate_Year'].focus();
	}
	else if(isDate('discount', 'Enddate_Day', 'Enddate_Month', 'Enddate_Year')==false)
	{
		document.discount.elements['Enddate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Enddate_Day'].focus();
	}
	else if(document.discount.elements['Validitydate_Day'].selectedIndex==0)
	{
		document.discount.elements['Validitydate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Validitydate_Day'].focus();
	}
	else if(document.discount.elements['Validitydate_Month'].selectedIndex==0)
	{
		document.discount.elements['Validitydate_Month'].style.backgroundColor='#d2e541';
		document.discount.elements['Validitydate_Month'].Birthday_Month.focus();
	}
	else if(document.discount.elements['Validitydate_Year'].selectedIndex==0)
	{
		document.discount.elements['Validitydate_Year'].style.backgroundColor='#d2e541';
		document.discount.elements['Validitydate_Year'].focus();
	}
	else if(isDate('discount', 'Validitydate_Day', 'Validitydate_Month', 'Validitydate_Year')==false)
	{
		document.discount.elements['Validitydate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Validitydate_Day'].focus();
	}
	else if(van<nu)
	{
		document.discount.elements['Startdate_Day'].style.backgroundColor='#d2e541';
		document.discount.elements['Startdate_Day'].focus();
	}
	
	else if((document.discount.elements['AdvantageNL'].value=='')&&(document.discount.elements['AdvantageFR'].value==''))
	{
		switchtab(1);
		document.discount.elements['AdvantageNL'].style.backgroundColor='#d2e541';
		document.discount.elements['AdvantageNL'].focus();
	}
	else if (document.discount.DiscountWebshopHideCode && document.discount.elements['DiscountWebshopHideCode'].checked == false && trim(document.discount.elements['DiscountWebshopDiscountCodeNL'].value) == '')
	{
		
		document.discount.elements['DiscountWebshopDiscountCodeNL'].style.backgroundColor='#d2e541';
		document.discount.elements['DiscountWebshopDiscountCodeNL'].focus();		
		
	}
	else if (document.discount.DiscountWebshopDiscountLinkNL && (trim(document.discount.elements['DiscountWebshopDiscountLinkNL'].value) == '' || !isUrl(trim(document.discount.elements['DiscountWebshopDiscountLinkNL'].value))))
	{
		
		document.discount.elements['DiscountWebshopDiscountLinkNL'].style.backgroundColor='#d2e541';
		document.discount.elements['DiscountWebshopDiscountLinkNL'].focus();		
		
	}

	else
	{
		var now = new Date();
		var nu = new Date(now.getYear(), now.getMonth(), now.getDate());
		var van = new Date(document.discount.elements['Startdate_Year'].options[document.discount.elements['Startdate_Year'].selectedIndex].value, document.discount.elements['Startdate_Month'].selectedIndex-1, document.discount.elements['Startdate_Day'].selectedIndex);
		var tot = new Date(document.discount.elements['Enddate_Year'].options[document.discount.elements['Enddate_Year'].selectedIndex].value, document.discount.elements['Enddate_Month'].selectedIndex-1, document.discount.elements['Enddate_Day'].selectedIndex);
		var geldig = new Date(document.discount.elements['Validitydate_Year'].options[document.discount.elements['Validitydate_Year'].selectedIndex].value, document.discount.elements['Validitydate_Month'].selectedIndex-1, document.discount.elements['Validitydate_Day'].selectedIndex);

		// if(van<nu)
		// {
		//	document.discount.elements['Startdate_Day'].style.backgroundColor='#d2e541';
		//	document.discount.elements['Startdate_Day'].focus();
		// }
		if(tot<=van)
		{
			document.discount.elements['Enddate_Day'].style.backgroundColor='#d2e541';
			document.discount.elements['Enddate_Day'].focus();
		}
		else if(geldig<tot)
		{
			document.discount.elements['Validitydate_Day'].style.backgroundColor='#d2e541';
			document.discount.elements['Validitydate_Day'].focus();
		}
		else
		{		
			if(document.discount.elements['AdvantageNL'].value=='') {
				document.discount.elements['AdvantageNL'].value = document.discount.elements['AdvantageFR'].value;
			}
			if(document.discount.elements['AdvantageFR'].value=='') {
				document.discount.elements['AdvantageFR'].value = document.discount.elements['AdvantageNL'].value;
			}
			if(document.discount.elements['ModalitiesNL'].value=='') {
				document.discount.elements['ModalitiesNL'].value = document.discount.elements['ModalitiesFR'].value;
			}
			if(document.discount.elements['ModalitiesFR'].value=='') {
				document.discount.elements['ModalitiesFR'].value = document.discount.elements['ModalitiesNL'].value;
			}
			
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['DiscountWebshopDiscountCodeNL'].value=='') {
				document.discount.elements['DiscountWebshopDiscountCodeNL'].value = document.discount.elements['DiscountWebshopDiscountCodeFR'].value;
			}
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['DiscountWebshopDiscountCodeFR'].value=='') {
				document.discount.elements['DiscountWebshopDiscountCodeFR'].value = document.discount.elements['DiscountWebshopDiscountCodeNL'].value;
			}		
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['DiscountWebshopDiscountLinkNL'].value=='') {
				document.discount.elements['DiscountWebshopDiscountLinkNL'].value = document.discount.elements['DiscountWebshopDiscountLinkFR'].value;
			}
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['DiscountWebshopDiscountLinkFR'].value=='') {
				document.discount.elements['DiscountWebshopDiscountLinkFR'].value = document.discount.elements['DiscountWebshopDiscountLinkNL'].value;
			}		
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['WebshopDiscountDescriptionNL'].value=='') {
				document.discount.elements['WebshopDiscountDescriptionNL'].value = document.discount.elements['WebshopDiscountDescriptionFR'].value;
			}
			if(document.discount.DiscountWebshopHideCode && document.discount.elements['WebshopDiscountDescriptionFR'].value=='') {
				document.discount.elements['WebshopDiscountDescriptionFR'].value = document.discount.elements['WebshopDiscountDescriptionNL'].value;
			}			
			document.discount.submit();
		}
	}

}

function check_discount_step2(addresses)
{
	addresses_array = addresses.split(',');
	address_selected = 0;

	if(addresses_array.length!=0)
	{
		for(i=0;i<addresses_array.length;i++)
		{
			if(document.discount.elements['address' + addresses_array[i] + ''].checked==true)
			{
				address_selected = 1;
			}
		}
	}

	if(address_selected==0)
	{
		if(addresses_array.length!=0)
		{
			for(i=0;i<addresses_array.length;i++)
			{
				document.discount.elements['address' + addresses_array[i] + ''].style.backgroundColor='#d2e541';
			}
		}
		else
		{
			document.discount.submit();
		}
	}
	else
	{
		document.discount.submit();
	}
}

function check_discount_step3()
{
	// if((document.discount.elements['LogoNL'].value=='')&&(document.discount.elements['LogoFR'].value==''))
	// {
	//	switchtab(1);
	//	document.discount.elements['LogoNL'].style.backgroundColor='#d2e541';
	//	document.discount.elements['LogoNL'].focus();
	// }
	// else
	// {
		if(document.discount.elements['LogoNL'].value=='')
		{
			document.discount.elements['LogoNL'].value = document.discount.elements['LogoFR'].value;
		}
		if(document.discount.elements['LogoFR'].value=='')
		{
			document.discount.elements['LogoFR'].value = document.discount.elements['LogoNL'].value;
		}
		
		if(document.discount.elements['GlobalpictureNL'].value=='')
		{
			document.discount.elements['GlobalpictureNL'].value = document.discount.elements['GlobalpictureFR'].value;
		}
		if(document.discount.elements['GlobalpictureFR'].value=='')
		{
			document.discount.elements['GlobalpictureFR'].value = document.discount.elements['GlobalpictureNL'].value;
		}			
		
		document.discount.submit();
	// }
}

function check_discount_step4()
{
	document.discount.submit();
}

function get_companies()
{
	// if (window.ActiveXObject)
	// {
	//	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	//	xmlDoc.async = 'false';
	//	xmlDoc.onreadystatechange = verify;
	//	xmlDoc.load('xml/companies.asp?VAT='+document.profile.CompanyVAT.value);
	//	fill_company();
	// }
	// else if (document.implementation && document.implementation.createDocument)
	// {
	//	xmlDoc = document.implementation.createDocument("","",null);
	//	xmlDoc.load('xml/companies.asp?VAT='+document.profile.CompanyVAT.value);
	//	xmlDoc.onload = function(){fill_company()}
	// }
}

function fill_company()
{
	var companies = xmlDoc.documentElement.getElementsByTagName('company');

	if(companies.length==1)
	{
		for(j=0;j<companies[0].childNodes.length;j++)
        {                 
            switch(companies[0].childNodes[j].nodeName)
            {
                case 'id':
                    companyid = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyId.value =  companyid;
                    break;
				case 'companytype':
                    companycompanytype = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyCompanytype.value =  companycompanytype;
                    break;
				case 'name':
                    companyname = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyName.value =  companyname;
                    break;
				case 'email':
                    companyemail = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyEmail.value =  companyemail;
                    break;
				case 'address':
                    companyaddress = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyAddress.value =  companyaddress;
                    break;
				case 'municipalityid':
                    companymunicipalityid = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyMunicipalityId.value =  companymunicipalityid;
                    break;
				case 'phone':
                    companyphone = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyPhone.value =  companyphone;
                    break;
				case 'fax':
                    companyfax = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyFax.value =  companyfax;
                    break;
				case 'website':
                    companywebsite = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyWebsite.value =  companywebsite;
                    break;
				case 'vat':
                    companyvat = GetNodeValue(companies[0].childNodes[j].firstChild);
					document.profile.CompanyVAT.value =  companyvat;
                    break;
            }
        }
	}
}

function verify()
{
  if (xmlDoc.readyState != 4)
  {
      return false;
  }
}

function GetNodeValue(node)
{
    if(node != null)
        return node.nodeValue;
    else 
        return '';
}

function getkey(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
  			return e.which;
	else
 		 	return null;
}

function goodchars(e,goods)
{
	var key, keychar;
	key = getkey(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
		return false;
}

function checkMail(formname,elementname,taal)
{
	var x = document.forms[''+formname+''].elements[''+elementname+''].value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	{
		if(x!='')
		{
			email = document.forms[''+formname+''].elements[''+elementname+''].value;
			document.forms[''+formname+''].elements[''+elementname+''].value = '';
			if(taal=='nl') { alert('\'' + email + '\' is geen geldig e-mailadres.'); }
			else { alert('\'' + email + '\' is not valid.'); }
		}
	}
}

function uploadit(uploadfield,uploadform)
{
	venster=open("upload-form.asp?uploadfield="+uploadfield+"&uploadform="+uploadform,"venster","height=160,width=300,scrollbars=no");
	venster.focus();
}

function switchtab(tab) { 
	
	if (tab == 1) { 
		state1 = 'block'; class1 = 'tab_active';
		state2 = 'none'; class2 = 'tab';
	} 
	else if (tab == 2) { 
		state1 = 'none'; class1 = 'tab';
		state2 = 'block'; class2 = 'tab_active';
	} 


	// divs showen / hiden
	if (document.all) 
	{ 
		eval( "document.all.innercontainer1.style.display = state1"); 
		eval( "document.all.innercontainer2.style.display = state2"); 
	} 
	if (document.getElementById &&!document.all) 
	{ 
		hza = document.getElementById('innercontainer1'); hza.style.display = state1; 
		hza = document.getElementById('innercontainer2'); hza.style.display = state2; 
	}
	
	// class van de tabs wijzigen
	var currTabElem = document.getElementById('tab1'); 
	currTabElem.setAttribute("class", class1); 
	currTabElem.setAttribute("className", class1); 
	var currTabElem = document.getElementById('tab2'); 
	currTabElem.setAttribute("class", class2); 
	currTabElem.setAttribute("className", class2); 
}

function switchtabnew(tab,containername) { 
	
	if (tab == 1) { 
		state1 = 'block'; class1 = 'tab_active';
		state2 = 'none'; class2 = 'tab';
	} 
	else if (tab == 2) { 
		state1 = 'none'; class1 = 'tab';
		state2 = 'block'; class2 = 'tab_active';
	} 


	// divs showen / hiden
	if (document.all) 
	{ 
		eval( "document.all."+containername+"1.style.display = state1"); 
		eval( "document.all."+containername+"2.style.display = state2"); 
	} 
	if (document.getElementById &&!document.all) 
	{ 
		hza = document.getElementById(containername+'1'); hza.style.display = state1; 
		hza = document.getElementById(containername+'2'); hza.style.display = state2; 
	}
	
	// class van de tabs wijzigen
	var currTabElem = document.getElementById('tab'+containername+'1'); 
	currTabElem.setAttribute("class", class1); 
	currTabElem.setAttribute("className", class1); 
	var currTabElem = document.getElementById('tab'+containername+'2'); 
	currTabElem.setAttribute("class", class2); 
	currTabElem.setAttribute("className", class2); 
}

function tellafriend()
{
	tellafriend_layer = '<div id="tellafriend" style="position:absolute;top:0px;left:0px;width:100%;height:100%;"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center" valign="middle"><div style="text-align:center;width:400px;height:200px;background-color:#FFFFFF;border-top:Solid 1px #c9c9c9;border-left:Solid 1px #c9c9c9;border-bottom:Solid 1px Gray;border-right:Solid 1px Gray;">'
	tellafriend_layer = tellafriend_layer + '<form name="tellafriendform" method="post"><table border="0" cellpadding="0" cellspacing="0" style="margin:20px;">';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" valign="top" style="padding-right:20px;" rowspan="7"><img src="/images/tellafriend.jpg" width="30" height="30"></td><td align="left" colspan="2"><strong>Afzender</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Uw naam</td><td align="left"><input type="text" name="FromName" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Uw e-mail</td><td align="left"><input type="text" name="FromEmail" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" colspan="2" style="padding-top:10px;"><strong>Ontvanger</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Naam</td><td align="left"><input type="text" name="ToName" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">E-mail</td><td align="left"><input type="text" name="ToEmail" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td></td><td align="left" style="padding-top:10px;"><input type="button" onClick="document.tellafriendform.action=document.location;document.tellafriendform.submit();" value="verzenden" class="button"> <input type="button" class="button" value="sluiten" onClick="setmainfocus();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '</table></form></div></td></tr></table></div>';
	document.getElementById('main').style.filter = 'alpha(opacity=40)';
	document.getElementById('main').style.opacity = '.40';
	document.getElementById('footer').style.filter = 'alpha(opacity=40)';
	document.getElementById('footer').style.opacity = '.40';
	document.body.innerHTML += tellafriend_layer;
	//document.body.insertAdjacentHTML("BeforeEnd",tellafriend_layer);
}

function tellafriendfr()
{
	tellafriend_layer = '<div id="tellafriend" style="position:absolute;top:0px;left:0px;width:100%;height:100%;"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center" valign="middle"><div style="text-align:center;width:400px;height:200px;background-color:#FFFFFF;border-top:Solid 1px #c9c9c9;border-left:Solid 1px #c9c9c9;border-bottom:Solid 1px Gray;border-right:Solid 1px Gray;">'
	tellafriend_layer = tellafriend_layer + '<form name="tellafriendform" method="post"><table border="0" cellpadding="0" cellspacing="0" style="margin:20px;">';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" valign="top" style="padding-right:20px;" rowspan="7"><img src="/images/tellafriend.jpg" width="30" height="30"></td><td align="left" colspan="2"><strong>Expéditeur</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Votre nom</td><td align="left"><input type="text" name="FromName" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Votre e-mail</td><td align="left"><input type="text" name="FromEmail" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" colspan="2" style="padding-top:10px;"><strong>Destinataire</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Nom</td><td align="left"><input type="text" name="ToName" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">E-mail</td><td align="left"><input type="text" name="ToEmail" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td></td><td align="left" style="padding-top:10px;"><input type="button" onClick="document.tellafriendform.action=document.location;document.tellafriendform.submit();" value="envoyer" class="button"> <input type="button" class="button" value="fermer" onClick="setmainfocus();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '</table></form></div></td></tr></table></div>';
	document.getElementById('main').style.filter = 'alpha(opacity=40)';
	document.getElementById('main').style.opacity = '.40';
	document.getElementById('footer').style.filter = 'alpha(opacity=40)';
	document.getElementById('footer').style.opacity = '.40';
	document.body.innerHTML += tellafriend_layer;
	//document.body.insertAdjacentHTML("BeforeEnd",tellafriend_layer);
}

function verwittighandelaar()
{
	tellafriend_layer = '<div id="tellafriend" style="position:absolute;top:0px;left:0px;width:100%;height:100%;"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center" valign="middle"><div style="text-align:center;width:400px;height:200px;background-color:#FFFFFF;border-top:Solid 1px #c9c9c9;border-left:Solid 1px #c9c9c9;border-bottom:Solid 1px Gray;border-right:Solid 1px Gray;">'
	tellafriend_layer = tellafriend_layer + '<form name="tellafriendform" method="post"><table border="0" cellpadding="0" cellspacing="0" style="margin:20px;">';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" valign="top" style="padding-right:20px;" rowspan="7"><img src="/images/tellafriend.jpg" width="30" height="30"></td><td align="left" colspan="2"><strong>Uw gegevens:</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Uw naam</td><td align="left"><input type="text" name="FromName2" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Uw e-mail</td><td align="left"><input type="text" name="FromEmail2" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td align="left" colspan="2" style="padding-top:10px;"><strong>Gegevens van de handelaar:</strong></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">Naam</td><td align="left"><input type="text" name="ToName2" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td width=""150"" style="padding-right:20px;" align="left">E-mail</td><td align="left"><input type="text" name="ToEmail2" value="" class="w245" onFocus="this.select();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '<tr><td></td><td align="left" style="padding-top:10px;"><input type="button" onClick="document.tellafriendform.action=document.location;document.tellafriendform.submit();" value="verzenden" class="button"> <input type="button" class="button" value="sluiten" onClick="setmainfocus();"></td></tr>';
	tellafriend_layer = tellafriend_layer + '</table></form></div></td></tr></table></div>';
	document.getElementById('main').style.filter = 'alpha(opacity=40)';
	document.getElementById('main').style.opacity = '.40';
	document.getElementById('footer').style.filter = 'alpha(opacity=40)';
	document.getElementById('footer').style.opacity = '.40';
	document.body.innerHTML += tellafriend_layer;
	//document.body.insertAdjacentHTML("BeforeEnd",tellafriend_layer);
}

function setmainfocus()
{
	document.location.reload();
}

var dtCh= "-";
var minYear=2000;
var maxYear=3000;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(form, dayfield, monthfield, yearfield){
	dtStr = document.forms[''+form+''].elements[''+monthfield+''].options[document.forms[''+form+''].elements[''+monthfield+''].selectedIndex].value + '-' + document.forms[''+form+''].elements[''+dayfield+''].options[document.forms[''+form+''].elements[''+dayfield+''].selectedIndex].value + '-' + document.forms[''+form+''].elements[''+yearfield+''].options[document.forms[''+form+''].elements[''+yearfield+''].selectedIndex].value;
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}



function showhideaddress(val)
{
	
	if (val == 0 )
	{
		document.getElementById('companympccontainer').style.display = 'block';
		document.getElementById('companympccontainer').style.visibility = 'visible';
	}
	else
	{
		document.getElementById('companympccontainer').style.display = 'none';
		document.getElementById('companympccontainer').style.visibility = 'hidden';
	}

}

function isUrl(s) {

     /*
	
     var theurl=s;
     var tomatch= /(http:https):\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(theurl))
     {
         return true;
     }
     else
     {
         return false; 
     }
     */
	

     var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
     return regexp.test(s);
 }

function generatecode(element)
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
	//abcdefghiklmnopqrstuvwxyz
	var string_length = 10;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	document.getElementById(element).value = "MK" + randomstring;
	
}

function setmap(inh)
{
	document.getElementById("mapcontent").innerHTML = inh;

}

function wijzigVoorwaarden(){
	if(document.getElementById('standardconditions').checked == true){
		document.getElementById('standardconditions2').checked = true;
		if(document.getElementById('voorwaardennl').value == ''){
			document.getElementById('voorwaardennl').value = 'Korting enkel geldig op vertoon van uw gepersonaliseerde M&B kaart en of deze afgedrukte kortingsbon';
		}
		if(document.getElementById('voorwaardenfr').value == ''){
			document.getElementById('voorwaardenfr').value = 'Remise valable sur présentation de votre carte personnalisée de M&B ou et le bon imprimé';
		}
	}
	if(document.getElementById('standardconditions').checked == false){
		document.getElementById('standardconditions2').checked = false;
		document.getElementById('voorwaardennl').value = '';
		document.getElementById('voorwaardenfr').value = '';
	}
}
