Código PHP:
(function($){$(document).ready(function(){$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
var w=$(this).attr("id");});function format(str){for(var i=1;i<arguments.length;i++){
str=str.replace('%'+(i-1),arguments[i])}return str}function CloudZoom(jWin,opts){
var sImg=$('img',jWin);var img1;var img2;var zoomDiv=null;var $mouseTrap=null;
var lens=null;var $tint=null;var softFocus=null;var $ie6Fix=null;var zoomImage;
var controlTimer=0;var cw,ch;var destU=0;var destV=0;var currV=0;var currU=0;
var filesLoaded=0;var mx,my;var ctx=this,zw;setTimeout(function(){if($mouseTrap===null){
var w=jWin.width();jWin.parent().append(format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center"
class="cloud-zoom-loading" >Loading...</div>',w/3,(w/2)-(w/6))).find(':last').css('opacity',0.5)}},200);
var ie6FixRemove=function(){if($ie6Fix!==null){$ie6Fix.remove();$ie6Fix=null}};this.removeBits=function(){if(lens){
lens.remove();lens=null}if($tint){$tint.remove();$tint=null}if(softFocus){softFocus.remove();softFocus=null}ie6FixRemove();$('.cloud-zoom-loading',jWin.parent()).remove()};this.destroy=function(){jWin.data('zoom',null);
if($mouseTrap){$mouseTrap.unbind();$mouseTrap.remove();$mouseTrap=null}
if(zoomDiv){zoomDiv.remove();zoomDiv=null}this.removeBits()};this.fadedOut=function(){
if(zoomDiv){zoomDiv.remove();zoomDiv=null}this.removeBits()};this.controlLoop=function(){
if(lens){var x=(mx-sImg.offset().left-(cw*0.5))>>0;var y=(my-sImg.offset().top-(ch*0.5))>>0;
if(x<0){x=0}else if(x>(sImg.outerWidth()-cw)){x=(sImg.outerWidth()-cw)}if(y<0){y=0}else if(y>(sImg.outerHeight()-ch)){y=(sImg.outerHeight()-ch)}lens.css({left:x,top:y});
lens.css('background-position',(-x)+'px '+(-y)+'px');destU=(((x)/sImg.outerWidth())*zoomImage.width)>>0;
destV=(((y)/sImg.outerHeight())*zoomImage.height)>>0;currU+=(destU-currU)/opts.smoothMove;currV+=(destV-currV)/opts.smoothMove;
zoomDiv.css('background-position',(-(currU>>0)+'px ')+(-(currV>>0)+'px'))}controlTimer=setTimeout(function(){ctx.controlLoop()},30)};
this.init2=function(img,id){filesLoaded++;if(id===1){zoomImage=img}
if(filesLoaded===2){this.init()}};this.init=function(){ $('.cloud-zoom-loading',jWin.parent()).remove();$mouseTrap=jWin.parent().append(
format("<div class='mousetrap' id='"+w+"' style='background-image:url(\".\");
z-index:999;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;\'></div>",sImg.outerWidth(),sImg.
En la primera-segunda linea he definido una variable: var w=$(this).attr("id");
ya que .cloud-zoom tiene un id que le saco.
Y en las tres ultimas lineas pongo +w+ pero después de tantas funciones ya ha cambiado y no es el mismo...
¿Como puedo trasladar ese w que quiero hasta allí abajo y que sea el mismo sin que varía con tantas funciones..?
¿Se puede hacer una variable de local a global?
¿Se puede hacer una variable fija fija?