function setPicture(url, id)
{
	document.getElementById('foto_groot').src=url;
	document.getElementById('fotoindex').value=id;
	//energielabel verbergen als het niet de eerste foto is..
	if ( id == 0 && document.getElementById('energielabel') )
	  document.getElementById('energielabel').style.visibility='visible';
	else if ( document.getElementById('energielabel') )
	  document.getElementById('energielabel').style.visibility='hidden';
}	

function showPicture(woning)
{
	window.open('/fotoPagina.axd?action=read,'+woning+'&selected='+document.getElementById('fotoindex').value,'picture','width=800, height=600, scrollbars=yes, resizable=yes');
}	
function showLocatie(zip, adres, plaats)
{
	window.open('http://tools.locatienet.com/location/map.asp?config_id=5089&language=dutch&zipcode='+zip+'&country=NL&zoom=3&logo=http://www.sierdmoll.nl/images/logo_sierd_moll.gif&returntext=U%20bekijkt de woning: '+adres+' in '+plaats+'<BR>Terug%20naar%20de%20Sierd%20Moll%20site','lokatie','width=675,height=538, scrollbars=yes');
}
function printme(link)
{
	window.open(link,'lokatie','width=750,height=538, scrollbars=yes');
}	

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
    x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++)
    x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function getPos(theObj)
{
  x = y = 0;
  	var oldstyle = theObj.style.display;	
  	theObj.style.display = 'block';
  h = theObj.offsetHeight;
  w = theObj.offsetWidth;
	theObj.style.display = oldstyle;
  while(theObj){
    x += theObj.offsetLeft;
    y += theObj.offsetTop;
    theObj = theObj.offsetParent;
  }
  return {height:h,width:w,x:x,y:y}
}


var maxWidth = 150;
//150 zorgt ervoor dat de paragrafen er strak uitzien, maar dat de woningplaatjes niet worden geresized (zijn 140)
function checkImages()
{
	var images = document.getElementById('midden').getElementsByTagName('img');
	for(var i=0; i<images.length;i++)
	{
		var pos = getPos(images[i]);
		if (pos.width>maxWidth)
		{
			if (images[i].className!='directnaarlink' && images[i].id != 'foto_groot')
			{
				var factor = pos.height/pos.width;
				images[i].style.width = maxWidth + 'px';
				images[i].style.height = (maxWidth*factor) + 'px';
				
				/*if (images[i].parentNode.tagName != 'a')
				{
					images[i].className += ' resized';
					images[i].alt = 'Klik hier om de afbeelding te vergroten!';
					images[i].onclick = openInWindow;
				}*/
			}
		}
		
	}
}
function openInWindow()
{
	var popupwindow = window.open(this.src, 'popupwindow','width=600, height=400, scrollbars=yes, resizable=yes');
}
function Toggle(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	if(dd.style.display == "block") { dd.style.display = "none"; }
	else { dd.style.display = "block"; }
}

function setNewWoning(command)
{
	
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	
	xmlhttp.open("GET", "randomwoning.axd?command="+command ,true);
	
	
	 xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {	   
	   var returntekst = xmlhttp.responseText;
	   document.getElementById('rightHighlight').innerHTML = returntekst;
//	   	makeDomainHTML(domein+ext, returnarr[1], first);	   
	  }
	 }
	 xmlhttp.send(null)
}
function selectAllePlaatsen()
{
	var pCheckboxes=document.getElementsByName('back:woonplaatsinteresse');
	var ischecked=document.getElementById('cbAllePlaatsen').checked;
	for(i=0;i<pCheckboxes.length;i++)
	{
		pCheckboxes[i].checked=ischecked;
	}
	return true;
}