var parameters;

function setLang(langcode){
Cookie.set('taal', langcode, {duration: 1});
document.location.reload();
};

function init(){

if(parameters!=null && parameters.slider==1){
var pad=(parameters.id=='')? "images/"+parameters.op+"/" : "images/"+parameters.op+"/"+parameters.id+"/";
var ss=new Slideshow('beeld', 0, parameters.op,parameters.id, parameters.categorie,  pad, '#fafafa', 0, parameters.vertaal);	
}	

};

window.onload=init;


Window.onDomReady(function(){
new Menu();
//init();	
});

var Menu= new Class( { 
initialize: function(formid, options){
	
	this.menu_0=(window.ie) ? $$('#menu #menu_0') : $$('#menu_0');
	this.menu_0.each(function(menu0) {
	
	var beeld= $E('img', menu0);	
	menu0.hit=(menu0.className.match("_on")==null) ? 0 : 1;
	menu0.addEvent('mouseenter', function(){
	
	if(menu0.className.match("_on")==null){	
	var beeld=$E('img', menu0).src;			
	var new_src= beeld.split(".gif");	
	new_src= new_src[0]+"_muis.gif";
	$E('img', menu0).src=new_src
	
	menu0.className=menu0.className+'_on';
	menu0.setStyle("cursor", "default");
	
	}
	
	menu0.childNodes[2].style.display="block";
	});
	
	
	menu0.addEvent('mouseleave', function(){
	
	
	if(menu0.hit==0){
	var beeld=$E('img', menu0);
	var new_src= beeld.src.split("_muis.gif");
	new_src= new_src[0]+".gif";
	$E('img', menu0).src=new_src
	menu0.cl=menu0.className.split('_on');
	menu0.className=menu0.cl[0];
	}
	
	menu0.childNodes[2].style.display="none";
	});
	
	
	});
	
	},
	
Verzend: function(stap){
	
}

});



var Menuklein= new Class( { ////navigatiemenu
initialize: function(formid, options){
	var menu_klein=(window.ie) ? $$('#menu_klein #menu_itemk') : $$('#menu_itemk');
	menu_klein.each(function(menuk) {
	
	menuk.hit=(menuk.className.match("_on")==null) ? 0 : 1;	
	menuk.addEvent('mouseenter', function(){	
	if(menuk.hit==0){
	menuk.className= menuk.className+"_on";	
	window.status=menuk.className;
	}
	});
	
	menuk.addEvent('mouseleave', function(){
	var new_class= menuk.className.split("_on");	
	if(menuk.hit==0){
	menuk.className= new_class[0];
	window.status=menuk.className;
	}
	});
	
	
	});
		
}

});



var Relaties= new Class( { 
initialize: function(){

this.bestand="index.php?op=links&ajax=1&f=relaties";

this.s2 = new SWFObject("image_rotator/imagerotator.swf","relaties","180","135","7");
	this.s2.addVariable("file",encodeURIComponent(this.bestand)); 
	this.s2.addVariable("transition","slowfade");
	this.s2.addVariable("shownavigation","false");
	this.s2.addVariable("thumbsinplaylist","false");
	this.s2.addVariable("overstretch","false");
	this.s2.addVariable("showicons","true");
	this.s2.addVariable("width","180");
	this.s2.addVariable("height","135");
	this.s2.addVariable("repeat","true");
	this.s2.addVariable("shuffle","false");
	this.s2.addVariable("frontcolor","0x0d0046");//+this.lightcolor
	this.s2.addVariable("lightcolor","0xffffff");
	this.s2.addVariable("backcolor","0xffffff");
	this.s2.addVariable('linktarget','_blank');
	this.s2.addVariable('linkfromdisplay','true');
	this.s2.addVariable('rotatetime','4');
	
	this.s2.write("relaties");	
	}
});	


