﻿/* menu 
==================================================*/
var openMenuId = ""
var closingMenuId = "";
var timer = 0;
var prevClass = -1;
var hilitedLinkID = "";
var prefix = "ctl00_hdrMain_ucMainMenu_"
var defaultI = -1;

function sm(i, defI) {
	var menuID = (prefix + 's' + i); var linkID = (prefix + 'l' + i); if (defaultI == -1) { defaultI = defI; }
	if (openMenuId != "") {
		if (timer) { closingMenuId = ""; clearTimeout(timer); timer = null; }
		if (openMenuId != menuID) { closeMenu(openMenuId); }
	}
	popupMenu = document.getElementById(menuID); if (popupMenu) {
		defaultMenu = document.getElementById(prefix + 's' + defaultI); if (defaultMenu) { defaultMenu.style.display = 'none'; }
		popupMenu.style.display = '';
	}
	openMenuId = menuID; link = document.getElementById(linkID); if (link) {
		if (link.className != "" && prevClass == -1) { prevClass = link.className; }
		else if (prevClass == -1) { prevClass = ""; }
		link.className = 'selected'; hilitedLinkID = linkID;
	}
}
function hm(i) {
	var menuID = (prefix + 's' + i); var linkID = (prefix + 'l' + i); if (timer) { clearTimeout(timer); }
	closingMenuId = menuID; if (document.getElementById(menuID)) { timer = setTimeout("hideMenu()", 2000); }
	else { hideMenu(); }
}
function sm2(i, defI) {
	var menuID = (prefix + 's' + i); if (defaultI == -1) { defaultI = defI; }
	if (timer) { clearTimeout(timer); closingMenuId = ""; timer = null; }
	if (openMenuId == "") {
		popupMenu = document.getElementById(menuID); if (popupMenu) {
			defaultMenu = document.getElementById(prefix + 's' + defaultI); if (defaultMenu) { defaultMenu.style.display = 'none'; }
			popupMenu.style.display = '';
		}
		openMenuId = menuID;
	}
}
function hm2() { if (openMenuId != "") { closingMenuId = openMenuId; timer = setTimeout("hideMenu()", 2000); } }
function hideMenu() { if (closingMenuId != "") closeMenu(closingMenuId); }
function closeMenu(menuID) {
	popupMenu = document.getElementById(menuID); if (popupMenu) { popupMenu.style.display = 'none'; openMenuId = ""; }
	if (defaultI > -1) { defaultMenu = document.getElementById(prefix + 's' + defaultI); if (defaultMenu) { defaultMenu.style.display = ''; } }
	if (hilitedLinkID != "") {
		link = document.getElementById(hilitedLinkID); if (link && prevClass != -1) { link.className = prevClass; prevClass = -1; }
		hilitedLinkID = "";
	}
}

