$(document).ready(
	function () {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapper').Sortable(
			{
				accept: 'groupItem',
				helperclass: 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass : 'sortablehover',
				handle: 'div.itemHeader',
				tolerance: 'pointer',
				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
				}
			}
		);
	}
);
var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};
function serialize(s,type)
{

// userID: $('#userID').val(), [dit kwam voor serial: etc]
	serial = $.SortSerialize(s);
	$.post("/startpagina/sort.php", { serial: serial.hash },
            function(data){
			   $("#user_respond").html(data);
    });
};

// begin links schuiven
$(document).ready(
	function () {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapperItem').Sortable(
			{
				accept: 'groupItemItem',
				helperclass: 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass : 'sortablehover',
				handle: 'div.itemHeaderItem',
				tolerance: 'pointer',
				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
				}
			}
		);
	}
);
var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};

function serializeItem(s,type)
{

// userID: $('#userID').val(), [dit kwam voor serial: etc]
	serial = $.SortSerialize(s);
	$.post("/startpagina/sort.php", { serial: serial.hash },
            function(data){
			   $("#user_respond").html(data);
    });
};
// einde links

$(function(){
iniAccordion();
});
function iniAccordion()
{
	$(".accordion h5").eq(95).addClass("active");
	$(".accordion div").eq(95).show();

	$(".accordion h5").click(function(){
		$(this).next("div").slideToggle("slow")
		.siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h5").removeClass("active");
	});

}

function Toggle(thediv) { 

	document.getElementById("rss").style.display = "none";
	document.getElementById("rss_uitleg").style.display = "none";
	document.getElementById("links_uitleg").style.display = "none";
	document.getElementById("notities_uitleg").style.display = "none";
	document.getElementById("taken_uitleg").style.display = "none";
	document.getElementById("kladblok_uitleg").style.display = "none";
	document.getElementById("zoekmachine").style.display = "none"; 
	document.getElementById("zoekmachine_uitleg").style.display = "none"; 
	document.getElementById("calculator").style.display = "none";
	document.getElementById("calculator_uitleg").style.display = "none";
	document.getElementById("bestanden_uitleg").style.display = "none";
	document.getElementById("algemeen").style.display = "block"; 
	document.getElementById("submit").style.display = "block";
	document.getElementById(thediv + "_uitleg").style.display = "block";
	
	
if (thediv == 'zoekmachine') {
	document.getElementById("algemeen").style.display = "none"; 
	document.getElementById("submit").style.display = "block";
	document.getElementById("zoekmachine").style.display = "block";
} 

if (thediv == 'calculator') {
	document.getElementById("algemeen").style.display = "none"; 
	document.getElementById("submit").style.display = "block";
	document.getElementById("calculator").style.display = "block";
} 

if (thediv == 'rss') {
	document.getElementById("rss").style.display = "block";
} 

} 

// KLADBLOK
function editKladblok(id){
			$.post("/startpagina/blokken/kladblok.php?actie=wijzig_kladblok",{ kladblok: $('#kladblok'+id).val(),kladID: $('#kladID'+id).val()}, 
			function(data){
        });
      } 

// TAKEN
	function checkTaak(id){
			$.post("/startpagina/blokken/taken.php?actie=check_taak&taakID=" + id,{ checktaak: $('#checktaak'+id).val()}, 
			function(data){
        });
      } 


// BLOKKEN
function addBlok(){
	
	
	$.ajax({
			type: 'POST',
			url: "startpagina/control_panel.php",
			data: "docbloc=nieuw&blokType=" + $('#blokType').val() + "&blokTitel=" + $('#blokTitel').val(),
			success: function(response){$("#totaalbloks").html(response)},
			complete:function(){
							$(document).ready(
	function () {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapper').Sortable(
			{
				accept: 'groupItem',
				helperclass: 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass : 'sortablehover',
				handle: 'div.itemHeader',
				tolerance: 'pointer',
				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
				}
			}
		);
	}
);
var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};
function serialize(s,type)
{

// userID: $('#userID').val(), [dit kwam voor serial: etc]
	serial = $.SortSerialize(s);
	$.post("/startpagina/sort.php", { serial: serial.hash },
            function(data){
			   $("#user_respond").html(data);
    });
};

// begin links schuiven
$(document).ready(
	function () {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapperItem').Sortable(
			{
				accept: 'groupItemItem',
				helperclass: 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass : 'sortablehover',
				handle: 'div.itemHeaderItem',
				tolerance: 'pointer',
				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
				}
			}
		);
	}
);
var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};

