﻿/*** @author tanya ***/

function ChangePic(elem, settings){
    this.root = elem;
    this.miniPics = this.root.find("a");
	this.bigPic = settings.bigPic;
    this.init();
    this.attachEvents();
}

ChangePic.prototype = {
    init: function(){
		
    },
    attachEvents: function(){
        var me = this;
        this.miniPics.mouseenter(function(event){
			event.preventDefault();
			var picA=$(this);
			if(!picA.hasClass('.active')){
				var link=picA.attr('href').replace(/(.*)[.](jpg|gif|png)/,"/autothumbs.php?img=$1_380_auto.$2");
				me.bigPic.attr('src',link);
				me.miniPics.removeClass('active');
				picA.addClass("active");
			}
        });
    },
}

$(function(){
    $(".miniPics").each(function(){
        new ChangePic($(this), {bigPic:$('#page .bigPic img')});
    }).find("a:first").addClass("active");
});

