// zoomi - A zoom for images ~ Sean Catchpole - Version 0.9
(function($){

$.fn.zoomi = function() {
  $(this).filter("img").each(function(){
    if(!this.z) {
      $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
      $(this.z).mouseout(function(){$(this).hide();}); }
  });
 return this;
}

$.fn.zoom1 = function() {
  $(this).each(function(){
    var e = this;
    $(e).css({'position':'relative','z-index':'8'}).after('<img class="'+e.className+'" height="150" width="217">');
    e.z = e.nextSibling;
    $(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
    .css({'position':'absolute','z-index':'10'});
    $(e.z).hide();
  });
  return this;
}

$.fn.zoom2 = function() {
  var s = [];
  this.each(function(){
    var e = this;
    if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
    if(!e.z.complete) return;
    if(!e.z.width) { $(e.z).show(); e.z.width=e.z.width; $(e.z).hide(); }
    $(e.z).css({left:$(e).offsetLeft()-(e.z.width-e.scrollWidth)/2+'px',
    top:$(e).offsetTop()-(e.z.height-e.scrollHeight)/2+'px'});
  });
  return this.pushStack(s);
}

$.fn.offsetLeft = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetLeft;
  return e.offsetLeft + $(e.offsetParent).offsetLeft(); }

$.fn.offsetTop = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetTop;
  return e.offsetTop + $(e.offsetParent).offsetTop(); }

$(function(){ $('img.zoomi').zoomi(); });

})(jQuery);

 

$(function(){
 
  $('#zoomme img').zoom1().click(
    function()
    {
         $(this).zoom2().fadeIn().click(
         function()
         {
             $(this).hide(); return false;
          }
          )
    .end().parent().addClass('red'); return false; 
     });

 	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=neptune-1-1-1"><img border=0 class="zoomi" style="margin:5px 50px 0px 50px" src="http://www.calofic.com.vn/uploads/images/neptune_142x98px.jpg" height="98" width="142"></a>');
	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=simply"><img class="zoomi" style="margin:5px 50px 0px 0px" src="http://www.calofic.com.vn/uploads/images/simply_142x98px.jpg" height="98" width="142"></a>');
	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=kiddy"><img class="zoomi" style="margin:5px 0px 0px 0px" src="http://www.calofic.com.vn/uploads/images/kiddy_142x98px.jpg" height="98" width="142"></a><br />');
	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=meizan"><img border=0 class="zoomi" style="margin:15px 50px 0px 50px" src="http://www.calofic.com.vn/uploads/images/meizan_142x98px.jpg" height="98" width="142"></a>');
	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=Olivoila"><img class="zoomi" style="margin:15px 50px 0px 0px" src="http://www.calofic.com.vn/uploads/images/logo-olivoila.jpg" height="98" width="142"></a>');
	$('#bleach').append('<a href="http://www.calofic.com.vn/index.php?page=cai-lan"><img class="zoomi" style="margin:15px 0px 0px 0px" src="http://www.calofic.com.vn/uploads/images/cailan_142x98px.jpg" height="98" width="142"></a>');	

  $('#bleach img.zoomi').zoomi();
 
  $('.bw img')
  .zoom1().mouseover(function(){ $(this).zoom2().fadeIn(); })
  .zoom2().mouseout(function(){ $(this).fadeOut(1800); });
});
 

