<!--
window.addEvent('domready', function() {
	if(window.getWidth > 960) {
		$(document.body).setStyle('overflow-x','hidden');
	}
});
window.addEvent('domready', function() {
	// fixing z-index bug on ie7
	if(window.ie7 && navigator.appVersion.indexOf("MSIE 8")==-1){
		var zIndexNumber = 1000;
		$$('div').each(function(el,i){
			if(el.hasClass('bg_holder')) {
				// alert(el.getStyle('z-index'));
			} else {
				el.setStyle('z-index',zIndexNumber);
				zIndexNumber -= 10;
			}
		});
	};
});
// for debugging !@#$%^? ie6
window.addEvent('domready', function() {
	if(window.ie6){
		// alert(navigator.appVersion);
	};
});

window.addEvent('domready', function() {
	// set properties for external links
	var links = $$('a');
    links.each(function(item) {
		if (item.getProperty('rel')) {
			if (item.getProperty('rel')=="ext") {
				item.setProperty('target', '_blank');
				item.addClass('extlink');
			}
			if (item.getProperty('rel')=="exte") {
				item.setProperty('target', '_blank');
			}
		}
    });
	// open all pdfs in a new window
	var links_pdf = $$('a.pdf');
    links_pdf.each(function(item) {
			item.setProperty('target', '_blank');
    });
	if($('submenu_back_btn_url')) {
		// correct dlvplant submenu_back_btn_url with javascript.history(-1)
		$('submenu_back_btn_url').setProperty('href', 'javascript:history.go(-1)');
		
	}
});
window.addEvent('domready', function() {
	var print_links = $$('a.rel_print');
    
    print_links.each(function(item) {
		item.addEvent("click", function(event) {
			window.print();				 
					 
		});
    });

});
/* ----- TOOLTIP FUNCTIONS ----- */
/*
window.addEvent('domready', function(){
	var tooltip = new Tips($$('a[title], img[title], .tooltip'), {
		showDelay: 500,
		hideDelay: 0
	});
}); 
*/
/* ----- PIT_TINYMENU FUNCTIONS ----- */
var ptm_settings = new Array();
ptm_settings['ptm_display'] = "none";
window.addEvent('domready', function() {
	var myPTMslide = new Fx.Slide('pit_tinymenu_items', { duration:400, transition: Fx.Transitions.Bounce.easeInOut});
	var myLayer = $('pit_tinymenu_items');
	
	if (Cookie.get('ptm_display')) {
		ptm_settings['ptm_display'] = Cookie.get('ptm_display');
		if(ptm_settings['ptm_display'] == "none") {
			myPTMslide.hide();
		} else {
			myPTMslide.show();
		}
	} else {
		ptm_settings['ptm_display'] = "none";
		myPTMslide.hide();
	}
	// var ptm_cookie = Cookie.set('ptm_display', 'none', {path: '/'});
	$('pit_tinymenu_nav_btn_link').addEvent('click', function(e){
		e = new Event(e);
		myPTMslide.toggle();
		e.stop();
		if(ptm_settings['ptm_display'] == "none") {
			ptm_settings['ptm_display'] = "block";	
		} else {
			ptm_settings['ptm_display'] = "none";		
		}
		ptm_cookie = Cookie.set('ptm_display', ptm_settings['ptm_display'], {path: '/'});
		
	});
});

/* ----- TOGGLE FUNCTIONS ----- */
function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display == "block" ? "none":"block";
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display == "block" ? "none":"block";
	} else if (document.layers)	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display == "block" ? "none":"block";
	}
}
/* CONTACTFORM */
// See validate.js -- validating all rel="required" form items


// new periodical (timer) class
periodical_class = new Class({
    initialize: function(dateString){
        this.count = 0;
        this.startTimer();
    },
    updateCount: function(){
        this.count++;
    },
    stopTimer: function(){
        $clear(this.periodicalTimer);
    },
    startTimer: function(){
        this.periodicalTimer = this.updateCount.periodical(1000, this);
    }
});

/* Array shuffle *//*
Array.implement({
	shuffle: function() {
		for(var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
		return this;
	}
});

This likely wont be used in the core framework but does have its uses.
*/
function array_shuffle(myarray) {
	for(var j, x, i = myarray.length; i; j = parseInt(Math.random() * i), x = myarray[--i], myarray[i] = myarray[j], myarray[j] = x);
	return myarray;
}



