<!--
/**
 * @author Johan Huijkman, Eden design & communication
 */
//	:::::::::::::::::::::::::::::: start MENU functionality
var currentX = 0;
var currentY = 0;

HTMMenu = {
	sectionLabels: ["reisinfo","zakelijk", "overhtm","mijnhtm"],
	sections:new Array(),
	currentSection: -1,
	activeItem: null,
	hideTimer: null,
	hide: function(item){
		item.className = item.className.replace('js-hover','js-idle');
		var sub = item.sub;
		sub.className = sub.className.replace('js-show','hide');
		if(item.parentNode.id != HTMMenu.sectionLabels[HTMMenu.currentSection]&&HTMMenu.currentSection>=0){
			var it = HTMMenu.sections[HTMMenu.currentSection].item.parentNode;
			it.className = it.className.replace('ro-meta','js-idle');
		}
	}
};
//	:::::::::::::::::::::::::::::: end MENU functionality

//	:::::::::::::::::::::::::::::: start onload function calls
jQ(document).ready(function() {	
//	:::::::::::::::::::::::::::::: start MENU functionality	
	//Set currentSection:
	jQuery.each(HTMMenu.sectionLabels, function() {
	  if(jQ("body:first").hasClass(this)){
	  	HTMMenu.currentSection = jQuery.inArray(this, HTMMenu.sectionLabels);
	  }
    });
	
	// hover subnavigatie;
	// change class show, if present, to hide:
	jQ('.subnavigatie').each(function(){
		HTMMenu.sections[jQ('.subnavigatie').index(this)] = this;
		jQ(this).removeClass("show").addClass("hide");
		this.onmouseover = function(){
			clearTimeout(HTMMenu.hideTimer);
			HTMMenu.activeItem = this.item;
		};
		this.onmouseout = function(){
			var current = this.item;
			HTMMenu.hideTimer = setTimeout(function(){HTMMenu.hide(current)},1000);
		};
	})
	
	// hover menu-items:
	jQ('.hoofdnavigatie li a').each(function(){
		this.className += ' js-idle';
		this.sub = HTMMenu.sections[jQ('.hoofdnavigatie li a').index(this)];
		if(this.sub != undefined){
			this.sub.item = this;
			this.onmouseover = function(){
				clearTimeout(HTMMenu.hideTimer);
				if(HTMMenu.activeItem!=null) HTMMenu.hide(HTMMenu.activeItem);
				this.sub.className = this.sub.className.replace('hide','js-show');
				this.className = this.className.replace('js-idle','js-hover');
				HTMMenu.activeItem = this;
				if(this.parentNode.id != HTMMenu.sectionLabels[HTMMenu.currentSection]&&HTMMenu.currentSection>=0){
					var it = HTMMenu.sections[HTMMenu.currentSection].item.parentNode;
					it.className = 'ro-meta';
				}			
			};
			this.onmouseout = function(){
				var current = this;
				HTMMenu.hideTimer = setTimeout(function(){HTMMenu.hide(current)},1000);
			};
		}
		
	});
//	:::::::::::::::::::::::::::::: end MENU functionality

//	:::::::::::::::::::::::::::::: start show/hide functionality	
	//Toon-verberg functionaliteit:
	jQ('.item-content').each(function(){
		if(jQ(this).hasClass('show')){
			jQ(this).before('<a class="toon-verberg verberg" href="[link]" tabindex="#">Verberg info</a>');
		}
		if(jQ(this).hasClass('hide')){
			jQ(this).before('<a class="toon-verberg toon" href="[link]" tabindex="#">Toon info</a>');
		}
	});
	
	jQ('.toon-verberg').prev().click(function(){ 
		if(jQ(this).next().hasClass('verberg')){
			jQ(this).next().removeClass('verberg').addClass('toon');
			jQ(this).next().next().removeClass('show').addClass('hide');
		}else if(jQ(this).next().hasClass('toon')){
			jQ(this).next().removeClass('toon').addClass('verberg');
			jQ(this).next().next().removeClass('hide').addClass('show');
		}
	});
	
	jQ('.toon-verberg').click(function(){ 
		if(jQ(this).hasClass('verberg')){
			jQ(this).removeClass('verberg').addClass('toon');
			jQ(this).next().removeClass('show').addClass('hide');
			//jQ(this).next().hide("fast");
		} else if(jQ(this).hasClass('toon')){
			jQ(this).removeClass('toon').addClass('verberg');
			jQ(this).next().removeClass('hide').addClass('show');
			//jQ(this).next().show("normal");
		}
		return false;
	});
	
	// meerinfoblok functionaliteit:	
	//class '.abcdefg' separates the '.moreinfoblok' links from other kind of '.meerinfo' links
	jQ('.meerinfoblok').each(function(){
		jQ(this).before('<a href="[link]" class="meerinfo abcdefg" tabindex="#">Meer info</a>');
	});
	jQ('a.meerinfo.abcdefg').hover(function(){ 
		if(jQ(this).next().hasClass('hide')){
			jQ(this).next().removeClass('hide').addClass('show');
		}
	}, function(){
		if(jQ(this).next().hasClass('show')){
			jQ(this).next().removeClass('show').addClass('hide');
		}
	});
	
	// meerinfobutton
	jQ('a.meerinfo').each(function(){
		if(jQ(this).hasClass('abcdefg')) return;
		else{			
			jQ(this).hover(function(){
				jQ(this).parents().each(function(){
					if(jQ(this).hasClass('item-content')){
						jQ(this).next().removeClass('hide').addClass('show');
						return;
					}
				})
			}, function(){
				jQ(this).parents().each(function(){
					if(jQ(this).hasClass('item-content')){
						jQ(this).next().removeClass('show').addClass('hide');
						return;
					}
				})
			})
		}
	});

//	:::::::::::::::::::::::::::::: End show/hide functionality	

//	:::::::::::::::::::::::::::::: Start hover functionality	
	//hover submit knoppen:
	jQ(':image').each(function(){
		jQ(this).hover(function() {
			jQ(this).attr('src',jQ(this).attr('src').replace('.gif','_ro.gif'));
		}, function() {
			jQ(this).attr('src',jQ(this).attr('src').replace('_ro.gif','.gif'));
		});
	});
	
	// click 'lees verder' links:
	jQ('a.verder').each(function () { 
		this.parentNode.parentNode.className += ' js-idle';
		this.parentNode.parentNode.a = this;
		this.parentNode.parentNode.onclick = function(){
			document.location = this.a.href;
		};
		this.parentNode.parentNode.onmouseover = function(){
			this.className = this.className.replace(' js-idle',' item-ro');
		};
		this.parentNode.parentNode.onmouseout = function(){
			this.className = this.className.replace(' item-ro',' js-idle');
		};
	});
	// hover keuzeblok:
	jQ('.keuzeblok').each(function () { 
		jQ(this).hover(function() {
			jQ(this).addClass('item-ro');
		}, function() {
			jQ(this).removeClass('item-ro');
		});
		this.onclick = function(){
			document.location = this.getElementsByTagName('a')[0].href;
		};
	});
	// hover .ok-knop:
	jQ('.ok-knop').each(function () { 
		jQ(this).hover(function() {
			jQ(this).addClass('input-ro');
		}, function() {
			jQ(this).removeClass('input-ro');
		});
	});
//	:::::::::::::::::::::::::::::: End hover functionality	

//	:::::::::::::::::::::::::::::: Start Timetable Dropdown functionality	
	if(jQ('#time-dropdown')){
		jQ('#cnt-table .item-info').prepend("<div id='time-options'></div>");
		jQ('#time-options').val("FALSE");
		jQ('#time-dropdown option').each(function () { 
			jQ('#time-options').append('<a href="">'+ jQ(this).html() +'</a>');				
		});
		jQ('#time-dropdown option:selected').each(function(){
			jQ('#time-dropdown').append('<ul><li id="time-selected">' + jQ(this).html() + '</li></ul>');
			jQ('#time-selected').click(function(){
				if(jQ('#time-options').css('display')=='block'){
					jQ('#time-options').val("FALSE");
					jQ('#time-options').hide();						
				}else{
					jQ('#time-options').val("TRUE");
					jQ('#time-options').show();
				}			
			});
		});
		jQ('#time-options a').click(function(){
			var i = jQ('#time-options a').index(this);			
			document.getElementById('time-dropdown').getElementsByTagName('select')[0].options[i].selected = "selected";
			jQ('#time-selected').html(jQ(this).html());
			jQ('#time-options').hide();
			return false;
		});
		jQ(document).click(function(){
			if(jQ('#time-options').val()=="FALSE") jQ('#time-options').hide();
			jQ('#time-options').val("FALSE");
		});
	}
	if(jQ('#day-dropdown')){
		jQ('#cnt-table .item-info').prepend("<div id='day-options'></div>");
		jQ('#day-options').val("FALSE");
		jQ('#day-dropdown option').each(function () { 
			jQ('#day-options').append('<a href="">'+ jQ(this).html() +'</a>');
		});
		jQ('#day-dropdown option:selected').each(function(){
			jQ('#day-dropdown').append('<ul><li id="day-selected">' + jQ(this).html() + '</li></ul>');
			jQ('#day-selected').click(function(){
				if(jQ('#day-options').css('display')=='block'){
					jQ('#day-options').val("FALSE");
					jQ('#day-options').hide();						
				}else{
					jQ('#day-options').val("TRUE");
					jQ('#day-options').show();
				}				
			});
		});
		jQ('#day-options a').click(function(){
			var i = jQ('#day-options a').index(this);			
			document.getElementById('day-dropdown').getElementsByTagName('select')[0].options[i].selected = "selected";
			jQ('#day-selected').html(jQ(this).html());
			jQ('#day-options').hide();
			return false;
		});
		jQ(document).click(function(){
			if(jQ('#day-options').val()=="FALSE") jQ('#day-options').hide();
			jQ('#day-options').val("FALSE");
		});
	}
	
//	:::::::::::::::::::::::::::::: End Timetable Dropdown functionality	

//	:::::::::::::::::::::::::::::: Start 'Bewaren' function calls	
	
	jQ('#ok-knop-bewaarroute').click(function(){
		HTMSaveBlock.show(this);
		return false;
	});
	jQ('#ok-knop-bewaarroute-metnaam').click(function(){
		HTMSaveBlock.show(this);
		return false;
	});
	jQ('#routebewaarbutton').click(function(){
		HTMSaveBlock.show(this);
		return false;
	});
	jQ('.bewaarblok input[value="Annuleer"]').click(function(){
		jQ('.bewaarblok').hide();
		HTMModalScreen.hide();
		return false;
	});
//	:::::::::::::::::::::::::::::: End 'Bewaren' function calls
	
	HTMLijnenDropDown.init();
	// HTMHaltesDropDown.init();
	HTMTitleHover.init();
	
	HTMSitemap.init();
	HTMFoldingLists.init();
	HTMPriceTable.init();
});

