window.onload = jQuery(function($)
{
	$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
	
	if($('.gallery_demo_unstyled').hasClass('gallery_demo'))
	{
		
	

	$('.gallery_demo').galleria({
		history   : false, // deactivates the history object for bookmarking, back-button etc.
		clickNext : false, // helper for making the image clickable. Let's not have that in this example.
		insert    : '.imgshow', // the containing selector for our main image.
		 insertCaption  : '.galleria_caption',
		// If not found or undefined (like here), galleria will create a container
		// before the ul with the class .galleria_container (see CSS)
		onImage   : function() { $('.nav').css('display','block'); } // shows the nav when the image is showing
	});

	$(".gallery_demo_unstyled li").css("display", "block");
	$(".gallery_demo_unstyled li").css("visibility", "visible");

	}

    // which container to measure height of? 
	 var wh = $(window).height();
	 var top= 132;

    if ($(".wrapper").height() <= wh){
		$("#container").css("height", wh-top);
	}

    //if ($(".doc_list").height() <= wh){
		//$(".doc_list").css("height", wh-top-64);
	//}

    if ($(".frame_middle").height() <= wh){
		$(".frame_middle").css("height", wh-top-64);
	}


    $(".show_comments").click(function() {
        var id = 'div_' + this.id;
        $(".hideable").hide();
        $("#" + id).show();
        return false;
    });

    $(".show_unselected").click(function() {
        var id = 'div_' + this.id;
        $(".hideable").hide();
        $("#" + id).show();

        $("a.showSelected").addClass("show_unselected");
        $("a.showSelected").removeClass("showSelected");

        $(this).removeClass("show_unselected");
        $(this).addClass("showSelected");
		document.getElementById("#" + id).scrollIntoView(true);
        return false;
    });

	   $("#blog").hover(
      function () {
        $(this).addClass('div_menu_top_hover');
      }, 
      function () {
        $("#blog").removeClass('div_menu_top_hover');
      }
    );

		   $("#user").hover(
      function () {
        $(this).addClass('div_menu_top_hover');
      }, 
      function () {
        $("#user").removeClass('div_menu_top_hover');
      }
    );

		   $("#newblog").hover(
      function () {
        $(this).addClass('div_menu_top_hover');
      }, 
      function () {
        $("#newblog").removeClass('div_menu_top_hover');
      }
    );

		   $("#myblog").hover(
      function () {
        $(this).addClass('div_menu_top_hover');
      }, 
      function () {
        $("#myblog").removeClass('div_menu_top_hover');
      }
    );


//$("#textarea").click( function() {

    // Completely strips tags.  Taken from Prototype library.
   // var strClean = $(this).html().replace(/<\/?[^>]+>/gi, '');

    // Remove any double and single quotation marks.
   // strClean = strClean.replace(/"/gi, '').replace(/'/gi, '');
//		var strClean = CleanWordHTML($("#textarea").html());
    // put the data back in.
  //  $("#textarea").html(strClean);
//});





		// add the Galleria class
		$(this).addClass('galleria');
		
		// loop through list
		$(this).children('li').each(function(i) {
			
			// bring the scope
			var _container = $(this);
			                
			// build element specific options
			var _o = $.meta ? $.extend({}, $opts, _container.data()) : $opts;
			
			// remove the clickNext if image is only child
			_o.clickNext = $(this).is(':only-child') ? false : _o.clickNext;
			
			// try to fetch an anchor
			var _a = $(this).find('a').is('a') ? $(this).find('a') : false;

			// reference the original image as a variable and hide it
			var _img = $(this).children('img').css('display','none');
			
			// extract the original source
			var _src = _a ? _a.attr('href') : _img.attr('src');
	

	// get the thumb
	var _thumb = $('.galleria img[rel="'+_src+'"]');

	if (_thumb.hasClass('fewpic')) {
	_thumb.css("height", '120px');
	_thumb.css("width", '120px');
	}

	if (_thumb.hasClass('manypic')) {
		_thumb.css("height", '60px');
		_thumb.css("width", '60px');
		}
		});
});