// fadeBetweenImages:
window.addEvent('domready', function() {
	// settings for DLV homepage fader
	var fadeDuration = 2000; //in milliseconds
	var periodicalDuration = 5000; //in milliseconds 
	var faderImages = new Array();
	// todo: set on page with php by reading a dir
	faderImages[0] = '/es/core/img/img_blend_1.jpg';
	faderImages[1] = '/es/core/img/img_blend_2.jpg';
	faderImages[2] = '/es/core/img/img_blend_3.jpg';
	faderImages[3] = '/es/core/img/img_blend_4.jpg';
	faderImages[4] = '/es/core/img/img_blend_5.jpg';
	faderImages[5] = '/es/core/img/img_blend_7.jpg';
	faderImages[6] = '/es/core/img/img_blend_8.jpg';
	faderImages[7] = '/es/core/img/img_blend_9.jpg';
	faderImages[8] = '/es/core/img/img_blend_10.jpg';
	faderImages[9] = '/es/core/img/img_blend_11.jpg';
	faderImages[10] = '/es/core/img/img_blend_12.jpg';
	faderImages[11] = '/es/core/img/img_blend_13.jpg';
	faderImages[12] = '/es/core/img/img_blend_14.jpg';
	faderImages[13] = '/es/core/img/img_blend_15.jpg';
	faderImages[14] = '/es/core/img/img_blend_16.jpg';
	faderImages[15] = '/es/core/img/img_blend_17.jpg';
	faderImages[16] = '/es/core/img/img_blend_18.jpg';
	faderImages[17] = '/es/core/img/img_blend_19.jpg';
	faderImages[18] = '/es/core/img/img_blend_6.jpg';
	
	new_faderImages = array_shuffle(faderImages);

	var visibleDiv = $("img_holder_1");
	// set the first items and skip these for the initial start
	$("img_fader_src_1").src = new_faderImages[0];
	$("img_fader_src_2").src = new_faderImages[1];
	
	var pathToImage = "";
	var start = 0;

	function faderToggle(newSrc,duration){
		if($("img_holder_1").fx){$("img_holder_1").fx.stop();}
		if($("img_holder_2").fx){$("img_holder_2").fx.stop();}
		if(visibleDiv == $("img_holder_1")){
			$("img_fader_src_2").src = newSrc;
			$("img_holder_1").fx = new Fx.Style($("img_holder_1"), 'opacity', {duration: duration}).start(0);
			$("img_holder_2").fx = new Fx.Style($("img_holder_2"), 'opacity', {duration: duration}).start(1);
			visibleDiv = $("img_holder_2");
		}else{
			$("img_fader_src_1").src = newSrc;
			$("img_holder_1").fx = new Fx.Style($("img_holder_1"), 'opacity', {duration: duration}).start(1);
			$("img_holder_2").fx = new Fx.Style($("img_holder_2"), 'opacity', {duration: duration}).start(0);
			visibleDiv = $("img_holder_1");
		}
	}
	function initFaderToggle() {
		if(start+1 < new_faderImages.length) {
			start++;
		} else {
			start = 0;	
		}
		//alert(start+'|'+faderImages.length);
		pathToImage = new_faderImages[start];
		faderToggle(pathToImage,fadeDuration);	
	}
	// start the darn thing
	myhomepageFader = initFaderToggle.periodical(periodicalDuration);
	
});

/* ZODAN Harmonica voor Contactpagina */
window.addEvent('domready', function(){

	var url_hash = "";
	if(window.location.hash) {url_hash = window.location.hash.substring(1);}

	var pitems = $$('.pitem');
	var pitem_count = 0;
	pitems.each(function(item){

		var thisCollapsable = item.getElement( '.harm_collapse' );
		var thisHeader =  item.getElement( '.harm_opener' );
		var toggler = item.getElement( '.toggle' );
		var myCollapsableSlide = new Fx.Slide(thisCollapsable, { duration:400, transition: Fx.Transitions.Bounce.easeInOut});

		if (url_hash.length==0) {
			if(pitem_count != 0) {// only leave the first item open
				myCollapsableSlide.hide();
			} else{
				thisHeader.toggleClass('active');
			}
		} else {
			if(toggler.getProperty('name') == url_hash) { // if url anchor is set, open this one
				myCollapsableSlide.show();
				thisHeader.toggleClass('active');
			} else {
				myCollapsableSlide.hide();
			}	
		}
		pitem_count++;	

		toggler.addEvent('click', function(e){
			e = new Event(e);
			myCollapsableSlide.toggle();
			thisHeader.toggleClass('active');
			e.stop();
		});
	});

}); 


//-->
