/* Jquery scripts voor Ashladan en Panzerkampf. Het bestand bevat de volgende scirpts:
*password strenge
*Afbeelding resize script
*Selecteerbare rij die checkbox en bg kleur veranderd
*/
/* begin Rij selectie script*/
/*
  $(function() {
            //kijk of er checkboxen checked zijn bij document ready.
            $("input:checkbox:checked").each(function() {
                $(this).parents("li").addClass("selected");
            });

            //CLICK EVENT dus werkt niet voor keyboard input.
            //CHANGE EVENT is ook mogelijk maar IE doet daar nogal raar mee.
            $("input:checkbox").click(function() {
                if ($(this).attr("checked")) {
                    $(this).parents("li").addClass("selected");
					 $(this).parents("li").removeClass("bg1 bg2 bg3 reported");
                } 
                else {
                    $(this).parents("li").removeClass("selected");
                }
            });
        });
	*/
	/* einde Rij selectie script*/
$(document).ready(function() {
  $('.mpc')
 .filter(':has(:checkbox:checked)').
 removeClass('bg1 bg2 bg3 reported')
 .addClass('selected')
 .end()
  .click(function(event) {
 $(this).toggleClass('selected');
 if (event.target.type !== 'checkbox') {
   $(':checkbox', this).attr('checked', function() {
  return !this.checked;
  
   });
 }
  });
});
/* begin afbeelding resize script*/
$(document).ready(function() {
    $('.postimage').each (function() {
        var maxWidth = 500; // Max width for the image
        var maxHeight = 500;    // Max height for the image
        var ratio = 1;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
 
        // Check if the current width is larger than the max
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            $(this).css("width", maxWidth); // Set new width
            $(this).css("height", height * ratio);  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }
 
        // Check if current height is larger than max
        if(height > maxHeight){
            ratio = maxHeight / height; // get ratio for scaling image
            $(this).css("height", maxHeight);   // Set new height
            $(this).css("width", width * ratio);    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
        }
    });
});
/* einde afbeelding resize script*/

/* begin password strengte script*/
$(document).ready(function(){
    $('form').passroids({ 
       main: '#new_password',
       verify: '#password_confirm',
       button: '.button100',
       minimum: 1
    });
});
/* einde password strengte script*/