//	:::::::::::::::::::::::::::::: end onload function calls

//	:::::::::::::::::::::::::::::: Start 'Bewaren' function
HTMSaveBlock = {
	show:function(ref){
		var w = jQuery.browser.msie ? 350 : 333;
		var h = ref.id == 'ok-knop-bewaarroute-metnaam' ? 95: 55;
		
		var x = Essentials.findElementPosition(ref)[0]-w;
		var y = Essentials.findElementPosition(ref)[1]-h;
		jQ('body').append(jQ('.bewaarblok').clone(true).attr('id','currentSaveBlock').css({top:y+"px",left:x+"px"}).show());		
		jQ('#currentSaveBlock .ok-knop').each(function(){
			if(jQ(this).val().toLowerCase()=='ok') jQ(this).focus();
		})
		HTMModalScreen.show();
	}
}
//	:::::::::::::::::::::::::::::: End 'Bewaren' function

//	:::::::::::::::::::::::::::::: Start modal screen functionality
HTMModalScreen = {
	init:function(){
		//create modal screen
		if(jQ('#modal-screen').length == 0) jQ('body').append('<div id="modal-screen"></div>');
		//create iframe mask
		if (jQ('#modal-mask').length == 0 && jQuery.browser.msie) {
			jQ('body').append('<iframe id="modal-mask" src="../../images/htmweb/algemeen/iframe-fake-src.gif"></iframe>');
		}
	},
	sizing:function(){
		var h = jQ('#header-zone').height()+jQ('#hoofd-zone').height();
		jQ('#modal-screen').height(h);
		if(jQuery.browser.msie) jQ('#modal-mask').height(h);
		
		var w = jQ('body').width()<760 ? 760 : jQ('body').width();
		jQ('#modal-screen').width(w);
		if(jQuery.browser.msie) jQ('#modal-mask').width(w);
	},
	show:function(){	
		HTMModalScreen.init();
		HTMModalScreen.sizing();
		jQ('#modal-screen').show();
		if(jQuery.browser.msie) jQ('#modal-mask').show();
		jQ(window).bind("resize", function(){
			HTMModalScreen.sizing();
		});
	},
	hide:function(){				
		jQ('#modal-screen').hide();
		if(jQuery.browser.msie) jQ('#modal-mask').hide();
		jQ(window).unbind("resize", function(){
			HTMModalScreen.sizing();
		});
	}	
}
//	:::::::::::::::::::::::::::::: Start Lijnennet dropdown functionality
HTMLijnenDropDown = {
	options : {},
	optionGroups :  { 	"Attracties":"attracties", "Musea":"musea", "Theaters":"theaters",
						"Kerk":"kerken", "Winkelgebieden":"winkelgebieden", "Ziekenhuis":"ziekenhuizen",
						"HTM Verkooppunt":"htm-verkooppunten", "NS Station":"ns-stations"	},
	optionGroupsHTML : new Array(),
	init:function(){
		jQ('#object').after('<select id="temp-dropdown"></select>');
		jQ('#temp-dropdown').hide();
		
		// create one dropdwon for each optiongroup:
		jQ('#object optgroup').each(function(){
			var curr = jQ(this).attr("label");
			var linkHtml = '<a href="[link]" id="'+HTMLijnenDropDown.optionGroups[curr]+'" title="'+HTMLijnenDropDown.optionGroups[curr]+'">'+curr+'</a>';
			jQ('#object').before(linkHtml);
			jQ('#object').hide();
			HTMLijnenDropDown.optionGroupsHTML[curr] = jQ(this).html();	
			jQ('#'+HTMLijnenDropDown.optionGroups[curr]).click(function(){
				jQ('.current').removeClass('current');
				jQ(this).addClass('current');
				jQ('#temp-dropdown').html(HTMLijnenDropDown.optionGroupsHTML[jQ(this).html()]);
				jQ('#temp-dropdown').change();
				return false;
			})
			if(jQ('#object optgroup').index(this) == 0) {
				jQ('#'+HTMLijnenDropDown.optionGroups[curr]).addClass('current');
				jQ('#temp-dropdown').html(jQ(this).html());
				jQ('#temp-dropdown').show();		
			}
			
		})
		// make same selection in hidden humonguous dropdown:
		jQ('#temp-dropdown').change(function(){
			if(jQ('#temp-dropdown option:selected').length<=0) jQ('#object option[value='+jQ('#temp-dropdown option:first').val()+']').attr('selected','selected');
			else {
				jQ('#temp-dropdown option:selected').each(function(){
					jQ('#object option[value='+jQ(this).val()+']').attr('selected','selected');
				})	
			}			
		})
		jQ('#temp-dropdown').change();	
	}	
}
//	:::::::::::::::::::::::::::::: End Lijnennet dropdown functionality