/* Scripts for page load...
==================================================*/
$(document).ready(function() {

	// tooltips op alle elementen met de class .tooltip
	tooltip();

	// op alle elementen met class .bar wordt deze functie op de onclick
	// handlers gezet
	$('.toggleblock').find('.bar').each(function() {
		var bar = $(this);
		var pnl = bar.next();
		var img = bar.find('img');
		var controlid = bar.parent().attr("ctrlid");
		/*
		alert(controlid + ": " + $.cookie(controlid));

		//alert(controlid + ': ' + $.cookie(controlid));

		if (pnl.attr("forced") != "true") {
			if ($.cookie(controlid)) {
				if ($.cookie(controlid) == "closed") {
					if (!pnl.is(":hidden")) {
						pnl.hide();
						img.attr('src', '/sites/shared/images/arrow_right_grey.gif');
					}
				} else {
					if (pnl.is(":hidden")) {
						pnl.show();
						img.attr('src', '/sites/shared/images/arrow_down_grey.gif');
					}
				}
			}
		} else {
			//alert(pnl.attr("forced"));
		}
        */
	});

	$('.toggleblock').find('.bar').click(function() {
		// het panel is het volgende element in de dom gezien vanaf het geklikte element
		var pnl = $(this).next();
		// de afbeelding in het element opzoeken
		var img = $(this).find('img');

		// het id van het control waar op geklikt is
		var controlid = $(this).parent().attr("ctrlid");

		// kijk of het panel zichtbaar is of niet (daarom moet een niet zichtbaar panel niet serversize onzichtbaar gemaakt worden)
		if (!pnl.is(":hidden")) {
			pnl.slideUp("slow");
			img.attr('src', '/sites/shared/images/arrow_right_grey.gif');
			//alert('dicht: ' + controlid);
			$.cookie(controlid, 'closed', { expires: 7 });
		} else if (pnl.is(":hidden")) {
			pnl.slideDown("slow");
			img.attr('src', '/sites/shared/images/arrow_down_grey.gif');
			//alert('open: ' + controlid);
			$.cookie(controlid, 'open', { expires: 7 });
		} else {
			alert("Control moet attribuut 'display: none' hebben, niet Visible='false'");
		}
	});

	// op alle elementen met class .slideintro wordt deze functie op de onclick
	// handlers gezet
	$(document).find('.slideintro').click(function() {

		if ($(this).attr("link") == "back") {
			var lblContinue = $(this).next();
			var lblLong = $(this).prev();
			var lblShort = lblLong.prev();
			lblLong.slideUp("slow");
			lblShort.show();
			$(this).hide();
			lblContinue.show();
		}
		else if ($(this).attr("link") == "continue") {
			var lblBack = $(this).prev();
			var lblLong = lblBack.prev();
			var lblShort = lblLong.prev();
			lblShort.hide();
			lblLong.slideDown("slow");
			$(this).hide();
			lblBack.show();
		}
	});

	// op alle elementen met class .slidelink wordt deze functie op de onclick
	// handlers gezet
	$(document).find('.slidelink').click(function() {

		if ($(this).attr("link") == "hide") {
			var pnlText = $(this).prev();
			var lblHide = $(this);
			var lblShow = pnlText.prev();
			pnlText.slideUp("slow", function() {
				lblHide.hide();
				lblShow.show();
			});
		}
		else if ($(this).attr("link") == "show") {
			var pnlText = $(this).next();
			var lblHide = pnlText.next();
			$(this).hide();
			pnlText.slideDown("slow", function() {
				lblHide.show();
			});
		}
    });

    // op alle elementen met class .contentSlider wordt deze functie op de onclick
    // handlers gezet
    $('.contentSlider').click(function() {
        var pnl = $(this).prev();
        if (pnl.is(":hidden")) {
            pnl.slideDown("slow");
            $(this).html(txt5);
        } else {
            pnl.slideUp("slow");
            $(this).html(txtall);
        }       
    });
	
});

/* Star rating 
==================================================*/
function hideAllStars() { for (i = 1; i <= 5; i++) { hideStar(i); } }
function showStar(number) {
	clearInterval(myInterval); top = number; for (i = 1; i <= number - 1; i++) { var obj = document.getElementById(eval("star" + i)); obj.src = "/shared/images/ster_rood.gif"; }
	var obj = document.getElementById(eval("star" + number)); obj.src = "/shared/images/ster_geel.gif"; for (i = 5; i > number; i--) { hideStar(i); }
}
function hideStar(number) { var obj = document.getElementById(eval("star" + number)); obj.src = "/shared/images/ster_wit.gif"; }
function hideStars() { myInterval = window.setInterval(function(a, b) { hideStar(top); top = top - 1; if (top == 0) { clearInterval(myInterval); } }, 5); }

/* click with enter 
==================================================*/
function doClick(buttonName, e) {
	//the purpose of this function is to allow the enter key to 
	//point to the correct button to click.
	var key;
	if (window.event) {
		key = window.event.keyCode;     //IE
	} else {
		key = e.which;      //firefox
	}
	if (key == 13) {
		//Get the button the user wants to have clicked
		var btn = document.getElementById(buttonName);
		if (btn != null) { //If we find the button click it
			newBtnName = buttonName.replace(/_/g, "$");
			if (DES_BtnClick(buttonName)) {
				__doPostBack(newBtnName, e)
			}
			event.keyCode = 0
		}
	}
}
