﻿/* Open/Close SlideDiv in FilmsOnRSS 
=============================================*/
function showAllFilms(id) {
	// show all films
	$("#slideDiv_" + id).slideDown();

	// show other link
	var links = $("#slideLinks_" + id).children("A");
	for (var i = 0; i < links.length; i++) {
		if ($(links[i]).attr("action") == "open") $(links[i]).hide();
		if ($(links[i]).attr("action") == "close") $(links[i]).show();
	}
}

function showTwoFilms(id) {
	// show only first two films
	$("#slideDiv_" + id).slideUp();

	// show other link
	var links = $("#slideLinks_" + id).children("A");
	for (var i = 0; i < links.length; i++) {
		if ($(links[i]).attr("action") == "open") $(links[i]).show();
		if ($(links[i]).attr("action") == "close") $(links[i]).hide();
	}
}
/* Films On RSS 2011
=============================================*/
$(document).ready(function () {
	$(".for-top").click(function () {
		if ($(this).next().is(':hidden')) {
			$(".for-top").each(function () {
				$(this).next().hide('fast');
				$(this).removeClass("for-active");
			});
			// open
			$(this).next().slideDown('fast');
			$(this).addClass("for-active");
		} else {
			// close
			$(this).next().hide('fast');
			$(this).removeClass("for-active");
		}
	});

});

/* SHFilmMemories
=============================================*/
function closeMemory() {
    document.getElementById('memory_view').style.display = 'none';
    document.getElementById('popup-bgr').style.display = 'none';
}

function closeMemoryAdd() {
    document.getElementById('memory_add').style.display = 'none';
    document.getElementById('popup-bgr').style.display = 'none';
}

function showMemory(name, title, text, pin) {
    document.getElementById('view_pin').className = "pin pin"+pin;
    document.getElementById('view_name').innerHTML = unescape(name);
    document.getElementById('view_title').innerHTML = unescape(title);
    document.getElementById('view_text').innerHTML = unescape(text);
    
    var scrollPosTop = 0;
    scrollPosTop = window.pageYOffset;
    if (scrollPosTop == 0 || typeof scrollPosTop == "undefined") scrollPosTop = document.documentElement.scrollTop;
    document.getElementById('memory_view').style.top = ((document.body.offsetHeight - 413) / 2 + scrollPosTop) + "px";
    document.getElementById('memory_view').style.display = '';

    var ie7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
    if (!ie7) {
        document.getElementById('popup-bgr').style.display = '';
        document.getElementById('popup-bgr').style.height = (document.body.offsetHeight + scrollPosTop) + "px";
        document.getElementById('popup-bgr').setAttribute('onclick', 'closeMemory();');
    }
}

function showMemoryAdd() {
    var pin = Math.floor(Math.random() * 3) + 1;
    document.getElementById('add_pin').className = "pin pin" + pin;
    document.getElementById('memory_add').style.top = ((document.body.offsetHeight - 413) / 2) + "px";
    document.getElementById('memory_add').style.display = '';
    document.getElementById('popup-bgr').style.display = '';
    document.getElementById('popup-bgr').setAttribute('onclick', 'closeMemoryAdd();');
}

function validateMemoryAdd(name, title, text) {
    var alertMsg = "";
    if (document.getElementById(name).value == "") alertMsg += "- Jouw naam\n";
    if (document.getElementById(title).value == "") alertMsg += "- Titel herinnering (kort)\n";
    if (document.getElementById(text).value == "") alertMsg += "- Herinnering\n";

    if (alertMsg != "") {
        alert("De volgende velden zijn verplicht:\n"+alertMsg);
        return false;
    }
    else return true;
}