function displayuser(st)
{
var blog = $(".userblog").css("style");
var user = $(".userform").css("style");

if(st=='userblog')
	{
		$("#user").removeClass('div_menu_toop_hover');
		$("#newblog").removeClass('div_menu_toop_hover');
		$("#myblog").removeClass('div_menu_toop_hover');
		$("#blog").addClass('div_menu_toop_hover');
		$(".userform").hide();
		$(".newblogg").hide();
		$(".myblogg").hide();
		$(".userblogg").show();
	}

if(st=='myblog')
	{
		var mn = $("#mName").val();
		var mi = $("#mIngress").val();
		var mp = $("#mPic").val();
		$("#user").removeClass('div_menu_toop_hover');
		$("#newblog").removeClass('div_menu_toop_hover');
		$("#blog").removeClass('div_menu_toop_hover');
		$("#myblog").addClass('div_menu_toop_hover');
		$(".userform").hide();
		$(".newblogg").hide();
		$(".userblogg").hide();
		$('[name=MENUTITLE]').val(mn);
		$(".myblogg").show();
		tinyMCE.execInstanceCommand('bodytext2','mceSetContent',false, mi,false );

		if(mp !="")
		$(".IMG1").html("<img src='"+mp+"' style='height:100px;width:100px'/>");
	}

if(st=='userform')
	{
		$("#blog").removeClass('div_menu_toop_hover');
		$("#newblog").removeClass('div_menu_toop_hover');
		$("#myblog").removeClass('div_menu_toop_hover');
		$("#user").addClass('div_menu_toop_hover');
		$(".userblogg").hide();
		$(".newblogg").hide();
		$(".myblogg").hide();
		$(".userform").show();
	}
if(st=='newblog')
	{
		$("#blog").removeClass('div_menu_toop_hover');
		$("#user").removeClass('div_menu_toop_hover');
		$("#myblog").removeClass('div_menu_toop_hover');
		$("#newblog").addClass('div_menu_toop_hover');
		$(".myblogg").hide();
		$(".userblogg").hide();
		$(".userform").hide();
		$(".newblogg").show();

	$('[name=TITLE]').val('new title');
	$('[name=INGRESS]').val('');
	$('[name=body]').val('');
	$('[name=doc_id]').val('');
	$('[name=descr1]').val('');
	$('[name=descr2]').val('');
	$('[name=descr3]').val('');
	$('[name=descr4]').val('');
	$('[name=descr5]').val('');
	$('[name=descr6]').val('');
	$(".IMG1").html("");
	$(".IMG2").html("");
	$(".IMG3").html("");
	$(".IMG4").html("");
	$(".IMG5").html("");
	$(".IMG6").html("");
tinyMCE.execInstanceCommand('bodytext','mceSetContent',false,'',false );
	}
}


