window.addEvent("domready",function(){
	//$("locaties").setStyle("height",$("content").getCoordinates().height-40);		
	var today = new Date();
	var dag = today.get("date");
	var maand = today.get("month")+1;
	var jaar = today.get("year");	
	var closer = new Element("img",{
		src:'img/close.png',						
		styles:{
			zIndex:10001,
			cursor:"pointer",
			display:"none"
		}		
	}).addClass("closer").inject(document.body);
	$$("#select_dag option").each(function(option,index){
		if(option.get("value")==dag) {
			$("select_dag").set("value",option.get("text"));
			$("select_dag").selectedIndex = index;
		}
	});
	$$("#select_maand option").each(function(option,index){
		if(option.get("value")==maand) {
			$("select_maand").set("value",option.get("text"));
			$("select_maand").selectedIndex = index;
		}
	});
	$$("#select_jaar option").each(function(option,index){
		if(option.get("value")==jaar) {
			$("select_jaar").set("value",option.get("text"));
			$("select_jaar").selectedIndex = index;
		}
	});
	$$(".nieuwsItem").each(function(item){
		item.addEvents({
			"mouseenter":function(){
				item.setStyles({"cursor":"pointer"});
			},			
			"click":function(){
				document.location.href = item.getElement("a").get("href");
			}
		});
	});
	$$("#lastMinutes .even").each(function(item){
		item.addEvents({
			"mouseenter":function(){
				item.setStyles({"background":"#fff","cursor":"pointer"});
			},
			"mouseleave":function(){
				item.setStyle("background","#A4C6DD");
			},
			"click":function(){
				document.location.href = item.getElement("a").get("href");
			}
		});
	});
	$$("#lastMinutes .odd").each(function(item){
		item.addEvents({
			"mouseenter":function(){
				item.setStyles({"background":"#fff","cursor":"pointer"});
			},
			"mouseleave":function(){
				item.setStyle("background","#CDDDE7");
			},
			"click":function(){
				document.location.href = item.getElement("a").get("href");
			}
		});
	});
	$$(".aanbieding").each(function(item){
		item.addEvents({
			"mouseenter":function(){
				item.setStyles({"background":"#CDDDE7","cursor":"pointer"});
			},
			"mouseleave":function(){
				item.setStyle("background","#FCEFB5");
			},
			"click":function(){
				document.location.href = item.getElement("a").get("href");
			}
		});
	});
	$$("tbody.vloot").each(function(item){
		item.addEvents({
			"mouseenter":function(){
				item.setStyles({"background":"#eee"});
			},
			"mouseleave":function(){
				item.setStyle("background","#fff");
			}			
		});
	});
	$$(".specs").addEvents({
		"click":function(){		
			var url = this.get("href").toURI();
			var keuze = url.getData("schip");
			var myStickyWin = new StickyWin.Modal.Ajax({
				url: 'includes/specs.asp?keuze='+keuze,
				id:'stickywin',
				destroyOnClose:true,
				allowMultiple:false,
				hideOnClick:false,
				onDisplay:function(){
					closer.removeEvents().addEvents({
						"click":function(){
							myStickyWin.hide();
							closer.hide();
						}
					}).show().position({
						relativeTo: $("stickywin"),
						position: 'upperLeft',
						offset:{
							x:-13,
							y:-13
						}
					});
				}				
			}).update();
		}
	});
	$$("#thumbs img").addEvents({
		"click":function(){
			var thumb = this;
			thumb.wait();
			var href = thumb.get("src").toURI();
			var pic = "picture.asp?kenmerk="+href.getData("kenmerk")+"2&size=282&volgnr="+href.getData("volgnr")+"&plattegrond=" + href.getData("plattegrond");
			var link = "picture.asp?kenmerk="+href.getData("kenmerk")+"2&volgnr="+href.getData("volgnr")+"&plattegrond=" + href.getData("plattegrond");
			var foto = $("photo").getElement("a");
			new Element("img",{
				src:pic,
				events:{
					"load":function(){
						$("photo").setStyle("opacity",1);
						$$(".foto img").set("src",pic);
						foto.set("href",link);
						$$("img.active").removeClass("active");
						thumb.addClass("active");
						thumb.release();						
					}
				}
			})
		}
	});
	$$("#photo").setStyle("opacity",0);
	$$("#thumbs").getFirst("img").fireEvent("click");
	$$("#tagcloud a").addEvents({
		"click":function(e){
			var keuze = this.get("href").toURI().getData("keuze");
			new Request({
				url:'includes/updateTagCloud.asp'
			}).send('keuze='+keuze);
		}
	});
});

window.addEvent('load', function() { 
	ReMooz.assign('#photos a', {
		'origin': 'img',
		'shadow': 'onOpen'
	}); 
});