var sos	= new Array();
var so	= '';
var Imagerotator= new Class( { ////bij opstarten alle blokken automatisch een mouseover geven met de coordinaten naar centered
initialize: function(options){
	this.options = Object.extend({
		update_id: 0,
		width: 0,		
		height: 0,
		delay: 750,
		file: '',
		parameters: '',
		background: 'flvplayer/film.jpg',
		lightcolor:'ffffff',
		showvolume: true,
		autostart: true
		}, options || {});
	
	this.update_id	=this.options.update_id;	
	this.width	= this.options.width;	
	this.height	= this.options.height;	
	this.delay	= this.options.delay;	
	this.file		= this.options.file;	
	this.parameters= this.options.parameters;	
	this.lightcolor	= this.options.lightcolor;
	this.showvolume= this.options.showvolume;
	this.autostart	= this.options.autostart;
	this.background= this.options.background;
	
	mySlidestate=0;
	toggle_beeld();
	var bestand="index.php?"+this.parameters;
	//document.location.href=bestand;
	this.s2 = new SWFObject("image_rotator/imagerotator.swf","floatcontent","559","419","7");
	this.s2.addVariable("file",encodeURIComponent(bestand)); //<<<< volgende stap om die goed te zetten in het systeem
	this.s2.addVariable("transition","slowfade");
	this.s2.addVariable("shownavigation","true");
	this.s2.addVariable("thumbsinplaylist","true");
	this.s2.addVariable("overstretch","false");
	this.s2.addVariable("showicons","true");
	this.s2.addVariable("width","559");
	this.s2.addVariable("height","419");
	this.s2.addVariable("shuffle","false");
	this.s2.addVariable("frontcolor","0x0d0046");//+this.lightcolor
	this.s2.addVariable("lightcolor","0xffffff");
	this.s2.addVariable("backcolor","0xffffff");
	this.Write.delay(this.delay, '', new Array(this.update_id, this));
	
	},
	
Write: function(update_id, ob){	
	//alert(update_id+"|"+ob.s2);
	ob.s2.write(update_id);	
	}

});


var mySlide='';
var mySlidestate=0;

function toggle_beeld(){
mySlide = (mySlide=="") ? new Fx.Styles($('beeld') ,'opacity', {duration: 500, transition: Fx.Transitions.Cubic.easeOut,  wait:false}) : mySlide ;

if(mySlidestate==1){
$('imgcontroller').src		= "images/buttons/min.png";	
mySlide.start({
'height': [0, 442],
   'opacity': [0, 1]
});	

}else{
	

$('imgcontroller').src		=  "images/buttons/plus.png";
mySlide.start({'height': [350, 32], 'opacity': [1, 0]});
}
mySlidestate			= (mySlidestate==0) ? 1 : 0;
}


var sos	= new Array();
var so	= '';
var Imagerotator= new Class( { ////bij opstarten alle blokken automatisch een mouseover geven met de coordinaten naar centered
initialize: function(options){
	this.options = Object.extend({
		update_id: 0,
		width: 0,		
		height: 0,
		delay: 750,
		file: '',
		parameters: '',
		background: 'flvplayer/film.jpg',
		lightcolor:'ffffff',
		showvolume: true,
		autostart: true
		}, options || {});
	
	this.update_id	=this.options.update_id;	
	this.width	= this.options.width;	
	this.height	= this.options.height;	
	this.delay	= this.options.delay;	
	this.file		= this.options.file;	
	this.parameters= this.options.parameters;	
	this.lightcolor	= this.options.lightcolor;
	this.showvolume= this.options.showvolume;
	this.autostart	= this.options.autostart;
	this.background= this.options.background;
	
	mySlidestate=0;
	toggle_beeld();
	var bestand="index.php?"+this.parameters;
	//document.location.href=bestand;
	this.s2 = new SWFObject("image_rotator/imagerotator.swf","floatcontent","559","419","7");
	this.s2.addVariable("file",encodeURIComponent(bestand)); //<<<< volgende stap om die goed te zetten in het systeem
	this.s2.addVariable("transition","slowfade");
	this.s2.addVariable("shownavigation","true");
	this.s2.addVariable("thumbsinplaylist","true");
	this.s2.addVariable("overstretch","false");
	this.s2.addVariable("showicons","true");
	this.s2.addVariable("width","559");
	this.s2.addVariable("height","419");
	this.s2.addVariable("shuffle","false");
	this.s2.addVariable("frontcolor","0x0d0046");//+this.lightcolor
	this.s2.addVariable("lightcolor","0xffffff");
	this.s2.addVariable("backcolor","0xffffff");
	this.Write.delay(this.delay, '', new Array(this.update_id, this));
	
	},
	
Write: function(update_id, ob){	
	//alert(update_id+"|"+ob.s2);
	ob.s2.write(update_id);	
	}

});


