var ISIE=false;

// >>> START JQUERY >>>
$(document).ready(function() {
							
								
// check of het Internet Explorer is
ISIE=$.browser.msie; 
// css preloader:
$.preloadCssImages();


// ### initialiseer items ##

// external links
$('A[rel="external"]').click( function(){window.open( this.href );return false;});	






// ### FORM  OPTIONS EN SPAM CHECK ###


// form buttons effect:
$('.submit_button').hover(function(){
//mouseover
$(this).addClass('submit_buttonhover'); 
},function(){
//mouseout
$(this).removeClass('submit_buttonhover'); 
});

$(".datumveld").datepicker({dateFormat: 'dd-mm-yy', changeMonth: true, changeYear: true});
$( ".submit_button, a.button").button();


// limiet voor textarea
$('.ta_limit100').keyup(function() {
      var maxlen = 450;
      var len = this.value.length;
      if (len >= maxlen) { this.value = this.value.substring(0, maxlen); }
      $('#charleft').text("Max chars:" + (maxlen - len));
  });


	// first example
	$("#folder_001").treeview({
		animated: "fast",
		collapsed: true,
		unique: false,
		persist: "cookie",
		cookieId: "stsnav"
	});



// antispam 
// doe checks op formulieren met class webform:
$(".webform").validate({rules:{antispam_veld:{required:true,minlength:6}},messages:{antispam_veld:{required:"Vul de juiste code in.",minlength:"Code bestaat uit 6 cijfers"}},submitHandler:function(form){var imgID=$(".webform #antispam_img").attr("title");var spamNaam=$(".webform input#antispam_veld").val();if($(".webform #spamchecker").val()!="true"){$.get('/include/ajax_antispam.asp?antispam='+spamNaam+'&imgID='+imgID,function(response){if(response=="true"){$(".webform #spamchecker").val("true");form.submit();}else{$(".webform #antispam_msg").html("<img src=\"/images/folders/arrow_down.png\" alt=\"Fout!\" style=\"vertical-align:middle;\"/>Vul de juiste code in.<br/>");$(".webform #antispam_msg").show("fast");return false;}});}else{form.submit();}}});$(".weblogin").validate();

/* >>>>>>>>>> EINDE JQUERY READY <<<<<<<<<< */
 });





//################### LOAD WINDOW SCRIPTS ##################
//$(window).load(function(){}); 
//  END window load 


// ###################### FUNCTIONS  #############


// _________________ / FUNCTIONS ________________

/* ****************************************
function: open and closing sliders of BARS (NOT panels)
SliderPos: left/right/top/bottom
e: element
******************************************/
function SliderControl(e, SliderPos) {
    var $Element = $("#" + SliderPos + "_bar .bar_content");
    var elem = {};
    var mode1 = "slide_" + SliderPos + "_open";
    var mode2 = "slide_" + SliderPos + "_close";
    var sWidth = 0;
    var sHeight = 0;
    var SliderTime = 200;

    if (SliderPos === "left" || SliderPos === "right") { sWidth = $Element.width(); }
    if (SliderPos === "top" || SliderPos === "bottom") { sHeight = $Element.height(); }

    if (sWidth !== 0) {

        if (e.parent().hasClass("openbar")) {
            //close the bar
            elem["margin-" + SliderPos] = "-" + sWidth + "px";
            $Element.stop().animate(elem, SliderTime, function() {
                e.parent().removeClass(mode2).addClass(mode1).removeClass("openbar");
            });
        } else {
            //open tab      
            elem["margin-" + SliderPos] = "0px";
            $Element.stop().animate(elem, SliderTime, function() {
                e.parent().removeClass(mode1).addClass(mode2).addClass("openbar");
            });
        }

    } else if (sHeight !== 0) {

        if (e.parent().hasClass("openbar")) {

            // opentab              
            elem["margin-" + SliderPos] = "-" + sHeight + "px";

            $Element.stop().animate(elem, SliderTime, function() {
                e.parent().removeClass(mode2).addClass(mode1).removeClass("openbar");
            });
        } else {
            //close tab
            elem["margin-" + SliderPos] = "0px";
            $Element.stop().animate(elem, SliderTime, function() {
                $Element.addClass("opentab");
                e.parent().removeClass(mode1).addClass(mode2).addClass("openbar");
            });
        }
    }
}