//	:::::::::::::::::::::::::::::: Start Lijnennethaltes dropdown functionality
/* HTMHaltesDropDown = {
	options : {},
	optionGroupsHTML : new Array(),
	init:function(){
		jQ('#halte').after('<select id="temp-dropdown1" style="clear:both;" onclick="SetActivePanel(4)"></select>');
		jQ('#temp-dropdown1').hide();
		
		// create one dropdwon for each optiongroup:
		jQ('#halte optgroup').each(function(){
			var curr = jQ(this).attr("label");
			var linkstr = new String(curr);
			var linklist = linkstr.split(";");
			
			var linkid = 'lijn'+linklist[2]+'-'+linklist[3];
			var linkclass = linklist[0];
			var linktitle = 'Richting '+linklist[4];
			var linktext = linklist[1];
			
			var linkHtml = '<a href="[link]" id="'+linkid+'" class="krt'+linkclass+'" title="'+linktitle+'">'+linktext+'</a>';
			jQ('#halte').before(linkHtml);
			jQ('#halte').hide();	
			HTMHaltesDropDown.optionGroupsHTML[linkid] = jQ(this).html();
			jQ('#'+linkid).click(function(){
				jQ('.current').removeClass('current');
				jQ(this).addClass('current');
				jQ('#temp-dropdown1').html(HTMHaltesDropDown.optionGroupsHTML[linkid]);
				jQ('#temp-dropdown1').change();
				return false;
			})
			if(jQ('#halte optgroup').index(this) == 0) {
				jQ('#'+linkid).addClass('current');
				jQ('#temp-dropdown1').html(jQ(this).html());
				jQ('#temp-dropdown1').show();		
			}						
			
		})
		// make same selection in hidden humonguous dropdown:
		jQ('#temp-dropdown1').change(function(){
			if(jQ('#temp-dropdown1 option:selected').length<=0) jQ('#halte option[value='+jQ('#temp-dropdown1 option:first').val()+']').attr('selected','selected');
			else {
				jQ('#temp-dropdown1 option:selected').each(function(){
					jQ('#halte option[value='+jQ(this).val()+']').attr('selected','selected');
				})	
			}			
		})
		jQ('#temp-dropdown1').change();
	}	
}*/
//	:::::::::::::::::::::::::::::: End Lijnennethaltes dropdown functionality

