//We need this var to make sure the same tumbnail don't triger the effect twice. 
//It is akting as kind of memory. It remember the last used tumb
var count

function ReplaceImages(ccode,uid){
	//If it is the previous tumbnail don't do it
	if (count!=uid)  {
	//Calling the server side script, replacing the big_image content	
    new Ajax('stylesheets/custom/ajax/ajax.php?CCODE='+ccode+'&ID='+ uid, {
        method: 'get',
        update: $('big_image'),
	    initialize: function(){
	    	//Making the style effect, don't wait previous to end,start with blank image, if interupted make it blank
		    this.fx1 = new Fx.Style('big_image','opacity', {
		    	duration:500,
		    	transition: Fx.Transitions.Quart.easeInOut,
		    	wait: false,
		    	onStart: function() {
		    		$('big_image').effect('opacity').set(0);
		    	},
		    	onCancel: function() {
		    		$('big_image').effect('opacity').set(0);
		    	}
		    });
			
	    },
	    //On new ajax request hide the image
	    onRequest:function(){
		    this.fx1.set(0);
	    },
	    //Do the effect once the ajax get it's value
	    onComplete:function(){
	    	
		    this.fx1.start(0,.99);
	    }
    }).request();
	}
	//Reseting the memory 
    count=uid;
 
}