// slideshow subheader
function slideSwitch() {
    var $active = $('.client_box ul li.active');
    if ( $active.length === 0 ) $active = $('.client_box ul li:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.client_box ul li:first');
    // uncomment the 3 lines below to pull the images in random order    
     var $sibs  = $active.siblings();
     var rndNum = Math.floor(Math.random() * $sibs.length );
     var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 9000 );
});


// decapicate words
function trimWords(text,length){
	var t = text.replace(/\s/g,' ');
	var words = t.split(' ');
	if(words.length<=length)	return text;
	var ret='';
	for(var i=0;i<length;i++){
		ret+=words[i]+' ';
	}
	return ret;
}

// decapicate characters
function trimText(text, length){
	if(text.length<=length){ 
		return text;
	}
	else{
		var ret='';
		var t=text.split('');
		for(i=0; i<length; i++){
			ret+=t[i];
		}
		return ret;
	}
}



// Check whether string s is empty.
function isEmpty(s){return((s==null)||(s.length==0))}


// Jelastic plugin:
(function(g){g.fn.extend({elastic:function(){var h=["paddingTop","paddingRight","paddingBottom","paddingLeft","fontSize","lineHeight","fontFamily","width","fontWeight"];return this.each(function(){function i(c,j){curratedHeight=Math.floor(parseInt(c,10));a.height()!=curratedHeight&&a.css({height:curratedHeight+"px",overflow:j})}function k(){var c=a.val().replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/<|>/g,"&gt;").replace(/\n/g,"<br />"),j=b.html().replace(/<br>/ig,"<br />");if(c+"&nbsp;"!= j){b.html(c+"&nbsp;");if(Math.abs(b.height()+l-a.height())>3){c=b.height()+l;if(c>=d)i(d,"auto");else c<=e?i(e,"hidden"):i(c,"hidden")}}}if(this.type!="textarea")return false;var a=g(this),b=g("<div />").css({position:"absolute",display:"none","word-wrap":"break-word"}),l=parseInt(a.css("line-height"),10)||parseInt(a.css("font-size"),"10"),e=parseInt(a.css("height"),10)||l*3,d=parseInt(a.css("max-height"),10)||Number.MAX_VALUE,f=0;if(d<0)d=Number.MAX_VALUE;b.appendTo(a.parent());for(f=h.length;f--;)b.css(h[f].toString(), a.css(h[f].toString()));a.css({overflow:"hidden"});a.bind("keyup change cut paste",function(){k()});a.bind("blur",function(){if(b.height()<d)b.height()>e?a.height(b.height()):a.height(e)});a.live("input paste",function(){setTimeout(k,250)});k()})}})})(jQuery);$("textarea").elastic();




// Get querystring from url:
;(function($){$.extend({getQueryString:function(name){function parseParams(){var params={},e,a=/\+/g,r=/([^&=]+)=?([^&]*)/g,d=function(s){return decodeURIComponent(s.replace(a," "));},q=window.location.search.substring(1);while(e=r.exec(q))
params[d(e[1])]=d(e[2]);return params;}
if(!this.queryStringParams)
this.queryStringParams=parseParams();return this.queryStringParams[name];}});})(jQuery);


// Jquery cookie:
jQuery.cookie=function(key,value,options){if(arguments.length>1&&(value===null||typeof value!=="object")){options=jQuery.extend({},options);if(value===null){options.expires=-1;}
if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}
return(document.cookie=[encodeURIComponent(key),'=',options.raw?String(value):encodeURIComponent(String(value)),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};


// mailto nospam:
jQuery.fn.nospam=function(settings){settings=jQuery.extend({replaceText:false,filterLevel:'normal'},settings);return this.each(function(){e=null;if(settings.filterLevel=='low'){if($(this).is('a[rel]')){e=$(this).attr('rel').replace('][','@').replace(/\//g,'.')}else{e=$(this).text().replace('][','@').replace(/\//g,'.')}}else{if($(this).is('a[rel]')){e=$(this).attr('rel').split('').reverse().join('').replace('][','@').replace(/\//g,'.')}else{e=$(this).text().split('').reverse().join('').replace('][','@').replace(/\//g,'.')}}if(e){if($(this).is('a[rel]')){$(this).attr('href','mailto:'+e);if(settings.replaceText){$(this).text(e)}}else{$(this).text(e)}}})};