//	:::::::::::::::::::::::::::::: Start Lijnennet title hover functionality
HTMTitleHover = {
	init : function(){
		jQ('.lijnen-blok').after('<div id="lijn-titel"></div>');
		jQ('.lijnen-blok a').each(function(){
			this.onmouseover = function(){
				document.getElementById("lijn-titel").innerHTML = this.title;
			}
			this.onmouseout = function(){
				document.getElementById("lijn-titel").innerHTML = '';
			}
		})
	}
}
//	:::::::::::::::::::::::::::::: End modal title hover functionality
//	:::::::::::::::::::::::::::::: Start sitemap functionality
HTMSitemap = {
	init : function(){
		jQ('ul.site-structure ul').each(function(){
			if(jQ(this).parent().get(0).tagName.toLowerCase() == 'li'){
				jQ(this).parent().addClass('sub');
				if(this.parentNode.firstChild.className == 'uit'){
					jQ(this).parent().prepend('<span class="toggle-btn min"></span>');
					jQ(this).show();
				}else{
					jQ(this).parent().prepend('<span class="toggle-btn plus"></span>');
				}
			}			
		});
		jQ('ul.site-structure span.min, ul.site-structure span.plus').hover(function(){
			jQ(this).addClass('hover');
		}, function(){
			jQ(this).removeClass('hover');
		});
		jQ('ul.site-structure span.toggle-btn').click(function(){
			if (jQ(this).hasClass('min')) {
				this.className = this.className.replace('min', 'plus');
				jQ(this).parents('li').children('ul:first').hide("fast");
				jQ(this).next().removeClass('uit').addClass('in');
			} else {
				this.className = this.className.replace('plus', 'min');
				jQ(this).parents('li').children('ul:first').show("fast");
				jQ(this).next().removeClass('in').addClass('uit');
			}
			return false;
		})
	}
}
//	:::::::::::::::::::::::::::::: End sitemap functionality

