$(function(){
	//Eksterne links (accepteret i xhtml-strict)
	$('a.blank').click(function(){ window.open(this.href); return false; });
	
	// Count-down i celle administration
 	$('#notescellgroupleader').keyup(function(){ limitChars('notescellgroupleader', 400, 'charlimitnotesleader'); })
 	$('#groupdesc').keyup(function(){ limitChars('groupdesc', 400, 'charlimitnotesgroup'); })
 	$('#pp_content').keyup(function(){ limitChars('pp_content', 1200, 'charlimitprayerpraise'); })
	
		
	/* Fancy-box */
	$("#fancybox").fancybox		({'width': 700,'height':500,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$("a#admin").fancybox		({'width': 700,'height':500,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$("a#outlook").fancybox		({'width': 700,'height':400,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$("a#tipafriend").fancybox	({'width': 700,'height':500,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$("a#findvej").fancybox		({'width': 750,'height':500,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$("a#scripture").fancybox	({'width': 700,'height':300,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
});


			/*
			// Examples - images

			$("a#example1").fancybox({'titleShow' : false});
			$("a#example2").fancybox({'titleShow' : false, 'transitionIn' : 'elastic','transitionOut' : 'elastic' });
			$("a#example3").fancybox({'titleShow' : false, 'transitionIn' : 'none','transitionOut' : 'none'	});
			$("a#example4").fancybox();
			$("a#example5").fancybox({'titlePosition' : 'inside'});
			$("a#example6").fancybox({'titlePosition' : 'over' });

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});

			//Examples - various

			$("#various1").fancybox({'titlePosition':'inside','transitionIn':'none','transitionOut':'none'});
			$("#various2").fancybox();
			$("#various3").fancybox({'width': '75%','height':'75%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
			$("#various4").fancybox({'padding':0,'autoScale':false,'transitionIn':'none','transitionOut':'none'});

  			*/

/* Navigering i dropdown-menu */


startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
				this.className+=" over";
				}
				node.onmouseout=function() {
				this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;


/* Tilmelding til Pastor og Lederbibelskole - beregner */


//function recalculatePLBS(){
//	
//	var pricePLBS     = document.getElementById('pricePLBS4').value * 1;
//	var objPLBS       = document.getElementById('PLBS4');
//	
//	if($("#PLBS1")[0].checked){
//		pricePLBS = (pricePLBS * 1) + 325;
//	}
//	if($("#PLBS2")[0].checked){
//		pricePLBS = (pricePLBS * 1) + 325;
//	}
//	if($("#PLBS3")[0].checked){
//		pricePLBS = (pricePLBS * 1) + 325;
//	}
//	if($("#PLBS4")[0].checked){
//		pricePLBS = (pricePLBS * 1) + 325;
//	}
//	if($("#PLBS5")[0].checked){
//		pricePLBS = (pricePLBS * 1) + 1200;
//	}
//
//	var totalPLBS = pricePLBS * 1;
//	
//	var subtotalPLBS  = totalPLBS;
//	var grandtotalPLBS = subtotalPLBS;
//	   
//    totalPLBS = totalPLBS.toFixed(2).toString().replace(".",",");
//    subtotalPLBS = subtotalPLBS.toFixed(2).toString().replace(".",",");
//    grandtotalPLBS = grandtotalPLBS.toFixed(2).toString().replace(".",","); 
// 	
//    $("#pricePLBS").html(pricePLBS);
//    $("#totalPLBS").html(totalPLBS);
//    $("#grandtotalPLBS").html(grandtotalPLBS);
//	$("#totalpricePLBS").val( $("#grandtotalPLBS").html() ); /* Den pris deltageren skal betale */
//}


function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('Du kan ikke skrive mere end '+limit+' tegn!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('Du har '+ (limit - textlength) +' tegn tilbage.');
		return true;
	}
}