var wfx;
function showPopup(w, h, bgtrans){
wfx 		= new Fx.Styles('floatwindow', {duration:750, wait:false});
var ttop	= (window.getHeight()/2)-(h/2);//$('beeld').getTop()+60;
var lleft		= (window.getWidth()/2)-(w/2);

if($('blok_23')){
$('blok_23').style.display="none";	
	
}

$('floatwindow').style.display='block';
$('floatwindow').setStyle('left', (window.getWidth()/2));
$('floatwindow').setStyle('top',  (window.getHeight()/2));

	wfx.start({			
	'height': h+'px',
	'width': w+'px',
	'top': ttop+'px',
	'left': lleft+'px',
	'opacity': '1'
	});		
	
	
	if(bgtrans>0){
	var ww=window.getScrollWidth();
	var wh=window.getScrollHeight();
	$('bgdiv').setStyles({
   	opacity: bgtrans,
   	width: ww,
   	height: wh
	});	
	
	}
	window.scrollTo(0, 0);
}


function closePopup(rreset){

wfx.start({			
	'height': 1+'px',
	'width': 1+'px',
	'top': (window.getHeight()/2)+'px',
	'left': (window.getWidth()/2)+'px',
	'opacity': '0'
	});	
		
	$('bgdiv').setStyles({
   	opacity: 0,
   	width: 0,
   	height: 0
	});	
$('floatcontent').innerHTML='';
if(rreset){
$(rreset).reset();	
}

if($('blok_23')){
$('blok_23').style.display="block";	
	
}

}



var map;
var GoogleMaps= new Class( { ////bij opstarten alle blokken automatisch een mouseover geven met de coordinaten naar centered

initialize: function(options){
	
this.options = Object.extend({
		breedte:	100,
		hoogte:		100,
		largemapc:	0,
		page_id:	0,
		maptypec:	0,
		overviewc:	0,
		debug:		0
		}, options || {});
	
		this.breedte		= this.options.breedte;
		this.hoogte		= this.options.hoogte;
		this.largemapc		= this.options.largemapc;
		this.page_id		= this.options.page_id;
		this.maptypec		= this.options.maptypec;
		this.overviewc		= this.options.overviewc;
		this.debug		= this.options.debug;
		
		if (GBrowserIsCompatible()) {
		this.themap	= $('map'); 	
		this.themap.setStyles("width:"+this.breedte+"px;height:"+this.hoogte+"px");
		map 	= new GMap2(this.themap);
		//this.locatie	= new GLatLng(53.03403936594488, 5.763959884643555);
		this.locatie	= new GLatLng(53.043328788835964, 5.779280662536621);
		map.setCenter(this.locatie, 16);
		map.setMapType(G_HYBRID_MAP);	
		
		if(this.largemapc==1){
		map.addControl(new GLargeMapControl());
		}
		
		if(this.maptypec==1){
		map.addControl(new GMapTypeControl());
		}

		if(this.overviewc==1){
		map.addControl(new GOverviewMapControl());
		}
		
		if(this.debug==1){		
		GEvent.addListener(map, "moveend", function() {
       		var center = map.getCenter();		
       		$("message").innerHTML = center.toString();
       		});	
		}
		
		this.getObjecten();
		}
		
		},
		
getObjecten: function(){
		
GDownloadUrl("objecten.php?page_id="+this.page_id, function(data) {
          var xml = GXml.parse(data);
          var objecten = xml.documentElement.getElementsByTagName("object");
      
          for (var i = 0; i < objecten.length; i++) {
          var naam	= objecten[i].getElementsByTagName('naam')[0].firstChild.nodeValue;
          var img_k	= objecten[i].getElementsByTagName('img_k')[0].firstChild.nodeValue;
          var img_ks	= objecten[i].getElementsByTagName('img_ks')[0].firstChild.nodeValue;
          var img		= objecten[i].getElementsByTagName('img')[0].firstChild.nodeValue;
          var border	= objecten[i].getElementsByTagName('border')[0].firstChild.nodeValue;
          var lat		= objecten[i].getElementsByTagName('lat')[0].firstChild.nodeValue;
          var lng		= objecten[i].getElementsByTagName('lng')[0].firstChild.nodeValue;
          var breedte	= objecten[i].getElementsByTagName('breedte')[0].firstChild.nodeValue;
          var hoogte	= objecten[i].getElementsByTagName('hoogte')[0].firstChild.nodeValue;
          var titel		= objecten[i].getElementsByTagName('titel')[0].firstChild.nodeValue;
          var tekst	= objecten[i].getElementsByTagName('tekst')[0].firstChild.nodeValue;
          var point 	= new GLatLng(lat,lng);
          

            this.object 	=createMarker(point, naam, img_k, img_ks, img, border, lat, lng, breedte, hoogte, titel, tekst);
            map.addOverlay(this.object);
          	}
          
        	});
	}



});


