$(document).ready(function() {
	$("input[name$=chkAccept]").each(function() {
	    if (  this.checked == false )
	    {	   	    
	         $("input[name$=btnSubmitArticleReaction]").toggle();   //.attr("disabled", "disabled");  
	    }
	});
	
	 $("input[name$=chkAccept]").click(function() {    
            var checked_status = this.checked;
            if (checked_status == true)
			{
                $("input[name$=btnSubmitArticleReaction]").toggle(); //.removeAttr("disabled");
            }
            else
			{
                $("input[name$=btnSubmitArticleReaction]").toggle(); //  .attr("disabled", "disabled");
            }   
     });

	/* FUNCTIONS */
	/* Character counter */	
	jQuery.fn.counter = function() {
	  $(this).each(function() {
  
	    var max = $(this).attr('maxlength');
	    var val = $(this).attr('value');
	    var cur = 0;
	    if(val)
	    	cur = val.length;
	    var left = max-cur;
	    $(this).after("<div class='counter'>Nog <strong>"+left.toString()+"</strong> tekens over</div>");
	    var c = $(this).next(".counter"); 
	    $(this).keyup(function(i) {
	      var max = $(this).attr('maxlength');
	      var val = $(this).attr('value');
	      var cur = 0;
	      if(val)
	        cur = val.length;
	      var left = max-cur;

	      if (left < 0)
	      {
		i.preventDefault();
		left = 0;
	      }
	      $(this).next(".counter").find('strong').text(left.toString());
	      return this;
	    });
	    $(this).keypress(function(i) {
	      var max = $(this).attr('maxlength');
	      var val = $(this).attr('value');
	      var cur = 0;
	      if(val)
	        cur = val.length;
	      var left = max-cur;
		  
		  var key = i.which;
		  if(key >= 33 || key == 13)
		  {
			  if (left < 0 )
			  {
				i.preventDefault();
			  }
		  }
	      return this;
	    });
	  });
	  return this;
	}
	/* Justify height of columns */
	jQuery.fn.vjustify=function() {
	    var maxHeight=0;
	    this.each(function(){
	        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
	    });
	    this.each(function(){
	        $(this).height(maxHeight + "px");
	        if (this.offsetHeight>maxHeight) {
	            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
	        }
	    });
	};

	/* Tab widgets initialiseren */
	$('.tabs-widget > ul').tabs({ fx: { opacity: 'toggle', duration: 'fast' } });  
	/* Pictures */
	
	$('#photocontainer ul.photos li:first-child').show(); 

/* Create variabeles */
var countImages = $('#photocontainer ul.photos li').length;
var nextImage = 0;
var loopImages = false;

if (countImages == 1) {
	$('div.gpp').addClass('single');
}

	
	/* Show if loaded */
$('div.image-rotator').show();

/* Fix things */
$('div.image-rotator ul.controls li.prev').after('<li class="info">...</li>');

/* Create objects */
var $baseImage = $('#photocontainer ul.photos li:eq(0) img');
var $otherImages = $('div.image-rotator ul.photos li:gt(0) img');

/* Hide all images, except the first one */
//$otherImages.hide();

/* Create array with baseImage values */
var baseImageProperties = [];
baseImageProperties['src'] = $baseImage.attr('src');
baseImageProperties['alt'] = $baseImage.attr('alt');
baseImageProperties['title'] = $baseImage.attr('title');

/* Set initial info */
$('.article-detail .gpp li.info').text('1 van '+countImages);

/* Set initial caption */
$('.article-detail .gpp p.caption').text($baseImage.attr('alt'));
$('.article-detail .gpp p.copyright').text($baseImage.attr('title'));

/* Dim Previous button initially */
$('.article-detail .gpp ul.controls li.prev').toggleClass('dimmed');

/* Bind onClick handler to Next and Previous links */	
$('.image-rotator ul.controls li a').bind('click', function() {
	/* Disable dimmed Previous and Next buttons if needed */		
	if (!loopImages && $(this).parent('li').hasClass('dimmed'))
		return false;
	/* Has the Next or the Previous been clicked? */
	if ($(this).parent('li').hasClass('next'))
		next = true;
	else
		next = false;
	/* Determine position of next or previous image */
	if (nextImage == 0)
		if (next) nextImage = nextImage + 1;
		else nextImage = countImages - 1;
	else if ( (nextImage > 0) && (nextImage < (countImages - 1)) )
		if (next) nextImage = nextImage + 1;
		else nextImage = nextImage - 1;
	else if ( nextImage == (countImages - 1))
		if (next) nextImage = 0;
		else nextImage = nextImage -1;
	/* Change button states */	
	$('.article-detail .gpp ul.controls li').removeClass('dimmed');
	next = false;
	prev = false;		
	if (nextImage == 0)
		prev = true;
	else if (nextImage == (countImages - 1) )
		next = true;
	if (next)
		$('.article-detail .gpp ul.controls li.next').toggleClass('dimmed');
	else if (prev)
		$('.article-detail .gpp ul.controls li.prev').toggleClass('dimmed');
	/* Create object for required <li> */
	$nextImage = $('div.image-rotator ul.photos li:eq('+nextImage+')');
	/* Replace image */
	if (nextImage != 0){
		//$baseImage.fadeOut(125,function() 		{
			$baseImage.attr('src',$nextImage.find('img').attr('src'));
			$baseImage.attr('alt',$nextImage.find('img').attr('alt'));
			$baseImage.attr('title',$nextImage.find('img').attr('title'));
			//$baseImage.fadeIn(125);
		//});
		}
	else {
		//$baseImage.fadeOut(125,function() {
			$baseImage.attr('src',baseImageProperties['src']);
			//$baseImage.fadeIn(125);
		//});
		}
	/* Replace caption and copyright message */
	if (nextImage != 0) {
		$('.article-detail .gpp p.caption').text($nextImage.find('img').attr('alt'));
		$('.article-detail .gpp p.copyright').text($nextImage.find('img').attr('title'));
	}
	else {
		$('.article-detail .gpp p.caption').text(baseImageProperties['alt']);
		$('.article-detail .gpp p.copyright').text(baseImageProperties['title']);
	};
	/* Update status */
	$info = (nextImage+1)+' van '+countImages;
	$('.article-detail .gpp li.info').text($info);
	/* Ignore anchor */
	return false;
});



	/* Service navigation */
	$servicenav = 'close';
	$('ul#service-nav li > a')
		.bind('click',function() {
			$(this).parent().parent().find('li > ul').hide('fast');
			$(this).parent().find('ul').toggle('fast');
			if ($(this).css('display') == 'block') {
				$servicenav = 'open';
			}
			else {
				$servicenav = 'close';
			}
		});
	$('ul#service-nav li > a')
		.bind('mouseenter',function() {
			if ($servicenav == 'open') {
				$(this).parent().parent().find('li > ul').hide('fast');
				$(this).parent().find('ul').toggle('fast');	
			}
		});
	$('ul#service-nav li > ul')
		.bind('mouseleave',function() { 
			$(this).toggle('fast');
			$servicenav = 'close';
		})
	/* Add character counter to textarea */	
	$('.comments #your-comment textarea').counter();
  /* Add comma's to footer links */
  $('.ie #footer ul.links li:last-child').addClass('last');
  $('.ie #footer ul.links li:not(.last)').append(', ');
  /* Add video overlays */
 $('#breaking-video .panel li a img').each(function() {
		var src = $(this).attr('src');
		$(this)
			.css('background-image','url('+src+')')
			.attr('src','images/slidebox/video-overlay_85x60.png');
	});
	
	/* Profile - show/hide info */
	$("h6.label").click(function(){
		$(this).next("div").slideToggle("slow")
		.siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h6").removeClass("active");
	});
	
	/*Telex count*/
	$('#telex a').bind('click', function() {
		  var artikel = $(this).attr("href");
		  var categorie = "Navigatie - Telex";
		  var actie = "Klik - (" + artikel + ")";
		  var label = "Navigatie - Telex - StandaardOnline";
		  label = document.title;
		  /*alert("CATEGORIE: " + categorie + " ACTIE: " + actie + " LABEL " + label);*/
		  pageTracker._trackEvent(categorie, actie, label);
	});	
});
/* These functions rely on images being fully loaded, so $(document).ready() won't work */
$(window).load(function() {
	/* Adjust column heights where needed */
	$(".stretch").vjustify();
});

