﻿/* NAVIGATION 
=============================================*/
function highlightTab(c) { if (typeof (resetMainnavTimeout) != "undefined") { clearTimeout(resetMainnavTimeout) } var b = $(".mainnav").children("A"); for (var a = 0; a < b.length; a++) { if ($(b[a]).attr(c) == 1) { if (c == "hfm") { $(b[a]).addClass("highlightHFM") } else { $(b[a]).addClass("highlight") } } else { $(b[a]).removeClass("highlight"); $(b[a]).removeClass("highlightHFM") } } var d = $(".mainnav").children(".border"); for (var a = 0; a < d.length; a++) { if ($(d[a]).prev("A").hasClass("active") == false && $(d[a]).next("A").hasClass("active") == false) { $(d[a]).removeClass("highlight"); $(d[a]).removeClass("highlightHFM") } if ($(d[a]).attr(c) == 1) { if (c == "hfm") { $(d[a]).addClass("highlightHFM") } else { $(d[a]).addClass("highlight") } } } } function resetMainnav(a) { highlightTab(a) } function showDoormat(b) { if (typeof (resetDoormatTimeout) != "undefined") { clearTimeout(resetDoormatTimeout) } var c = $(".subitem"); for (var a = 0; a < c.length; a++) { if ($(c[a]).attr("itm") == b) { $(c[a]).addClass("highlight") } else { $(c[a]).removeClass("highlight") } } var d = $(".doormat"); for (var a = 0; a < d.length; a++) { if (d[a].getAttribute("doormatID") == b) { $(d[a]).show() } else { $(d[a]).hide() } } } function resetDoormat(a) { resetDoormatTimeout = setTimeout(function() { hideDoormat(a) }, 500) } function hideDoormat(b) { var c = $(".subitem"); for (var a = 0; a < c.length; a++) { if ($(c[a]).attr("itm") == b) { $(c[a]).removeClass("highlight") } } var d = $(".doormat"); for (var a = 0; a < d.length; a++) { if (d[a].getAttribute("doormatID") == b) { $(d[a]).hide() } } };
/* MediaBlock 
=============================================*/
function prevSlide() { var slides = $('#slides').children('.slide'); var aantalSlides = slides.length; for (var i = 0; i < aantalSlides; i++) { if ($(slides[i]).is(":visible")) var currentSlide = slides[i].getAttribute("slideID"); } if (currentSlide > 1) prev = parseInt(currentSlide) - 1; else prev = aantalSlides; $("#slides div.slide").hide(); $("#slides div.slide" + prev).show(); } function nextSlide() { var slides = $('#slides').children('.slide'); var aantalSlides = slides.length; for (var i = 0; i < aantalSlides; i++) { if ($(slides[i]).is(":visible")) var currentSlide = slides[i].getAttribute("slideID"); } if (currentSlide < aantalSlides) next = parseInt(currentSlide) + 1; else next = 1; $("#slides div.slide").hide(); $("#slides div.slide" + next).show(); } function mediablockMouseover() { $(".slidecontainer .btnNext").show(); $(".slidecontainer .btnPrev").show(); $.pause(); } function mediablockMouseout() { $(".slidecontainer .btnNext").hide(); $(".slidecontainer .btnPrev").hide(); $.pause(); }
/* click with enter 
==================================================*/
function doClick(buttonName, e) { var key; if (window.event) { key = window.event.keyCode; } else { key = e.which; } if (key == 13) { var btn = document.getElementById(buttonName); if (btn != null) { newBtnName = buttonName.replace(/_/g, "$"); if (DES_BtnClick(buttonName)) { __doPostBack(newBtnName, e) } event.keyCode = 0 } } } function doButtonClick(buttonName, e) { var key; if (window.event) { key = window.event.keyCode; } else { key = e.which; } if (key == 13) { var btn = document.getElementById(buttonName); if (btn != null) { event.keyCode = 0 } } }
function catchEnter(buttonName, e) { var key; if (window.event) { key = window.event.keyCode; } else { key = e.which; } if (key == 13) { __doPostBack(buttonName, 'javascript');event.keyCode = 0; } }
/* catchEnter needs the following code in ascx.vb
==================================================
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Page.ClientScript.RegisterForEventValidation(<buttonName>.UniqueID, "javascript")
MyBase.Render(writer)
End Sub
*/