markers=new Array();
markerscount=0;
function createMarker(point, naam, img_k, img_ks, img, border, lat, lng, breedte, hoogte, titel, tekst) {
// Create our "tiny" marker icon
var icon 		= new GIcon();
icon.image 		= img_k;
if(img_ks!="0"){
icon.shadow 		= img_ks;
}
icon.iconAnchor 	= new GPoint(16, 16);
icon.infoWindowAnchor= new GPoint(5, 1);	
	
var afbeelding=(img!=0)? "<img src='"+img+"' border='"+border+"'><br>": "";
var style=(breedte!="")? "style='text-align:left;border:1px solid #fafafa;width:"+breedte+"px;height:"+hoogte+"px'": "style='text-align:left;'";
var marker = new GMarker(point, {icon:icon,  title: titel});
      var html = "<div "+style+">"
      html += "<span id='infowindowtitel'>" + naam + "</span><br>"
      html += "<p align='left' id='infowindow'>"+afbeelding+""+tekst+"</span></div>";
      
   
 markers[markerscount] =  marker;    
 markerscount++;
 GEvent.addListener(marker, 'click', function() {
 	marker.openInfoWindowHtml(html);	
 	
   });
   
   
      return marker;
    }
    


function change(fe){
fe.style.fontStyle="normal";	
fe.style.color="#000059";	

if(fe.value=="bijv. schoolstraat 23, 9099 ws, leeuwarden"){
fe.value='';
}

}

