﻿
function Sligro_OnLoad()
{
	resize_iframe();
	SubmitDataToIframe();
	//SetIframe();
	PostcodeZoeker();
}
function resize_iframe()
{
	myString = String(parent.location);
	myArray = myString.split('.nl/');
	if (myArray[1] != 'Pages/default.aspx' && myArray[1] != 'thema/Pages/default.aspx')
	{
		if (window.frames['anIframe'])
		{
			document.getElementById("anIframe").height=document.body.offsetHeight-document.getElementById("anIframe").offsetTop-120;
		}
	}
}
function check_postcode()
{
	if (document.forms[0].zipcode.value.match(/^[1-9][0-9]{3}\s*?[a-zA-Z]{2}$/))
	{
		DoPostcodeLookup();
		return false;
	}
	else
	{
		window.alert('De ingevulde postcode is niet geldig. Een geldige postcode bestaat uit 4 cijfers en 2 letters');
		document.forms[0].zipcode.value='';
		return false;
	}
}
function postcode_KeyDown(e)
{
	if (e.keyCode == 13 || e.keyCode==10) 
	{
		e.returnValue=false;
		if (check_postcode())
		{
			DoPostcodeLookup();
			return false;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return true;
	}
}

function DoPostcodeLookup()
{
  var url = "/locaties/Pages/Locatiezoeker.aspx?zipcode=__zipcode__";
  url = url.replace(/__zipcode__/g, document.forms[0].zipcode.value);
  window.location = url;
}

function changeImages()
{
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function PostcodeZoeker()
{
	if (window.frames['LocatieZoekerIframe'])
	{
		qString = parent.location.search.substring(1).split('=');
		if ((qString[0] == 'zipcode') && (qString[1] != ''))
		{
			window.frames['LocatieZoekerIframe'].location = "http://tools.locatienet.com/finder/address.asp?zipcode=" + qString[1] +"&resulttype=BEST&client_id=1592&settings=&street=&country=NL&city=";
			document.invoerform.zipcode.value = qString[1];
		}
	}
}

function SubmitDataToIframe()
{
	if (window.frames['anIframe'])
	{
		qString = parent.location.search.substring(1).split('=');
		if ((qString[0] == 'zipcode') && (qString[1] != ''))
		{
			document.invoerform.action = 'http://tools.locatienet.com/finder/address.asp'
			document.invoerform.resulttype.value = 'BEST';
			document.invoerform.client_id.value = '1491';
			document.invoerform.country.value = 'NL';
			document.invoerform.zipcode.value = qString[1];
			document.invoerform.submit();
		}
		
		if ((qString[0] == 'vestiging') && (qString[1] != ''))
		{
			document.invoerform.action = '/wpresources/postcode.asp'
			document.invoerform.vestiging.value = qString[1];
			document.invoerform.submit();
		}
	}
}

function SetIframe()
{
	myString = String(document.location);
	myArray = myString.split('?');
	if (myArray.length > 1)
	{
		qString = parent.location.search.substring(1).split('=');
		
		if (window.frames['anIframe'] && myArray[1].search("zipcode") == -1 && myArray[1].search("vestiging") == -1)
		{
			//document.frames['anIframe'].location.href = '/wpresources/aanbiedingen/standaard_mc.asp?' + myArray[1];
		}
	}
}

function txtFinder_KeyDown(e)
{
	if (e.keyCode == 13 || e.keyCode==10) 
	{
		e.returnValue=false;
		DoSearch();
		return false;
	}
	else
		return true;
	}

function DoSearch()
{
	var url = "/zoeken/Pages/zoeken.aspx?k=__searchterm__";
	url = url.replace(/__searchterm__/g, document.all["txtfinder"].value);
	window.location=url;
}