/* ADHESE */
function getUrlVars()
{
	var current_url = window.location.href.toLowerCase(); 
	var vars = [], hash;
	var hashes = current_url.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars;
}


	/* */
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

/*  */

/* VERKEER */
var hash = getUrlVars();
var verkeersinfo = window.location.href.indexOf("extra/verkeer");
var gid = hash['kanaalid'];
if (gid==808 || verkeersinfo > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='dso_verkeer'<\/scr"+"ipt>");
}

/* WEER */
var weerinfo = window.location.href.indexOf("extra/weer");
if (weerinfo > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='dso_weer'<\/scr"+"ipt>");
} 


/* TYPEPAD - DSO */
var dso_batibouw = window.location.href.indexOf("RfOOOPp7hqNOAgj6Xw2exvUKxtO5LgdhkDrttv");
if (dso_batibouw > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='dso_batibouw'<\/scr"+"ipt>");
} 
/* WESTTOER- DSO */
var dso_typepad = window.location.href.indexOf("typepad");
if (dso_typepad > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='dso_typepad'<\/scr"+"ipt>");
} 


/* CANON  - DSO */
var dso_canon = window.location.href.indexOf("canon");
if (dso_canon > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='dso_canon'<\/scr"+"ipt>");
} 

/* CANON - ACTU */
var dso_actu= window.location.href.indexOf("actu24");
if (dso_actu> -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra ='actu_canon'<\/scr"+"ipt>");
} 