function openroute(loc){
var vanadres=$('adress1').value;
var naaradres="Jelle-Paad+2,+8493+Terhorne,+Boarnsterhim+(Friesland)";
//http://maps.google.nl/maps?f=d&hl=nl&geocode=&saddr=Bote+A+Bolswertstraat,+8701+Bolsward,+Bolsward+(Friesland)+(Friesland)
//&daddr=Jelle-Paad+2,+8493+Terhorne,+Boarnsterhim+(Friesland)&sll=52.469397,5.509644&sspn=3.048662,8.080444&ie=UTF8&z=12&om=0
var routepagina="http://maps.google.nl/maps?f=d&hl=nl&saddr="+vanadres+"&daddr="+naaradres;
window.open(routepagina,'routebeschrijving', 'width=1024,height=768,scrollbars=no,toolbar=no,location=no')
}




 
var stappen	= new Array();
var Ajaxform= new Class( { ////bij opstarten alle blokken automatisch een mouseover geven met de coordinaten naar centered
initialize: function(formid, options){
	this.options = Object.extend({
		update_id: 0,
		formulier: 0,
		to_Hide: 0
		}, options || {});
		//this.formulier2=$(formid);
		this.formulier=$(this.options.formulier);
		
		this.to_Update	= $(this.options.update_id);
		
	//alert(formid+" - "+this.formulier);
	
	stappen.extend([this]);
	
	//alert(this.formulier.tagName);
	this.formulier.addEvent('submit', function(e) {
	new Event(e).stop();
	
	});

	},
	
checkFields: function(){
var velden=this.formulier.elements;
//var velden = $$('#orderformulier select', '#orderformulier input') //an array of all anchor tags with theclass "myClass"
//var velden = $$('#formulier select', '#formulier input') //an array of all anchor tags with theclass "myClass"




for(i=0; i<velden.length; i++){
           var field = velden[i];
	if(field.tagName!="FIELDSET"){
          
            var isReq = (field.name.charAt(0)=="R") ? true : false
 	
            if(isReq && field.value==""){
           	var veldnaam = field.name.substring(1,27);
		var veldnaam = veldnaam.replace(/_/, " ");
           	alert("U bent vergeten '"+veldnaam+"' in te vullen.");
		field.focus();
		return false;	
		break;
		
	}
	
	if(field.name=="Remail"){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        	if (!filter.test(field.value)){
        	alert("Het door u ingevulde emailadres is onjuist");
        	return false;
        	break
        	}
	}
		
	}
	
};


return true;	
},
	
Vorige: function(functie){
$('f').value=functie;	
this.Verzend();
},

Verzend: function(functie){
	
	if(functie!=""){
	//$('f').value=functie;	
	}
	//alert(stappen[0].to_Update);
	//alert(1);
	if(this.checkFields()){
	
	this.formulier.send({
		update: stappen[0].to_Update,
		evalScripts: true
		//,onComplete: this.OK
	});
	
	}
	
	}

});


function ex_popup(source){
$('floatcontent').innerHTML="<img src='"+source+"' border='0'>";	
	
}



var occ;
var occasion_overzicht= new Class( { ////navigatiemenu
	
	initialize: function(){
	this.options = Object.extend({
		stap: ''
		}, this.options || {});
		this.stap=this.options.stap;

		//this.occ_divs=$$('#occasion_box');	
		this.occ_divs=$$('#overzicht_div span');	 //mag ook een andere tag zijn als die A verderop maar weeer terugkomt, dus span?

	occ=this;
	this.occ_divs.each(function(odiv) {
	/*
	odiv.addEvent('click', function(event){     
	var event = new Event(event);
	
	if(event.target.id=="niet"){
	alert('s');
	return false;
	}
	
	});	
	*/
	odiv.addEvent('mouseenter', function(){     	
	//alert(odiv.innerHTML);
	dedivs=odiv.getElements('.occ'); 
	dedivs[0].setStyle('background', 'url(images/overzichtbox_top.gif)');
	dedivs[1].setStyles('background:url(images/overzichtbox_midden.gif);cursor:pointer;color:#F71B14');
	dedivs[2].setStyle('background', 'url(images/overzichtbox_bottom.gif)');
	
	});
	
	odiv.addEvent('mouseleave', function(){     	
	dedivs=odiv.getElements('.occ'); 
	dedivs[0].setStyle('background', 'url(images/overzichtbox_top20.gif)');
	dedivs[1].setStyles('background:url(images/overzichtbox_midden20.gif);color:#000059');
	dedivs[2].setStyle('background', 'url(images/overzichtbox_bottom20.gif)');
	
	});

})

}

});


function check_files(fe, melding){
var files=$$('.file');	
var c=0;
files.each(function(file) {
c=(file.checked)?1: c;
});

if(c==0){
alert(melding);	
fe.checked=true;
}


}

function leegmaken(){
Cookie.remove('pg');
document.location.reload();
} 
//}