﻿/************************************
    Dynform functies
************************************/
function LoadPageLoading()
{
	// only show if a) no client-side validation or b) client-side validation is ok
    if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
    {
		var winl = Math.round((document.body.clientWidth - 300) / 2);
		var wint = document.body.scrollTop + Math.round((document.body.clientHeight - 100) / 2);
				
		document.getElementById("pageLoading").style.left = winl;
		document.getElementById("pageLoading").style.top  = wint;
		
		document.getElementById("pageLoading").style.visibility = 'visible';
	
		//RemoveDiv('false');
		
	}
}

function RemoveDiv(bool)
{

	if(bool == 'true')
	{
		if(document.getElementById("pageLoading") != null)
			document.getElementById("pageLoading").style.display = 'none';
	}
	else
	{
		if(document.getElementById("pageLoading") != null)
			document.getElementById("pageLoading").style.display = 'block';
	}
	
	this.setTimeout("RemoveDiv('true')",1000);
}

// Form input verwijderen
function ResetForm()
{
    var texts = document.getElementsByTagName('input')
    for (var i_tem = 0; i_tem < texts.length; i_tem++)
    {
        if (texts[i_tem].type == 'text')
            texts[i_tem].value = ''
    }
}

/************************************
    jQuery
************************************/
// jQuery custom selector for asp.net controls, see http://john-sheehan.com/blog/index.php/custom-jquery-selector-for-aspnet-webforms/
String.prototype.endsWith = function(str) {
    return (this.match(str + '$') == str)
}

jQuery.extend(
    jQuery.expr[":"],
    {
        asp: "jQuery(a).attr('id').endsWith(m[3]);"
    }
);

/*
    FAQ vragen toggle
    http://coderseye.com/2007/enhancing-faqs-with-jquery.html
*/

    FAQ = {
        init: function() {
            //$('div.faq .answer').not(':first').slideToggle('fast');
            //$('div.faq .answer').slideToggle('fast');
            $('div.faq .question').click(function() {
                FAQ.toggle(this)
            });
        },

        toggle: function(elt) {
            $(elt).toggleClass('active');
            $(elt).siblings('.answer').slideToggle('normal');

        }
    }

$(document).ready(function() {
    
    // regels wisselen (anamnese)
    $("table.zorgEpisoden tbody tr:even").addClass("regelWissel");

    // patient links
    $("table.tableList tr:even").not(':first').addClass("regelWissel");

    //FAQ
    FAQ.init();
    
});

