﻿ function changeBG(theA){
        theColor= theA.parentNode.style.backgroundColor
        if(theColor == ""){
            theA.parentNode.style.backgroundColor='#f8f4bd'
        }else{
            theA.parentNode.style.backgroundColor=''
        }
    }
    
   
       
       
       $(document).ready( function()
        {
           PEPS.rollover.init();
        });

        PEPS = {};
       
        PEPS.rollover =
        {
           init: function()
           {
              this.preload();
             
              $(".ro").hover(
                 function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
                 function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
              );
	      
	      $(".co").hover(
                 function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
                 function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
              );
	      
	      $(".co").click(
		function () { $(this).attr( 'src', PEPS.rollover.highlight($(this).attr('src')) ); }
	      )
           },

           preload: function()
           {
              $(window).bind('load', function() {
                 $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
              });
           },
           
           newimage: function( src )
           {
		var hStr = /_Highlight/
		var oStr = /_On/
	     
		if(src.search(hStr) > 0){
			theSrc =  src.replace(/_Highlight/, '_On')
		}else{
			theSrc = src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_On' + src.match(/(\.[a-z]+)$/)[0];
		}
		return theSrc
	     
              //return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_On' + src.match(/(\.[a-z]+)$/)[0];
              
           },

           oldimage: function( src )
           {
             
	      
                     if(globalImage != ""){
                               var gLen = globalImage.indexOf('_Highlight')
                               var sLen = src.indexOf('_On')
                               
                               if(globalImage.substring(0, gLen) == src.substring(0,sLen)){
                                       return src.replace('_On', '_Highlight');
                               }else{
                                       return src.replace(/_On\./, '.');
                                       
                               }
                     }else{		
                               return src.replace(/_On\./, '.');
                     }
              
           },
	   
	   
	   
	   highlight: function(src)
	   {
		//globalImage = src.replace(/_On/, '_Highlight');
		return src.replace(/_On/, '_Highlight');
	   }
        };
        
 
    