/* FONDSENDOSSIER */
var dso_fondsen= window.location.href.indexOf("extra/fondsendossier");
if (dso_fondsen> -1)
{
	document.write ("<scr"+"ipt language=javascript>var kanaal = 1504;<\/scr"+"ipt>");
} 

/* BEURS   CHI-X */
var beurs_chix = window.location.href.indexOf("extra/biz/chi-x");
if (beurs_chix > -1)
{
	document.write ("<scr"+"ipt language=javascript> var adhese_extra ='beurs_chix'; <\/scr"+"ipt>");
} 
var beurs_chix2 = window.location.href.indexOf("20100427_088");
if (beurs_chix2 > -1)
{
	document.write ("<scr"+"ipt language=javascript> var adhese_extra ='beurs_chix'; <\/scr"+"ipt>");
}

/* BEURS INDEXEN */
if ((window.location.href.indexOf("beurskoersen.aspx") > -1 && window.location.href.indexOf("?") == -1) || window.location.href.indexOf("artikelid=DMF20101006_081") > -1)
{
	document.write ("<scr"+"ipt language=javascript> var adhese_extra ='beurs_indexen'; <\/scr"+"ipt>");
} 

/* DOSSIER BLINDENZORG */
var dso_blindenzorg= window.location.href.indexOf("kanaalid=1513");
if (dso_blindenzorg > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_blindenzorg'<\/scr"+"ipt>");
} 

/* DOSSIER BNP PARIBAS */
var dso_bnpparibas= window.location.href.indexOf("kanaalid=1527");
if (dso_bnpparibas > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_bnpparibas'<\/scr"+"ipt>");
} 

/* DOSSIER FESTIVALS 2010 */
var dso_festivals = window.location.href.indexOf("aalId=434");
if (dso_festivals > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_festivals'<\/scr"+"ipt>");
} 




/* WEDSTRIJD WESTHOEK */
var dso_westhoek = window.location.href.indexOf("artikelid=DMF20100526_038");
if (dso_westhoek > -1)
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_westhoek'<\/scr"+"ipt>");
} 

/* ENERGIEGIDS - CREATIVE LAB - 201006 */
if (window.location.href.indexOf("kanaalid=1594") > -1 || window.location.href.indexOf("kanaalid=1593") > -1  || window.location.href.indexOf("kanaalid=1595") > -1  || window.location.href.indexOf("kanaalid=1591") > -1 )
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_energiegids'<\/scr"+"ipt>");
}

/* ING DOSSIER BEURS - 201010*/
if (window.location.href.indexOf("kanaalid=1866") > -1 )
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_ing_beursdossier'<\/scr"+"ipt>");
} 

/* DSO CAFE FOTO TAGGING */
if (window.location.href.indexOf("standaard.typepad.com/cafefoto/") > -1 )
{
	document.write ("<scr"+"ipt language=javascript>var adhese_extra = 'dso_cafefoto_'<\/scr"+"ipt>");
} 





/* basis paco wall count - jh - yvd - start */
	if  (typeof user_abo == "undefined"){ var user_abo = 0;}
	if (typeof user_id == "undefined"){ var user_id = 0;}
	if(user_id > 0 && user_abo == 0){ 
		if(GetCookie("paco_wall_count") == null) { 
			var visitCount = 0; var d = new Date(); d.setDate(d.getDate() + 365); var visitCount0 = visitCount + ";" + d + ";" + user_id; 
			SetCookie("paco_wall_count", visitCount0, d, "/"); }
		}
/* basis paco wall count - einde */