function changedoc(id)
{

	var t = $("#t_"+id).val();
	var i = $("#i_"+id).val();
	var c = $("#c_"+id).val();
	var img1 = $("#img_9_"+id).val();
	var img2 = $("#img_10_"+id).val();
	var img3 = $("#img_11_"+id).val();
	var img4 = $("#img_12_"+id).val();
	var img5 = $("#img_13_"+id).val();
	var img6 = $("#img_14_"+id).val();
	var DESCR1 = $("#DESCR_9_"+id).val();
	var	DESCR2 = $("#DESCR_10_"+id).val();
	var	DESCR3 = $("#DESCR_11_"+id).val();
	var	DESCR4 = $("#DESCR_12_"+id).val();
	var	DESCR5 = $("#DESCR_13_"+id).val();
	var	DESCR6 = $("#DESCR_14_"+id).val();
	var id1 = $("#ATTACH_9_"+id).val();
	var id2 = $("#ATTACH_10_"+id).val();
	var id3 = $("#ATTACH_11_"+id).val();
	var id4 = $("#ATTACH_12_"+id).val();
	var id5 = $("#ATTACH_13_"+id).val();
	var id6 = $("#ATTACH_14_"+id).val();

	$("#blog").removeClass('div_menu_top_hover');
	$("#user").removeClass('div_menu_top_hover');
	$("#newblog").addClass('div_menu_top_hover');

	$(".userblogg").hide();
	$(".userform").hide();
	$(".newblogg").show();

	$('[name=TITLE]').val(t);
	$('[name=INGRESS]').val(i);
	tinyMCE.execInstanceCommand('bodytext','mceSetContent',false, c,false );
	//$('[name=body]').val(c);
	$('[name=doc_id]').val(id);

	$('[name=descr1]').val(DESCR1);
	$('[name=descr2]').val(DESCR2);
	$('[name=descr3]').val(DESCR3);
	$('[name=descr4]').val(DESCR4);
	$('[name=descr5]').val(DESCR5);
	$('[name=descr6]').val(DESCR6);

	$('[name=ATTACHMENT_ID_1]').val(id1);
	$('[name=ATTACHMENT_ID_2]').val(id2);
	$('[name=ATTACHMENT_ID_3]').val(id3);
	$('[name=ATTACHMENT_ID_4]').val(id4);
	$('[name=ATTACHMENT_ID_5]').val(id5);
	$('[name=ATTACHMENT_ID_6]').val(id6);



	if(img1 !="")
		{
			$(".IMG1").html("<img src='"+img1+"' style='height:100px;width:100px'/>");
			$('[name=IMG_1]').val(img1);
			
		}
	if(img2 != null)
		{
			$(".IMG2").html("<img src='"+img2+"' style='height:100px;width:100px'/>");
			$('[name=IMG_2]').val(img2);
		}
	if(img3 !=null)
		{
			$(".IMG3").html("<img src='"+img3+"' style='height:100px;width:100px'/>");
			$('[name=IMG_3]').val(img3);
		}
	if(img4 !=null)
		{
			$(".IMG4").html("<img src='"+img4+"' style='height:100px;width:100px'/>");
			$('[name=IMG_4]').val(img4);
		}
	if(img5 !=null)
		{
			$(".IMG5").html("<img src='"+img5+"' style='height:100px;width:100px'/>");
			$('[name=IMG_5]').val(img5);
		}
	if(img6 !=null)
		{
			$(".IMG6").html("<img src='"+img6+"' style='height:100px;width:100px'/>");
			$('[name=IMG_6]').val(img6);
		}


}


function alertbox()
{
 alert("Registreer of log in aan linkerzijde pagina.");
}

function display(arkiv)
{
	if( !$('.sub_'+arkiv).is(':visible') ) {
		$(".sub_"+arkiv).show();
	}
	else {
		$(".sub_"+arkiv).hide();
	}
}

function CleanWordHTML( str )
{
	str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
	str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
	str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
	str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
	str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
	str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
	str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
	str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
	str = str.replace( /\s*tab-stops:[^"]*/gi, "" ) ;
	str = str.replace( /\s*face="[^"]*"/gi, "" ) ;
	str = str.replace( /\s*face=[^ >]*/gi, "" ) ;
	str = str.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
	str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	str = str.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
	str = str.replace( /\s*style="\s*"/gi, '' ) ;
	str = str.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
	str = str.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
	str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	str = str.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
	str = str.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
	str = str.replace(/<\\?\?xml[^>]*>/gi, "") ;
	str = str.replace(/<\/?\w+:[^>]*>/gi, "") ;
	str = str.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
	str = str.replace( /<H1([^>]*)>/gi, '' ) ;
	str = str.replace( /<H2([^>]*)>/gi, '' ) ;
	str = str.replace( /<H3([^>]*)>/gi, '' ) ;
	str = str.replace( /<H4([^>]*)>/gi, '' ) ;
	str = str.replace( /<H5([^>]*)>/gi, '' ) ;
	str = str.replace( /<H6([^>]*)>/gi, '' ) ;
	str = str.replace( /<\/H\d>/gi, '<br>' ) ; //remove this to take out breaks where Heading tags were
	str = str.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
	str = str.replace( /<(B|b)>&nbsp;<\/\b|B>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	//some RegEx code for the picky browsers
	var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;
	str = str.replace( re, "<div$2</div>" ) ;
	var re2 = new RegExp("(<font|<FONT)([^*>]*>.*?)(<\/FONT>|<\/font>)","gi") ;
	str = str.replace( re2, "<div$2</div>") ;
	str = str.replace( /size|SIZE = ([\d]{1})/g, '' ) ;
	return str ;
}


