function showPictures(id, urls, body) {
	var swf = new SWFObject("flash/pictures.swf", id, body ? "395" : "378", body ? "255" : "203", "9", "#FFFFFF", true);
	for(var i = 0; i < urls.length; i++) {
		swf.addVariable("pictureUrl"+i, urls[i]);
	}
	if(!body) {
		swf.addVariable("showShadow", true);
		swf.addVariable("showCorner", true);
	}
	swf.write(id);
}

function showBusyOverlay() {
	updateBusyOverlayPosition();
	if($('busyoverlay')!=null)
		$('busyoverlay').show();
}

function hideBusyOverlay(){
	if($('busyoverlay')!=null)
		$('busyoverlay').hide();
}

function hideSidebar() {
	$("sidebarCell").hide();
}

function showSidebar() {
	$("sidebarCell").show();
}

function updateSelectedCities(cities) {
	$("gemeenteId").value = cities.join("; ");
}

function closeMap() {
	hideKaart();
}

function closeVerkaveling() {
	hideVerkaveling();
}

function search(zoektype,postcode) {
	hideKaart();
	zoek(zoektype,postcode);
}

function hideIntro(){
	$("intro").hide();
	stretchBodyCell();
}
function showIntro(){
	$("intro").show();
	stretchBodyCell();
}

Event.observe(window, "load", function() {
	$('overlay').observe('click', hideContainers);
	Event.observe(window, "resize", updateOverlaySize);
});

function stretchBodyCell(){
	var dochoogte = document.documentElement.clientHeight;
	var headerhoogte = 179;
	var introhoogte = $("introCell").offsetHeight;
	var creditshoogte = $("creditsCell").offsetHeight;
	$("bodyCell").style.height=((dochoogte - headerhoogte - introhoogte - creditshoogte) + "px");	
}


function updateSelectedProvincieProjecten(prov){
	SWFAddress.setValue("/projecten/?provincie=" + prov);
}
function updateSelectedProvincieProjectenRef(prov){
	SWFAddress.setValue("/projecten/?provincie=" + prov + "&isReferentie=1");
}

function updateSelectedProvincieSfeerwoningen(prov){
	SWFAddress.setValue("/sfeerwoningen/?provincie=" + prov);
}

function updateOverlaySize() {
	var arrayPageSize = getPageSize();
	$('overlay').style.width = arrayPageSize[0] + 'px';
	$('overlay').style.height = arrayPageSize[1] + 'px';
}

function updateBusyOverlayPosition() {
	var arrayPageSize = getPageSize();
	if($('busyoverlay')!=null){
		$('busyoverlay').style.left = Math.round((arrayPageSize[0]-156)/2) + 'px';
		$('busyoverlay').style.top = Math.round((arrayPageSize[1]-8)/2) + 'px';
	}
}

function hideContainers(){
	try{
	hideKaart();
	}catch(e){
	}
	try{
	hideVerkaveling();
	}catch(e){
	}	
	try{
	hideKijkboek();
	SWFAddress.setValue("/");
	}catch(e){}
}
function hideKaart() {
	$('overlay').hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	$('kaartContainer').innerHTML='';
	document.body.removeChild($('kaartContainer'));	
}

function hideKijkboek() {
	$('overlay').hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	$('kijkboekContainer').innerHTML='';
	$('kijkboekLinkContainer').innerHTML='';
	document.body.removeChild($('kijkboekContainer'));	
	document.body.removeChild($('kijkboekLinkContainer'));	
}

function hideVerkaveling() {
	$('verkavelingContainer').innerHTML='';
	document.body.removeChild($('verkavelingContainer'));
	$('overlay').hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
}


/*****************************
/* zoek functies
/****************************/

function zoek(zoektype,postcode){
	SWFAddress.href("index1.asp?menuId=37#/tekoop/?kostenplaatsNummer=&gemeente="+postcode+"&zoektype="+zoektype+"&browseCounter=1");		
	hideIntro();
}
/*****************************
/* algemene functies
/****************************/
	

function createPopupWindow(html,name,width,height) {
	var n=open
	( 
	html, name, 
	'width='+width+',height='+height
	+',left='+(screen.width -width )/2
	+',top=' +(screen.height-height)/2
	+',status=0,menubar=0,toolbar=0,scrollbars=0,resizable=1'
	);
	n.focus();
}

function get_windowHeight()
{
   var myWidth = 0, myHeight = 0;
   if( typeof( window.innerWidth ) == 'number' )
   { //Non-IE
      myHeight = window.innerHeight;
   }
   else
   {
      if ( document.documentElement && ( document.documentElement.clientWidth ||    document.documentElement.clientHeight ) )
   { //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
   }
   else
   {
      if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
      { //IE 4 compatible
         myHeight = document.body.clientHeight;
      }
   }
}
   return myHeight;
}

function getPageSize() {
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function loadKaart(params){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/kaart.asp', { 
			method: 'get',
			parameters:params,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function loadJobs(){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/toonJobs.asp', { 
			method: 'get',
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function showJob(jobId,jobLanguage){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/toonJobs.asp', { 
			method: 'get',
			parameters:'jobId='+jobId+'&jobLanguage='+jobLanguage,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function loadProjecten(params){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/projecten.asp', { 
			method: 'get',
			parameters:params,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function loadReferenties(params){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/referenties.asp', { 
			method: 'get',
			parameters:params,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function loadSfeerwoningen(params){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/sfeerwoningen.asp', { 
			method: 'get',
			parameters:params,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function showLot(kostenplaatsNummer,lotNummer,oppervlakte,gemeente,typewoning,zoektype){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/toonLot.asp', { 
			method: 'get',
			parameters:'kostenplaatsNummer='+kostenplaatsNummer+'&lotNummer='+lotNummer+'&oppervlakte='+oppervlakte+'&gemeente='+gemeente+'&typewoning='+typewoning+'&zoektype='+zoektype,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}
function loadCalendar(params){
	new Ajax.Updater('bodyMain','/library/templates/matexi/includes/includeCalendarEvents.asp', { 
			method: 'get',
			parameters:params,
			evalScripts:true,
			onCreate: function(transport) {showBusyOverlay();},
			onComplete: function(transport) {hideBusyOverlay();}
		}
	);	
}

