/*
Name: Grayscale
URI: http://rubensargsyan.com/grayscale/
Author: Ruben Sargsyan
Author URI: http://rubensargsyan.com/
Version: 1.0
Created: 20.03.2010
       
Grayscale by Ruben Sargsyan is licensed under a Creative Commons Attribution 3.0 United States License.
*/
window.onload = function(){
  all_images = document.getElementsByTagName("img");

  if(all_images.length>0){
    for(var i=0; i<all_images.length; i++){
        the_class = all_images[i].className;
        pattern = /(\s|^)grayscale(\s|$)/;

        if(!pattern.test(the_class)){
            continue;
        }

        var the_image = all_images[i];
        var color_image_src = the_image.src;
        var grayscale_image_src = "/grayscale/grayscale.php?source_file="+color_image_src;
        the_image.src = grayscale_image_src;
        the_image.onmouseover = function(){
            this.src = this.src.substring(this.src.lastIndexOf("=")+1);
        }
        the_image.onmouseout = function(){
            this.src = "/grayscale/grayscale.php?source_file="+this.src;
        }
    }
  }

}