function serializeItem(s,type)
{

// userID: $('#userID').val(), [dit kwam voor serial: etc]
	serial = $.SortSerialize(s);
	$.post("/startpagina/sort.php", { serial: serial.hash },
            function(data){
			   $("#user_respond").html(data);
    });
};
// einde links
									   
									   
									   }
								 });
	
	hideLayer('formBlokToevoegen');
	showLayer('container_startpagina');

}

	function editBlok(blokID){
	 
		  $.post("/startpagina/blok.php?actie=wijzigen_blok&blokID=" + blokID, { blokTitel: $('#blokTitel'+blokID).val(),blokContent: $('#blokContent'+blokID).val(),blokPublic: $('#blokPublic'+blokID).val(),blokLines: $('#blokLines'+blokID).val(),blokType: $('#blokType'+blokID).val()}, 
				function(data){
					//alert(data);
				 $("#titelBlok" + blokID).html(data);
			});
		  
		  return true;   
	}
	
	
	function delBlok(blokID){
	 
		  $.post("/startpagina/blok.php?actie=verwijderen_blok&blokID=" + blokID, 
				function(data){
					//alert(data);
				 $("#blok" + blokID).html(data);
			});
		  
		  return true;   
	}
	
	
		function kopieBlok(blokID){
	 
		  $.post("/startpagina/blok.php?actie=kopieren_blok&blokID=" + blokID, 
				function(data){
					//alert(data);
				 $("#formKopie" + blokID).html(data);
			});
		  
		  return true;   
	}
	
			function kopieBlokken(blokID,userID){
	 
		  $.post("/startpagina/blok.php?actie=kopieren_blok&blokUser=" + userID, 
				function(data){
					//alert(data);
				 $("#formKopie" + blokID).html(data);
			});
		  
		  return true;   
	}
	
	function stateBlok(blokID,uitrol){
	
	if (uitrol == 0) {
	document.getElementById("blokView" + blokID).style.display = "none";
	document.getElementById("editBlok" + blokID).style.visibility="hidden";
	}
	
	if (uitrol == 1) {
	document.getElementById("blokView" + blokID).style.display = "block";
	document.getElementById("editBlok" + blokID).style.visibility="visible";
	}
	
		$.ajax({
	   url: "/startpagina/blok.php?actie=state_blok&blokID=" + blokID + "&state=" + uitrol, 
	   success: function(response){$("#stateBlok" + blokID).html(response)}
	 });
		  
	}

// LINKS & NOTITIES & BESTANDEN
function itemFilter(tag,contentBlokID,gebruiker){
	$.ajax({
	   url: "/startpagina/blokken/notities.php?gebruiker=" + gebruiker + "&sortID=" + contentBlokID + "&letter=" + tag,
	   success: function(response){$("#contentBlok" + contentBlokID).html(response)},
	   complete:function(){
							$(document).ready(
								function () {
									$('a.closeEl').bind('click', toggleContent);
									$('div.groupWrapperItem').Sortable(
										{
											accept: 'groupItemItem',
											helperclass: 'sortHelper',
											activeclass : 'sortableactive',
											hoverclass : 'sortablehover',
											handle: 'div.itemHeaderItem',
											tolerance: 'pointer',
											onChange : function(ser)
											{
											},
											onStart : function()
											{
												$.iAutoscroller.start(this, document.getElementsByTagName('body'));
											},
											onStop : function()
											{
												$.iAutoscroller.stop();
											}
										}
									);
								}
							);
							var toggleContent = function(e)
							{
								var targetContent = $('div.itemContent', this.parentNode.parentNode);
								if (targetContent.css('display') == 'none') {
									targetContent.slideDown(300);
									$(this).html('[-]');
								} else {
									targetContent.slideUp(300);
									$(this).html('[+]');
								}
								return false;
							};
							
							function serializeItem(s,type)
							{
							
							// userID: $('#userID').val(), [dit kwam voor serial: etc]
								serial = $.SortSerialize(s);
								$.post("/startpagina/sort.php", { serial: serial.hash },
										function(data){
										   $("#user_respond").html(data);
								});
							};
							// einde links
									   
									   
									   }
	 });
}
 
function vulItem(contentBlokID,id,gebruiker,type){
			
	$.ajax({
			type: 'POST',
			url: "/startpagina/blokken/" + type + ".php?actie=vul_contentItem&gebruiker=" + gebruiker + "&sortID=" + contentBlokID,
			data: "notID=" + $('#notID'+id).val(),
			success: function(response){$("#contentBlok" + contentBlokID).html(response)},
			complete:function(){
							$(document).ready(
								function () {
									$('a.closeEl').bind('click', toggleContent);
									$('div.groupWrapperItem').Sortable(
										{
											accept: 'groupItemItem',
											helperclass: 'sortHelper',
											activeclass : 'sortableactive',
											hoverclass : 'sortablehover',
											handle: 'div.itemHeaderItem',
											tolerance: 'pointer',
											onChange : function(ser)
											{
											},
											onStart : function()
											{
												$.iAutoscroller.start(this, document.getElementsByTagName('body'));
											},
											onStop : function()
											{
												$.iAutoscroller.stop();
											}
										}
									);
								}
							);
							var toggleContent = function(e)
							{
								var targetContent = $('div.itemContent', this.parentNode.parentNode);
								if (targetContent.css('display') == 'none') {
									targetContent.slideDown(300);
									$(this).html('[-]');
								} else {
									targetContent.slideUp(300);
									$(this).html('[+]');
								}
								return false;
							};
							
							function serializeItem(s,type)
							{
							
							// userID: $('#userID').val(), [dit kwam voor serial: etc]
								serial = $.SortSerialize(s);
								$.post("/startpagina/sort.php", { serial: serial.hash },
										function(data){
										   $("#user_respond").html(data);
								});
							};
							// einde links
									   
									   
									   }
								 });
}
	  