//	:::::::::::::::::::::::::::::: Start harmonica lists functionality
HTMFoldingLists = {
	init : function(){
		jQ('ul.lijst ul, ul.lijst div.subTekst').each(function(){
			if (jQ(this).parent().get(0).tagName.toLowerCase() == 'li') {
				if (this.parentNode.firstChild.className == 'uit') {
					jQ(this).show();
				}
				this.parentNode.firstChild.className += ' toggle-btn';
			}
		});
		jQ('ul.lijst a.toggle-btn').click(function(){
			if (jQ(this).hasClass('uit')) {
				this.className = this.className.replace('uit', 'in');
				jQ(this).next().hide("fast");
				if(jQ(this).next().next()){jQ(this).next().next().hide("fast");}
			} else {
				this.className = this.className.replace('in', 'uit');
				jQ(this).next().show("fast");
				if(jQ(this).next().next()){jQ(this).next().next().show("fast");}
			}
			return false;
		})
	}
}
//	:::::::::::::::::::::::::::::: End harmonica lists functionality

//	:::::::::::::::::::::::::::::: Start 'info-prijs' functionality
HTMPriceTable = {
	init : function(){
		$('div.info-prijs td.info-btn').each(function(){
			if($('div#info-prijs-hover').length<=0){
				$('body:first').append('<div id="info-prijs-hover"></div>');
			}
			var parentTable = $(this).parents('table');
			var textCell = $(this).next('td.info-text');
			
							
			$(this).children('span.meerinfo').hover(function(){
				var xPos = Essentials.findElementPosition(this)[0]-318;
				var yPos = Essentials.findElementPosition(this)[1]+$(this).height()+5;
				$('div#info-prijs-hover').html(textCell.text());
				$('div#info-prijs-hover').css({top: yPos+'px', left: xPos+'px'});
				$('div#info-prijs-hover').show();
				
			}, function(){
				$('div#info-prijs-hover').hide();
			})
		})
		$('input.info-prijs-toggle').each(function(){
			var infoDiv = $(this).parents('div.tt-functs').next('div.info-prijs');
			$(this).click(function(){
				if(infoDiv.hasClass('hide')) infoDiv.removeClass('hide').addClass('show');
				else if(infoDiv.hasClass('show')) infoDiv.removeClass('show').addClass('hide');
				else if(infoDiv.css('display') == 'block') infoDiv.addClass('hide');
				else if(infoDiv.css('display') == 'none') infoDiv.addClass('show');
				
				//change label according to state:
				if(infoDiv.css('display') == 'block') $(this).attr('value', $(this).attr('value').replace('Toon','Verberg'));
				else if(infoDiv.css('display') == 'none') $(this).attr('value', $(this).attr('value').replace('Verberg','Toon'));
				
				return false;
			});
		})
	}
}

//	:::::::::::::::::::::::::::::: End 'info-prijs' functionality

Essentials = {
	findElementPosition : function (elem){
		var curleft = curtop = 0;
		if (elem.offsetParent) {
		
			curleft = elem.offsetLeft
			curtop = elem.offsetTop
			while (elem = elem.offsetParent) {
				curleft += elem.offsetLeft
				curtop += elem.offsetTop
			}
		}
		return [curleft,curtop];
	}
}
//-->