/* SEARCHNFFDB
=============================================*/
function searchClose() { $('.searchResults').slideUp(); } function showInPopup(theUrl) { $('.searchResults').hide(); Shadowbox.open({ content: theUrl, player: "iframe", height: 400, width: 600 }); }
function showDiv(divID) {
	if (typeof (resetDivTimeout) != "undefined") { clearTimeout(resetDivTimeout); }
	var div = $('#' + divID); $(div).show();
}
function resetDiv(divID) { resetDivTimeout = setTimeout(function() { hideDiv(divID); }, 500); }
function hideDiv(divID) { var div = $('#' + divID); $(div).hide(); }
function nyroModalAddScrollbar() {
	var body = $('body');
	var bodyHeight = body.height();
	var newHeight = bodyHeight - 118;
	// set styles
	$('.error').css("margin-bottom", "0");
	document.getElementById('modalContent').style.height = newHeight + "px";
	document.getElementById('modalContent').style.overflowY = "scroll";
}
/* SCREENINGS
=============================================*/
function toggleInfoShadowBox(nr) {
	toggleInfo('infoDiv_' + nr);
	ShadowBoxFitHeight(440);
	setTimeout(function() { ShadowBoxFitHeight(440); }, 100);
}
function toggleInfo(id) {
	var elem = document.getElementById(id);
	if (elem.style.display == 'none') {
		elem.style.display = '';
	} else {
		elem.style.display = 'none';
	}
}

/* GENERAL
=============================================*/
function urlencode(string) { var hash_map = {}, symbol = '', tmp_str = '', entity = ''; tmp_str = string.toString(); hash_map["#"] = '%23'; hash_map["'"] = '%27'; hash_map[":"] = '%3A'; hash_map["!"] = '%21'; for (symbol in hash_map) { entity = hash_map[symbol]; tmp_str = tmp_str.split(symbol).join(entity); } return tmp_str; }
function encodeString(str) {
	var encodedStr = escape(str);
	encodedStr = encodedStr.replace("+", "%2B");
	encodedStr = encodedStr.replace("/", "%2F");
	return encodedStr;
}

/* MEDIABLOK
=============================================*/
function showMedia(inType, inUrl) {
	var playerType = "swf";
	if (inType == "page") { document.location.href = inUrl } else {
		if (inType == "video") {
			
			if (inUrl.indexOf("watch?v=") > -1) {
				//alert("yt");
				var newUrl = inUrl.replace(new RegExp("watch\\?v=", "i"), "v/")
				playerType = "flv"
			} else if (inUrl.indexOf("vimeo") > -1) {
				//alert("vi");
				newUrl = inUrl;
				playerType = "iframe"
			} else if (inUrl.indexOf("youtu") > -1) {
				newUrl = inUrl;
				playerType = "flv"
			} else if (inUrl.indexOf("http://") == -1) {
				//alert("other");

				// for now we assume a vimeo id is an integer, and all others are youtubes by default
				if(is_int(inUrl)) {
					newUrl = "http://player.vimeo.com/video/" + inUrl;
					playerType = "iframe";
				} else {
					newUrl = "http://www.youtube.com/v/" + inUrl + "&hl=nl_NL&fs=1&hd=1&autoplay=1";
					playerType = "flv";
				}
			} else { var newUrl = inUrl }

			//	alert(playerType);
			Shadowbox.open({ content: newUrl, player: playerType, title: "Video", height: 630, width: 880 })
		} 
	} return false
};

function is_int(value) {
	if ((parseFloat(value) == parseInt(value)) && !isNaN(value)) {
		return true;
	} else {
		return false;
	}
}

/* FLICKR
==================================================*/
function flickrJson(photosetid, divid, gallery) {
	var cnt = 0;
	$.getJSON("http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=4e92e4fb6a7cc33d617d00a133cc1741&photoset_id=" + photosetid + "&format=json&jsoncallback=?", function (data) {
		$.each(data.photoset.photo, function (i, item) {
			cnt++;
			var sourceSquare = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_s.jpg';
			var sourceBig = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg';
			$("<img/>").attr("src", sourceSquare).attr("width", 75).attr("height", 75).attr("alt", item.title).appendTo("#" + divid).wrap("<a href='" + sourceBig + "' title='" + item.title + "' id='flickrlink" + cnt + "'></a>");
			Shadowbox.setup("a#flickrlink"+cnt, { title: item.title });
		});
	});
}