function addItem(contentBlokID,id,actie,gebruiker,type){
			
				var letter = $('#naam'+contentBlokID).val().substring(0,1)
				if (actie == 'vul_contentItem') { actie = 'wijzigen_contentItem'; } else { actie = 'invoegen_contentItem'; }
				
	$.ajax({
			type: 'POST',
			url: "/startpagina/blokken/" + type + ".php?actie=" + actie + "&gebruiker=" + gebruiker + "&letter=" + letter + "&id=" + id + "&sortID=" + contentBlokID,
			data: "naam=" + $('#naam'+contentBlokID).val() + "&contentItemcontent=" + $('#contentItemcontent'+contentBlokID).val(),
			success: function(response){$("#contentBlok" + contentBlokID).html(response)},
			complete:function(){
							$(document).ready(
								function () {
									$('a.closeEl').bind('click', toggleContent);
									$('div.groupWrapperItem').Sortable(
										{
											accept: 'groupItemItem',
											helperclass: 'sortHelper',
											activeclass : 'sortableactive',
											hoverclass : 'sortablehover',
											handle: 'div.itemHeaderItem',
											tolerance: 'pointer',
											onChange : function(ser)
											{
											},
											onStart : function()
											{
												$.iAutoscroller.start(this, document.getElementsByTagName('body'));
											},
											onStop : function()
											{
												$.iAutoscroller.stop();
											}
										}
									);
								}
							);
							var toggleContent = function(e)
							{
								var targetContent = $('div.itemContent', this.parentNode.parentNode);
								if (targetContent.css('display') == 'none') {
									targetContent.slideDown(300);
									$(this).html('[-]');
								} else {
									targetContent.slideUp(300);
									$(this).html('[+]');
								}
								return false;
							};
							
							function serializeItem(s,type)
							{
							
							// userID: $('#userID').val(), [dit kwam voor serial: etc]
								serial = $.SortSerialize(s);
								$.post("/startpagina/sort.php", { serial: serial.hash },
										function(data){
										   $("#user_respond").html(data);
								});
							};
							// einde links
									   
									   
									   }
								 });
}
	  

	  	  	function delItem(contentBlokID,id,gebruiker,type,letter) {
			
			$.post("/startpagina/blokken/" + type + ".php?actie=verwijderen_contentItem&gebruiker=" + gebruiker + "&letter=" + letter + "&sortID=" + contentBlokID,{ notID: $('#notID'+id).val() }, 
			function(data){
				//alert(data);
            $("#contentItem" + id).html(data);
        });
      }
	  
// BESTANDEN
function startUpload(sortID){
      document.getElementById('uploadProgress' + sortID).style.display = 'block';
	  document.getElementById('uploadResult' + sortID).style.display = 'none';
	  document.getElementById('formcontentItem' + sortID).style.display = 'none';
      return true;
}

function stopUpload(foutmelding,bestanden,sortID){
      var result = '';
	  var extra = '';
	  
	  $.post("/startpagina/blokken/bestanden.php?foutmelding=" + foutmelding  + "&sortID=" + sortID, 
			function(data){
				//alert(data);
             $("#contentBlok" + sortID).html(data);
        });
	  
      return true;   
}
	  
// datepicker	  
	   if (navigator.platform.toString().toLowerCase().indexOf("linux") != -1){
	document.write('<link type="text/css" rel="stylesheet" href="http://www.medic-all.nl/sites/startpagina/css/datepickercontrol_lnx.css">');
 }
 else{
	document.write('<link type="text/css" rel="stylesheet" href="http://www.medic-all.nl/sites/startpagina/css/datepickercontrol.css">');
 }
 

 function showLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = 'block';
}

 function hideLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = 'none';
}


function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function toggleLayers( whichLayer, whichLayer2 )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  
    var elem2, vis2;
  if( document.getElementById ) // this is the way the standards work
    elem2 = document.getElementById( whichLayer2 );
  else if( document.all ) // this is the way old msie versions work
      elem2 = document.all[whichLayer2];
  else if( document.layers ) // this is the way nn4 works
    elem2 = document.layers[whichLayer2];
  vis2 = elem2.style;
  // if the style.display value is blank we try to figure it out here
  if(vis2.display==''&&elem2.offsetWidth!=undefined&&elem2.offsetHeight!=undefined)
    vis2.display = (elem2.offsetWidth!=0&&elem2.offsetHeight!=0)?'none':'block';
  vis2.display = (vis2.display==''||vis2.display=='none')?'block':'none';
}

 function showhideLayers( whichLayer, whichLayer2)
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = 'block';
  
    var elem2, vis2;
  if( document.getElementById ) // this is the way the standards work
    elem2 = document.getElementById( whichLayer2 );
  else if( document.all ) // this is the way old msie versions work
      elem2 = document.all[whichLayer2];
  else if( document.layers ) // this is the way nn4 works
    elem2 = document.layers[whichLayer2];
  vis2 = elem2.style;
  vis2.display = 'none';
}